Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Device example Analysis of ifcfg in CentOS

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about the device sample analysis of ifcfg in CentOS. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

# cat ifcfg-eth0

Device=eth0

...

Reason: a multi-node server moved to the computer room, for fear of being damaged, the hard disk was removed first, but when it was put back, it was in the wrong order, resulting in the mismatch of the boot network card, and the original eth01 became eth33. I know how to do it.

Analysis:

The solution of not finding eth0 device under CentOS

After Baidu, I learned some information and hereby record it here as a memo. Why did eth0 become eth2? Many Linux distribution use udev to dynamically manage device files and name them persistently based on the information of the device. Udev will identify the network card during the system boot and record the mac address and the name of the network card in the rule script of udev. For the new virtual machine, VMware will automatically generate the MAC address for the network card of the virtual machine, when you clone or reinstall the virtual machine software, because you are using the information of the virtual hard disk of the previous system, and the system already has the information of eth0, for this new network card, udev will automatically name it eth2 (the principle of accumulation), so after your system starts, you use the network card that ifconfig sees as eth2.

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 did eth0 become eth2?

How do I get back 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= "eth2"

The solution of not finding eth0 device under CentOS opens the file, and you will find that there is information about two network cards in eth0,eth2, but in fact, when you ifconfig, you can only find the information of one network card in eth2, because eth0 does not exist at all. Delete the eth0 information, and change the device name in the eth2 message 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 find new devices. In addition, there is a startup script file / etc/sysconfig/network-scripts/ifcfg-eth0, in which the mac address is the physical address of the original eth0 network card, while the virtual machine assigns a new physical address to the eth2, so if the information in the startup script does not match the actual information, modify the address information of the MAC to the MAC address of the eth2 in the 70-persistent-net.rules, restart the network again, and completely return to the state of the previous eth0 network card.

Thank you for reading! This is the end of this article on "device sample Analysis of ifcfg in CentOS". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report