2

I am currently trying to configure two Raspberry Pi 3s. The first one works fine. However, the other one always renames eth0 to eth1 on boot.

dmesg | grep eth

[2.485760] smsc95xx 1-1-.1:1-0 eth0: register 'smsc95xx' at usb-3f980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:56:b6:06
[4.742863] smsc95xx 1-1.1:1.0 eth1: renamed from eth0
[4.794234] systemd-udevd[151]: renamed network interface eth0 to eth1

Both Raspberrys have the same image on their SD card with minimum non-OS modifications in custom scripts (datalogging from sensors). Both SD cards' OS instances get their correct IPs (assigned by MAC) from the DHCP server when using the first Pi. Neither get any address when installed in the other Pi. Both Pis are new and from the same seller.

Changing eth0 to eth1 in /etc/network/interfaces works around the problem, but it took me hours to find out because I didn't expect the LAN port to NOT work out of the box. Something hardware-related seems to cause unnormal behaviour even though both Pis are the same generation.

Why does the hardware have such an effect on the OS and how can I fix it?

Domme
  • 375
  • 2
  • 11

4 Answers4

2

You can create systemd.link file like /etc/systemd/network/25-eth0.link

Universal file for Raspbery Pi 3B (probably on other revisions it will be the same or similar) it can be like this:

[Match]
Driver=smsc95xx
Path=platform-3f980000.usb-usb-0:1.1:1.0
#MACAddress=b8:27:eb:??:??:??

[Link]
Description=Raspberry Pi embedded SMSC9512/9514 Fast Ethernet Adapter
Name=eth0

To check Driver and Path options for specific device (eth0 here) you can use udevadm info -q all /sys/class/net/eth0 (add -a to see all ancestors).

Instead of Driver and Path directives you can use MACAddress value, but it will be unique for all devices.

For other devices (like wlan0) you can create similar .link file. Wireless devices usually has Type=wlan (udev DEVTYPE entry):

[Match]
Type=wlan
Driver=brcmfmac
Path=platform-3f300000.mmc
#MACAddress=b8:27:eb:??:??:??

[Link]
Description=Raspberry Pi embedded Wireless Adapter
Name=wlan0

For more info see man systemd.link.

Mikhail
  • 21
  • 2
1

It sounds like the next version of Raspbian/Debian may be moving to "predictable network interface names" -- which will throw a lot of people for a loop, but should prevent problems like this. Maybe. Anyway, as mentioned there traditionally 'udev shipped support for assigning permanent "ethX" names to certain interfaces based on their MAC addresses' which you would think would be consistent on the Pi (the OEM prefix is the always the same as far as I've noticed), except obviously there is some glitch here, probably with it considering the slot as occupied already.

The way this currently seems to be achieved is via a script, /lib/udev/write_net_rules. While there's probably a better way (you could research this yourself), a hacky sort of solution would be to just disable the rule that invokes that; this is in /lib/udev/rules.d/75-persistent-net-generator.rules.

I notice there's a /lib/udev/rules.d/75-persistent-net-generator.rules.distrib; I believe adding that suffix disables that so perhaps this is something Raspbian has done. The only difference is the removal of excluding of eth*, wlan* and some other things (go figure). You might want to check if both those files are actually there.

As for the hacky solution, just move both files or add a suffix like .disabled. This may be prone to getting replaced by system updates, so the "better solution" would be to write your own rule to override this one and put it in /etc/udev/rules.d -- but I don't know how it should go in this case.

I can't promise the hacky solution won't cause you some form of grief but it is easy to undo (as long as you don't delete those files) and probably won't, as all this shouldn't matter on a Pi where there are likely only a couple of interfaces and they might as well keep the name the kernel gives them.

goldilocks
  • 60,325
  • 17
  • 117
  • 234
0

Install one of the standard supported Foundation images and DO NOT run rpi-update.

Milliways
  • 62,573
  • 32
  • 113
  • 225
0

Did you duplicate the sd card from one to the other--after it had been booted and used in the first?

I found that you can edit: /etc/udev/rules.d/70-persistent-net.rules which is where PredictableNetworkInterfaceNames seem to be stored. It had eth0 and an eth1 in there after moving a micro sd card to a new system. I removed all the eth0/1 and wlan0/1 entries, and it then went back to 'normal' after rebooting.