This note detail how to update udev rules for an Ethernet connection and have them take effect without rebooting the machine. The critical part is using rmmod and modprobe to remove and re-load the networking module for the Ethernet connection, which effectively “unplugs” and “replugs” the connection, causing the udev rules to take effect. Note that this will cause brief downtime for the specific network interface, but avoids rebooting the entire machine.
First lets run ip addr to show the interfaces we are starting with:
Next we add our udev rule, which should give the Ethernet interface with the MAC address aa:bb:cc:dd:ee:ff the interface name ethfoo.
However this is not enough. It is necessary to unload and reload the module used for networking on that interface.
Examples of module names I’ve come across are:
ixgbe
tg3
e1000
asix
vmxnet3
The easiest way to find out which modules applies to your Ethernet connection is to physically unplug the cable (or virtually remove it if running a VM) and then run dmesg | tail to see the latest dmesg log. You should see something like this:
Or this:
In the first case I now know that the ens33u1 interface uses the asix module.
To unload and reload the module I run:
Finally I can run ip addr and see that the udev rules have taken effect - it is now called ethfoo: