Making network names persistent after cloning

It’s been a while since I started wondering if it’s possible to make network names persistent after cloning a Debian system and re-initializing the MAC address. I know how to do it on SLES10 but I never did it on Debian. So started searching.

Debian makes the network name persistent in /etc/udev/rules.d/70-persistent-net.rules. It uses the MAC address to make the name persistent so I had to find a way to replace the MAC based naming by a better one. I decided to use the PCI location because I assume it’s the one which stays permanent after cloning. So wrote a rule based on the PCI location.
To find the location, mdadm was very helpful. Running udevadm info --path=/sys/class/net/eth0 --attribute-walk gives you all the information you need. The parent device had this info:
KERNELS=="0000:00:03.0"
SUBSYSTEMS=="pci"

After commenting out the original lines in /etc/udev/rules.d/70-persistent-net.rules, I added this to the udev rules: SUBSYSTEM=="net", ACTION=="add", SUBSYSTEMS=="pci", KERNELS=="0000:00:03.0", KERNEL=="eth*", NAME="eth0". Testing the modifications can be done using mdadm again: udevadm test /sys/class/net/eth0 2>&1 | more . In my case I originally forgot the double equal sign and I saw the error running the test. Cloning the system gave me the result I searched for.

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s