#cat ifcfg-eth0
device=eth0
...
Reason: There is a multi-node server migration computer room. I was afraid of damage, so I removed the hard disk first, but when I put it back, I remembered the wrong order, causing the network card to not match the boot, and the original eth01 became eth23. I know. How to do it.
analyze:
Solution to the problem that the eth0 device cannot be found under CentOS
After passing Baidu, I learned some information, and I will record it here for memento. Why does eth0 become eth1? Many Linux distributions use udev to dynamically manage device files and persistently name them based on device information. udev will identify the network card during the system boot process, and record the corresponding mac address and network card name in udev's rule script. For new virtual machines, VMware will automatically generate a MAC address for the virtual machine's network card. When you clone or reinstall the virtual machine software, you are using the virtual hard disk information of the previous system, and the system already has eth0. Information, for this new network card, udev will automatically name it eth1 (accumulation principle), so after your system starts, the network card you see using ifconfig is named eth1.
The eth0 here is defined in /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
## You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}= ="1", KERNEL=="eth*", NAME="eth0"
Solution: Why does eth0 become eth1?
How to restore to eth0? The script for udev to record network rules is: /etc/udev/rules.d/70-persistent-net.rules [user@localhost ~]$ vi /etc/udev/rules.d/70 -persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program run by the persistent-net-generator.rules rules file.
## You can modify it, as long as you keep each rule on a single line.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:5a:6c:73", ATTR{type}= ="1",KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a9:22:9d", ATTR{type}= ="1",KERNEL=="eth*", NAME="eth1"
Solution to the problem that the eth0 device cannot be found under CentOS Open the file, and you will find that there is information about two network cards, eth0 and eth1, but in fact you can only find information about one network card, eth1, during ifconfig. Because eth0 does not exist at all. Delete the eth0 information and change the device name in the eth1 information to eth0. Restart the system. The network card you see is eth0. Or delete all the information and restart the system. Udev will help you discover new devices. . There is also a startup script file /etc/sysconfig/network-scripts/ifcfg-eth0. The mac address in this file is the physical address of the original eth0 network card, and the virtual machine assigns a new physical address to eth1, so the If the information does not match the actual information, change the MAC address information to the MAC address of eth1 in 70-persistent-net.rules, restart the network again, and it will be completely restored to the previous state of the eth0 network card.
The above is the detailed content of Parsing device fields of ifcfg files in CentOS. For more information, please follow other related articles on the PHP Chinese website!