After the enterprise-level Linux distribution CentOS is installed, the network connection service is not enabled by default, and the network service can be used after manually starting it. After the latest version of CentOS 7.0 is installed, the network configuration file is in the /etc/sysconfig/network-scripts/ directory. After entering the directory, find the network configuration file under it: ifcfg-enp0s3 (the specific file name will vary depending on the hardware, in accordance with ifcfg- en* format is fine), the default content of the configuration file is as follows:
12345678910111213141516 | HWADDR=00:1C:22:AD:74:43TYPE=EthernetBOOTPROTO=dhcpDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yesIPV6_FAILURE_FATAL=noNAME=enp0s3UUID=ae0718e7-25s9-43ra-8hp9-9d4g20a88ib1ONBOOT=no |
---|
Modify the last item ONBOOT=no
to ONBOOT=yes
to start the network service, save and exit.
Use the following command to restart the network service:
1 | service network restart |
---|
At this time, the network service has been turned on and can be used normally. The ifconfig command is usually used to view the network connection information. You may find that the newly installed CentOS 7.0 does not support the ifconfig command and will prompt "ifconfig command not found". At this time, you need to install an additional network toolkit to solve the problem. The command is as follows:
12 | # yum upgrade#yum install net-tools |
---|
After the installation is complete, you can use the ifconfig command to view information such as the ip address.
You can also use the ip addr command to view network card information
If you are setting static ip, you need to modify the following files
IP related parameters: /etc/sysconfig/network-scripts/ifcfg-eth0
DNS : /etc/resolv.conf
ifcfg-eth0:
TYPE=Ethernet
NETWORK (the first ip of the network segment), BROADCAST (the broadcast address can be omitted)
DNS:
nameserver 180.76.76.76
nameserver 202.96.134.13
I encountered this problem when I helped my colleague install a virtual machine with vbox today
device eth0 does not seem to present.
Trouble phenomenon:
service network restart
Shutting down loopback insterface: [ OK ]
Bringing up loopback insterface: [ OK ]
Bringing up interface eth0: Device eth0 does not seem to be present,delaying initialization. [FAILED]
Solution:
First, open the content of /etc/udev/rules.d/70-persistent-net.rules as shown in the following example:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?", ATTR{address}=="00:0c:29:8f:89:9
7", ATTR{type}=="1", KERNEL=="eth", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?", ATTR{address}=="00:0c:29:50:bd:1
7", ATTR{type}=="1", KERNEL=="eth", NAME="eth1"
Record the mac address of the eth1 network card 00:0c:29:50:bd:17
Next, open /etc/sysconfig/network-scripts/ifcfg-eth0
Change DEVICE="eth0" to DEVICE="eth1",
Change HWADDR="00:0c:29:8f:89:97" to the above mac address HWADDR="00:0c:29:50:bd:17"
Finally, restart the network
or
normal now.
Recommended Posts