How to rename eth0 ... etc

Thanks for the quick reply,

I doubt that the suggested solution would have helped in my case. The script (/usr/bin/toradex-net-rename.sh) that is called within the rule only handles 2 ‘real’ network adapters (not connected via USB)

But I found an answer myself:

I’ve worked through these instructions: systemd.link

The USB path can be found under ID_PATH if you call up, for example:
udevadm info /sys/class/net/eth0

An example .link file could look like this:

[Match]
Path=platform-ci_hdrc.1-usb-0:1.3.1:1.0

[Link]
Name=eth_as_i_need_it0

thanks, nevertheless,

I would still like to know where the names eth0 … ethX are assigned.
From the kernel logs you can see:

[    1.354298] fec 5b040000.ethernet: Adding to iommu group 0
[    1.640023] fec 5b040000.ethernet eth0: registered PHC device 0
[    6.641020] fec 5b040000.ethernet ethernet0: renamed from eth0

later:

[    7.882255] SMSC LAN8710/LAN8720 usb-004:004:01: attached PHY driver (mii_bus:phy_addr=usb-004:004:01, irq=POLL)
[    7.901797] smsc95xx 4-1.3.1:1.0 eth0: register 'smsc95xx' at usb-ci_hdrc.1-1.3.1, smsc95xx USB 2.0 Ethernet, 8e:ef:41:01:67:bd

[    8.071378] SMSC LAN8710/LAN8720 usb-004:005:01: attached PHY driver (mii_bus:phy_addr=usb-004:005:01, irq=POLL)
[    8.072561] smsc95xx 4-1.3.2:1.0 eth1: register 'smsc95xx' at usb-ci_hdrc.1-1.3.2, smsc95xx USB 2.0 Ethernet, 82:03:ad:93:08:9c

[    8.252628] SMSC LAN8710/LAN8720 usb-004:006:01: attached PHY driver (mii_bus:phy_addr=usb-004:006:01, irq=POLL)
[    8.253444] smsc95xx 4-1.3.3:1.0 eth2: register 'smsc95xx' at usb-ci_hdrc.1-1.3.3, smsc95xx USB 2.0 Ethernet, c2:cf:69:7f:96:d7

I would assume that when the KSZ9031 network adapter appears, a driver assigns a name like eth#, the udev rule renames it to ethernet0 (???) and then the recognition of the USB Ethernet adapter starts. The driver then starts naming again from 0.

It would be nice to know exactly.

Best Regards
Gerald