Good morning, everyone.
I am posting here the discussion I started on the Debian forum:
First of all, the operating system in use is a Diet-pi 9.13 64bit.
I am having difficulty understanding how to associate the three physical Ethernet interfaces, named LAN 1, LAN2 and LAN3, on a mini-PC with the standard names used in Linux, eth0, eth1 and eth2.
After performing clean installation a couple of times, I noticed that the operating system always associates eth0 with LAN2. Subsequently, if I edit the etc/network/interfaces file by entering
auto eth0 eth1 eth2
allow-hotplug eth0
allow-hotplug eth1
allow-hotplug eth2
I find that eth1 is associated with LAN3 and eth2 with LAN1.
How does the operating system associate the physical interface with the name eth*?
Is there a way to associate eth0 with Physical LAN1, eth1 with LAN2, and eth2 with LAN3?
I would like to understand how to manage this association, also because the next step would be to clone the system on two other identical mini-PCs and not find the Ethernet interfaces associated randomly.
Not really a DietPi issue, more related to the kernel which we don’t maintain for x86. On Debian (and most Linux distros using udev and systemd), the kernel no longer guarantees that a given physical NIC always gets the same classic name like eth0, eth1, etc. Normally, the first adapter which comes online during boot is assigned eth0, the second one eth1, and so on. That’s why you may see your NICs not in order you expect. AS well names can swap on reboot or after hardware changes.
To ensure one physical LAN port always has the same name (e.g., eth0), you can try to set an udev persistent naming rule.
First, list your network interfaces with MAC addresses:
ip link show
You’ll see something like:
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 00:11:22:33:44:66 brd ff:ff:ff:ff:ff:ff
4: eth2: ...