1

On my raspberry pi I am plugging a USB to ethernet adapter which is automatically assigned to eth1 but I would prefer having it be eth2.

I tried to add a dummy interface by doing ip link add eth1 type dummy. If I do this by hand and plug my adapter after it works.

I wanted to do that on boot so I added dummy in /etc/modules and I tried adding ip link add eth1 type dummy in rc.local (it didn't work).

I tried doing it as indicated here which didn't work either.

1

2 Answers 2

3

You want to name the wired interface to eth2. That is very easy with systemd-networkd using the MAC address. Just create this file and reboot:

rpi ~$ cat /etc/systemd/network/02-eth.link
[Match]
# example, use your MAC address
MACAddress=dc:a6:32:7f:38:46

[Link]
Name=eth2
2
  • I thought in raspberry pi 4 (and therefore raspbian stretch) networkd should not be used. Did I misunderstood something ?
    – f222
    Commented Dec 17, 2020 at 8:35
  • @f222 There is nothing said about stretch.You use a Raspberry Pi 4B. That is only supported by Buster (and later versions when available). But anyway, systemd is the main init system since Jessie, the predecessor of Stretch, and should be used instead of the deprecated and only emulated SysV init system. Renaming the interface this way, the systemd-networkd.service is not needed and must not run. Default dhcpcd networking is not affected.
    – Ingo
    Commented Dec 17, 2020 at 10:29
1

I found a way of doing it without using a dummy interface.

First I used raspi-config to enable predictable network names.

Then I created a file named /etc/udev/rules.d/10-network-device.rules. In this file I put a line like SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="mac_addr", NAME="interface_name" for each ethernet interface I have.

This post made me find my answer.

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