===== Set persistent MAC for RTL8111/8168/8411 (r8169) with udev =====
This tutorial does only work on systems that use ''**udev**'', like IPFire!
The Linux kernel mod ''r8169'' seems to set random MAC addresses for Realtek's ethernet cards 8111/8168/8411 every time this devices gets booted. This behaviour also seems to be intended like described in [[https://bugzilla.kernel.org/show_bug.cgi?id=215087|this]] kernel patch.
You can verify this by checking your (boot-) log, if it contains ''can't read MAC address, setting random one'' on the device that uses the mod ''r8169'', you may be affected.
But it may break your system like when using IPFire that recognizes it's NICs from their MAC address.
==== Get PCI device information ====
Use the following command and determine your NIC and it's PCI address: (''pciutils'' is required)
lspci -v
The output may look like this:
{{:linux:linux-tutorials:persistent_mac_rtl8111_lspci.png?900|}}
Now take note of it's address, in this case ''04:00.0''.
==== Create udev rules ====
Then add a ''udev''-rule for this NIC. Therefore create a new rule:
nano /etc/udev/rules.d/10-network-persistent-custom-mac-address.rules
And add the following content:
SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:", PROGRAM="/sbin/ip link set %k address "
Replace ''pci-address'' with the NICs PCI address that you got from the step before (e.g. ''0000:01:00.0'') and ''your-persistent-mac'' with the MAC address that should always be assigned to this NIC. (both without ''<'' and ''>'').
Finally save the file and reboot.
----
//Resources used: [[https://serverfault.com/questions/813995/change-interface-mac-hw-address-using-udev-rules|serverfault.com - Change interface MAC HW address]], [[https://packetpushers.net/udev/|packetpushers.net - udev]]//