Home > Operation and Maintenance > Docker > How to solve centos cannot find ifcfg configuration file

How to solve centos cannot find ifcfg configuration file

WJ
Release: 2020-06-05 15:44:03
Original
3833 people have browsed it

How to solve centos cannot find ifcfg configuration file

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/
Copy after login

How to solve centos cannot find ifcfg configuration file

Some people may not have this file, then we can use

Close NetworkManager service

  $ service NetworkManager stop
Copy after login

Close NetworkManager and start up

 $ chkconfig NetworkManager off
Copy after login

How to solve centos cannot find ifcfg configuration file

mkdir ifcfg-eth0
Copy after login

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
Copy after login

After we complete the modification. Just write it into it

vi /etc/sysconfig/network-scripts/ifcfg-eth0
Copy after login

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
Copy after login

Open network service

service network start
Copy after login

Verify whether it is successful

ping www.php.cn
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template