This is the 26th day of my participation in the August Text Challenge.More challenges in August

There are two network cards on the device used in the project. Note that eth0 and eth1 were differentiated in the setting at the beginning, and the problem was not found until eth0 was invalid. In fact, we created this problem ourselves. Because the hard disk is used in our project, the hard disk on one device will be directly transferred to another device for use. When the system of the original device has the configuration of the network adapter, the name of the network adapter will be changed on a new hardware platform (though it is still the same hard disk).

Such as:

# dmesg | grep udev [5.005449] systemd - udevd [1174] : starting version 204 [5.598720] systemd - udevd [1648] : 7. 命 Network interface eth0 to eth2 [6.610114] Systemd-udevd [1650]: configuration network interface eth1 to eth3Copy the code

This problem has a lot of discussion on the Internet, I also groped for a long time to solve, but the solution, I do not know whether it is complete, at least, use so far, the name of the network card has always been eth0 and eth1. In Linux, nic devices and MAC addresses are stored in the /etc/udev/rules.d/70-persistent-net.rules file. If the file already has an eth0, the next boot on a different device will add eth1 — regardless of whether eth0 is valid or not. Here is an example of this file:

This file maintains persistent names for network interfaces. # See udev(7) for syntax. # # Entries are automatically added by the 75-persistent-net-generator.rules # file; however you are also free to add your own entries. # PCI device 0x10ec:0x8168 (r8169) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="? *", ATTR{address}=="4c:41:54:45:4c:45", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"Copy the code

Because of this, when I used debootstrap to create the root file system, I had to empty this file to avoid the problem of changing the name of the nic device.

Solution:

1.

Delete /etc/udev/rules.d/70-persistent-net.rules from /etc/udev/rules.d/70-persistent-net.rules from /etc/udev/rules.d/70-persistent-net.rules from /etc/udev/rules.d/70-persistent-net. Clear /etc/udev/rules.d/70-persistent-net.rules at startup. To clear rules, run the echo “” > /etc/udev/rules.d/70-persistent-net.rules command

2,

In the /lib/udev/write_net_rules file, change the RULES_FIL path to another directory that does not exist:

RULES_FILE='/etc/udev/not_rules.d/70-persistent-net.rules'
Copy the code

3,

In the /lib/udev/rules.d/75-persistent-net-generator.rules file, comment out the following:

# device name whitelist #KERNEL! ="eth*|ath*|wlan*[0-9]|msh*|ra*|sta*|ctc*|lcs*|hsi*", \ # GOTO="persistent_net_generator_end"Copy the code

In the second point, there is a question, the current equipment does not carry out this operation is normal. Because it was settled a long time ago, now forget, will not change.