How to write rules for persistent net names?
Posted
by
ndemou
on Server Fault
See other posts from Server Fault
or by ndemou
Published on 2014-06-03T15:20:04Z
Indexed on
2014/06/06
9:28 UTC
Read the original article
Hit count: 318
I know that a process generates persistent network card names based on rules found in /lib/udev/rules.d/75-persistent-net-generator.rules. I also know how to completely disable this process with a simple
echo '#' > /etc/udev/rules.d/75-persistent-net-generator.rules
but I've read that I "could also write my own rules file to give the interface a name — the persistent rules generator ignores the interface if a name has already been set" (/etc/udev/rules.d/README confirms that this is possible).
Do you have any pointers to documentation about how to write such rules? (I mostly care about Debian/Ubuntu and a bit less for CentOS)
As a specific example of why I want to write custom rules: I have two identical servers with one onboard LAN and one PCI LAN. In case of HW failure I want to be able to move disks from HW#1 to HW#2 and it's important for eth0 to continue pointing to the onboard card and eth1 to the PCI card (no one wants to mess with cabling in the middle of a HW failure panic). My current workaround works but is a lot of work[1] so I wonder if writing custom rules would allow me to express something simple like this:
- cards with MAC A or B should be named eth0
- cards with MAC C or D should be named eth1
- follow default naming scheme for anything else
[1] install the OS in HW#1 and keep a copy of /etc/udev/rules.d/70-persistent-net.rules. Move the disks to HW#2 and keep a second copy of the same file. Concatenate the two copies and manually edit the NAME="ethX" part. Replace /etc/udev/rules.d/70-persistent-net.rules with my version. Finally disable auto-creation of a new 70-persistent-net.rules using
echo '#' > /etc/udev/rules.d/75-persistent-net-generator.rules
© Server Fault or respective owner