How to regenerate the /etc/udev/rules.d/70-persistent-net.rules file on Debian/Ubuntu

For quite a few years now most linux distributions ship udev with a network interface name caching mechanism. This simply means that whenever udev assigns a name for a network interface, it's cached (based on the interface's MAC address) in /etc/udev/rules.d/70-persistent-net.rules. However if you're cloning a system, the copy still contains this cache file. And since it lists your common interface names (from the original/source system) like eth0 or eth1 as occupied by specific MAC addresses, the cloned system will get new interface names (eg. eth2, eth3, rename3, etc.). Obviously this will break everything that references the old names and most of the time this will result in no network in the cloned system.

Usually the /etc/udev/rules.d/70-persistent-net.rules file can simply be deleted and it'll be regenerated upon reboot. But sometimes it's not or not fully regenerated. In these cases you can try either of these:
  • udevadm trigger
  • udevadm trigger --action=add
For me on an Ubuntu Precise (12.04.1) system the reboot created an entry in the rules file only for one of the NICs. And the udevadm trigger did not recreate the rules file. However the udevadm trigger --action=change command did the trick: /etc/udev/rules.d/70-persistent-net.rules was regenerated and it contained entries for both NICs.

P.S.: the udevadm trigger --action=change trick should be used only after you deleted the rules file and rebooted.

Syndicate content