0

Thanks for reading

I had a long question but think I tracked it down correctly. Figured I would post It here anyway for confirmation and to help anyone else looking for this The original shortened question:

I have 2 Pi’s (4) that I am going to use in a test setup. In addition to the on board ethernet connection I have added two USB gigabit ethernet adapters to each Pi. The plan: eth0 on each are connected together, one will be headless and this is my connection to it. Eth1 and eth2 on both are setup as network A(eth1) and B(eth2).

I don't understand how the OS selected the dongles for eth1 and eth2 and I wanted to lock it down so that after any reboot it never changes. I found this on the Ubuntu form, gave it a go, and seems to work

https://askubuntu.com/questions/689501/how-to-rename-network-interface-in-15-10

Summary: Create a file /etc/udev/rules.d/10-rename-network.rules with the content:

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ff:ff:ff:ff:ff", NAME="eth1"

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ff:ff:ff:ff:ff", NAME="eth2"

Where ff:ff:ff:ff:ff:ff is the dongle MAC address

save and reboot - seems to work

I still would like to know where in the OS the dongle to eth assignment was originally set if it’s an easy response for anyone Thanks

2
  • So you don't have a problem but are wondering if you implemented it the right way?
    – user96931
    Commented Apr 30, 2020 at 22:45
  • "I still would like to know where in the OS the dongle to eth assignment was originally set" See man systemd.link
    – goldilocks
    Commented Feb 28 at 21:17

2 Answers 2

1

The simple answer is you can't, because the order devices are enumerated is unpredictable. The allocation is just on a first come/first served basis. There is NO place it is set. Other platforms have rules based on BIOS provided index numbers or PCI card slot numbers, but this in not applicable to the Pi (or USB dongles in general)

The hard answer is to write udev rules - if you want to do this you will find lots of cryptic documentation.

The easy answer is to enable Predictable Network Interface Names as described in How to set up networking/WiFi This is what MOST Linux/UNIX systems use, but the Foundation has disabled it by default.

1
  • "The simple answer is you can't" -> This is false, see man systemd.link.
    – goldilocks
    Commented Feb 28 at 21:18
0

Somewhat simpler than writing the udev rule yourself is to let systemd do it. As per man systemd.link, create a file in /etc/systemd/network named, eg. "10-usbeth.link". Not sure if the suffix is important, but the "10-" prefix is since files of this sort are collected from various places and sorted together by name, those higher in the list take precedence.

All you need in it is:

[Match]
MACAddress=ff:ff:ff:ff  # Use the actual MAC shown as "link/ether" in `ip link` output.

[Link]
Description=USB ethernet adapter
Name=usbeth42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.