How to disable udev net rule generation?
Solution 1
You can override the /lib/udev/rules.d/*
by copying them to /etc/udev/rules.d
and then modifying them.
Or alternatively, you can create a new file with a lexically higher name e. g. /etc/udev/rules.d/99-stop-persistent-net.rules
with the following "do nothing" entry:
SUBSYSTEM=="net", DRIVERS=="?*", NAME="%k"
This should prevent new rules from being created as udev thinks the interface is already listed. This will also survive udev updates etc.
Sorry, don't have time to test it…
Solution 2
Based on JasminJ's answer, I read the manual. Well, I read a very small portion of it. The fifth sentence in the "Rules files" section states:
This can be used to override a system-supplied rules file with a local file if needed; a symlink in
/etc
with the same name as a rules file in/lib
, pointing to/dev/null
, disables the rules file entirely.
I just tested this with a VM and it does indeed work as described. I prefer this to conventional/hacky methods of disabling this functionality.
Here is the command
ln -s /dev/null /etc/udev/rules.d/75-persistent-net-generator.rules
Solution 3
cd /etc/udev/rules.d
rm -f 70-persistent-net.rules
rm -f 75-persistent-net-generator.rules
echo "# " > 75-persistent-net-generator.rules
See https://www.kernel.org/pub/linux/utils/kernel/hotplug/udev/udev.html
chapter "Rules files"
Related videos on Youtube
borfig
Updated on September 18, 2022Comments
-
borfig over 1 year
In our cloud, we generate MACs with the prefix
2c:c2:60
for instances. When we re-use an instance, or duplicate it, the new copy gets another MAC address. When the new copy boots, the NIC gets the name eth1 due to the new MAC.I see that in
/lib/udev/rules.d/75-persistent-net-generator.rules
, there are rules for known prefixes such as52:54:00 (KVM)
andVMWare (00:0c:29)
. But this file should not be edited as stated in its first line. We would like to use our own registered MAC prefix and not others' ones.How to disable net rules generation completely?
-
borfig over 11 yearsThe first suggestion works. The alternative suggestion does not.
-
Sathiya Narayanan over 11 yearsHere is another beautifully unclean solution. Make your
/etc/udev/rules.d/70-persistent-net.rules
a directory :)