I have been using the following to maintain consistency with udev across MAC address changes (e.g. swapping out NIC cards, etc). By default, udev builds rules the first time to associate an interface name with a MAC address, which works fine until the NIC cards are changed, or the system disk is moved to another box that has different MAC addresses (e.g. even in the motherboard):
Code:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth0", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth1", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth2", NAME="eth2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth3", NAME="eth3"
The problem with the above "solution" is it will not attempt to correct a different probe order when that happens during kernel initialization. I've never seen such a thing happen with multiple port NIC cards (like motherboards with 2 or 4 ports). But I'm now working with some machines which have 1 NIC on the motherboard and a dual port card plugged in with a different driver. Sometimes the interfaces come up differently.
So I really do need to implement something that makes things consistent. But the MAC address simply cannot do this because it is too volatile (e.g. it can change with NIC cards or motherboard is changed).
The idea I have is to use the BUS address. In the /sys/devices tree this is known as "device". I could code udev rules to match specific devices to specific interfaces. Still there is a problem with mass deployment in that these device bus addresses are not the same on different machines. I do want the setup to be the same. So merely coding specific device addresses and interface names in a udev rule would not accomplish it universally (e.g. each machine might need a different one).
Potentially I could have my own script generate such a configuration for a specific machine. But my question right now is, is there a way to just tell udev to do what it does, but instead of basing the association it stores on the MAC address, base it instead on the BUS device address.
So instead of ending up with /etc/udev/rules.d/70-persistent-net.rules having:
Code:
# 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 0x8086:0x10d3 (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:90:14:c4:58", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x10d3 (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:90:14:c4:59", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
I would get something that had "ATTR{device}" instead of "ATTR{address}". If udev can do this (somehow), that would be the "right way" I think. But if not, I guess I would have to generate these myself (probably scripted after testing a couple of them).