Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:linux-tutorials:set-persistent-mac-rtl8111 [2023/12/19 08:09] Zyzonixlinux:linux-tutorials:set-persistent-mac-rtl8111 [2024/04/23 11:45] (current) – [Create udev rules] Zyzonix
Line 2: Line 2:
  
 <callout type="warning" icon="true">This tutorial does only work on systems that use ''**udev**'', like IPFire!</callout> <callout type="warning" icon="true">This tutorial does only work on systems that use ''**udev**'', like IPFire!</callout>
 +
 +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)
 +<code bash>lspci -v</code>
 +
 +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:
 +<code bash>
 +nano /etc/udev/rules.d/10-network-persistent-custom-mac-address.rules
 +</code>
 +
 +And add the following content:
 +<code bash>
 +SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:<pci-address>", PROGRAM="/sbin/ip link set %k address <your-persistent-mac>"
 +</code>
 +
 +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]]//
  • linux/linux-tutorials/set-persistent-mac-rtl8111.1702969785.txt.gz
  • Last modified: 2023/12/19 08:09
  • by Zyzonix