How to solve the problem that centos cannot find the ifcfg configuration file?
After installing the CentOS 7 system on the virtual machine, when configuring communication with the host, use ifconfig to check whether there is an eth0 network card (it may also only have a loopback network card lo), so check the eth0 network card configuration file, it was found that there is no ifcfg-eth0
network card configuration file in the /etc/sysconfig/network-scripts/
directory.
The specific steps are as follows:
ls /etc/sysconfig/network-scripts/
Some people may not have this file, then we can use
Close NetworkManager service
$ service NetworkManager stop
Close NetworkManager and start up
$ chkconfig NetworkManager off
mkdir ifcfg-eth0
After creating the file, we need to write the corresponding host IP into it
The specific configuration information written is as follows
DEVICE="eth0" BOOTPROTO="static" #设置为静态ip地址 IPV6INIT="yes" NM_CONTROLLED="yes" ONBOOT="yes" TYPE="Ethernet" UUID="ce22eeca-ecde-4536-8cc2-ef0dc36d4a8c" IPADDR=172.16.4.22 #修改为自己的ip地址 PREFIX=24 NETMASK=255.255.254.0 #修改为自己的子网掩码 GATEWAY=192.168.0.1 #修改为自己的网关 DNS1=192.168.0.1 #修改为自己的dns DEFROUTE=yesIPV4_FAILURE_FATAL=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no NAME="System eth0" HWADDR=00:0C:29:3C:BF:E7 IPV6_PEERDNS=yes IPV6_PEERROUTES=yes LAST_CONNECT=1501853614
After we complete the modification. Just write it into it
vi /etc/sysconfig/network-scripts/ifcfg-eth0
After opening it, press i on the keyboard to enter the writing mode
Just write the modified configuration file above
Press Esc key and then Shift: Enter wq! Save and exit
Boot upnetwork
chkconfig network on
Open network service
service network start
Verify whether it is successful
ping www.php.cn
Related references: centOS tutorial
The above is the detailed content of How to solve centos cannot find ifcfg configuration file. For more information, please follow other related articles on the PHP Chinese website!