I’m adding this because some day I will need it… again.
Sometimes you get an incorrect matching of ethernet device numbers and MAC addresses. Sometimes this is really important, like when running in a VM and each device is assigned to a different VLAN.
Steps to follow to solve or minimize this
- Bring the network interfaces down, then
- modify /etc/udev/rules.d/70-persistent-net.rules (or its equivalent)
- re-load with udevadm control –reload-rules and finally
- re-trigger with udevadm trigger –attr-match=subsystem=net
- bring the network interfaces up.
I was surprised how well this worked, an example:
# vi /etc/udev/rules.d/70-persistent-net.rules
This is how it look before:
# PCI device 0x10ec:0x8139 (8139cp) (custom name provided by external tool) #SUBSYSTEM=="net", ACTION=="add", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
we will modify to always naming the interfaces based on its MAC address
# 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. # Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b6:5d:09:9e:f0:dc", ATTR{type}=="1", NAME="eth0" # Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="c2:77:a2:d8:fd:c8" ATTR{type}=="1", NAME="eth1"