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

Solution to the drift of network card serial number (copy virtual machine IP problem)

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

I will not say much about the reasons for this problem, for example: changing the motherboard (integrated network card), changing the network card, virtual machine COPY and so on will occur the network card serial number drift phenomenon. However, our batch processing script is generally aimed at fixed Nic serial numbers (such as eth0/eth2). If it becomes eth3/eth4, it will obviously cause inconvenience to batch operations.

1. Identify the existing network card

You can use ifconfig-a | grep HWaddr to view the MAC of all network cards (record the corresponding MAC of the network card whose serial number needs to be changed). If you only want to determine the specific physical network card, you can use the method of unplugging the network cable with sudo ethtool ethX to determine (in the output result: Linked detected:yes, indicating that the network cable is connected; Linked detected:no, indicating that the network cable is not connected).

two。 Modify the configuration file

The configuration file for Ubuntu to save the MAC address is "/ etc/udev/rules.d/70-persistent-net.rules", which is as follows:

SUBSYSTEM== "net", ACTION== "add", DRIVERS== "? *", ATTR {address} = = "8c:89:a5:61:99:c3", ATTR {dev_id} = = "0x0", ATTR {type} = = "1", KERNEL== "eth*", NAME= "eth2"

# PCI device 0x8086:0x10c9 (igb)

SUBSYSTEM== "net", ACTION== "add", DRIVERS== "? *", ATTR {address} = = "8c:89:a5:61:99:c2", ATTR {dev_id} = = "0x0", ATTR {type} = = "1", KERNEL== "eth*", NAME= "eth0"

# PCI device 0x8086:0x10c9 (igb)

SUBSYSTEM== "net", ACTION== "add", DRIVERS== "? *", ATTR {address} = = "6c:62:6d:b3:bb:32", ATTR {dev_id} = = "0x0", ATTR {type} = = "1", KERNEL== "eth*", NAME= "eth3"

# PCI device 0x8086:0x10c9 (igb)

SUBSYSTEM== "net", ACTION== "add", DRIVERS== "? *", ATTR {address} = = "6c:62:6d:b3:bb:33", ATTR {dev_id} = = "0x0", ATTR {type} = = "1", KERNEL== "eth*", NAME= "eth4"

BLOG: http://blog.sina.com.cn/s/blog_4152a9f50100wrxf.html of Skyfire

Edit this file with vi, delete the previous eth0/eth2 configuration based on the current MAC address, and then modify eth3's NAME= "erh3" to NAME= "eth0" and eth4's NAME= "erh4" to NAME= "eth2". The modified content is as follows:

SUBSYSTEM== "net", ACTION== "add", DRIVERS== "? *", ATTR {address} = = "6c:62:6d:b3:bb:32", ATTR {dev_id} = = "0x0", ATTR {type} = = "1", KERNEL== "eth*", NAME= "eth0"

# PCI device 0x8086:0x10c9 (igb)

SUBSYSTEM== "net", ACTION== "add", DRIVERS== "? *", ATTR {address} = = "6c:62:6d:b3:bb:33", ATTR {dev_id} = = "0x0", ATTR {type} = = "1", KERNEL== "eth*", NAME= "eth2"

Save exit, restart the system, and Ubuntu will use the new configuration file to set up the network card.

Note: before restarting the system, please modify the serial number of the network card in / etc/network/interfaces (currently eth3 and eth4) to the new serial number after the change (eth0 and eth2 after the change), otherwise, the network card cannot be started due to the change of the serial number of the network card after the system restart, and it will not be accessible remotely.

If you do not restart, you can restart load udev rules and restart udev

/ sbin/udevadm control-- reload-rules

/ sbin/start_udev

Service network restart

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

Network Security

Wechat

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

12
Report