Hello,
after diving deeper into the naming of network interfaces, I finally found a solution.
TL;DR:Copy the systemd's default network link configuration file into /etc
$this->bbcode_second_pass_code('', 'cp /usr/lib/systemd/network/99-default.link /etc/systemd/network/99-default.link')
Change the name policy list from
$this->bbcode_second_pass_code('', 'NamePolicy=keep kernel database onboard slot path')
to
$this->bbcode_second_pass_code('', 'NamePolicy=keep kernel database onboard slot path mac')
Afterwards, the RaspberryPi's network interfaces will be named according to their internal MAC addresses, i.e.
enx########### or
wlx############ where ############ being the MAC address (hex) without any separators.
Possible drawbacks(*):
1) Interface names are long and hard to remember.
2) Any hardware changes (e.g. migrate to other RaspberryPi or change external interfaces), interface names will change, too. Take care of your scripts.
Now a more detailed explanation:First of all, predictable interface names are not disabled for RaspberryPi but have kind of limited support.
By default, udev assigns names to each interface according to the rules in
/lib/udev/rules.d/80-net-setup-link.rulesand the value of the variable
$env{ID_NET_NAME}That variable is part of systemd's builtin "net_setup_link" for network link configuration (
https://www.freedesktop.org/software/systemd/man/systemd.link.html) which is triggered/called by the udev rule to fill the variable accordingly.
The builtin parses configuration files within
/usr/lib/systemd/network/* , in particular defaults from
/usr/lib/systemd/network/99-default.linkIt includes a (space-separated) list of naming policies that shall be tried out sequentially to generate an interface name and set the varibale
ID_NET_NAME (which is used by the udev rule afterwards).
The default policy list is "
NamePolicy=keep kernel database onboard slot path"; the meaning of the values is described in the URL above.
This list is processed sequentially until an entry delivers a valid value.
However, the policies "
slot" and "
path" which are mostly responsible for the predictable interface names (e.g. enp3s0) on common PCs, don't work with RaspberryPi. (Maybe because that platform has no PCI bus, and the typical names are derived from PCI slots - but this is only an assumption, I haven't verified that)
In fact, generally, all of the listed policies fail on RaspberryPi and the name falls back to the "classic" unpredictable interface name like "eth0".
The default settings can be overridden by masking the default
99-default.link file with a customized file of the same name in
/etc/systemd/network/By appending the policy list with the "
mac" policy as described above, systemd additionally tries to provide an interface name according to the internal MAC address (if available).
This works on all my RaspberryPi 3B and 3B+ with both, the builtin interfaces and several external USB network interfaces.(*) Finally, it may be desired to overcome the two listed drawbacks for some explicit interfaces, e.g. naming the embedded Wifi interface "wifi" on any Pi (of the same model). The remaining interfaces will be named as specified before.
To achieve this for a RaspberryPi 3B+, add a new udev rule, e.g. in a new file
/etc/udev/rules.d/10-net-embedded.rules with the following content:
$this->bbcode_second_pass_code('', 'SUBSYSTEM=="net", DEVPATH=="/devices/platform/soc/3f300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1/net/*", NAME="wifi"')
See
https://wiki.archlinux.org/index.php/Network_configuration#Change_interface_name for more details about this explicit assignment.
Best Regards
RF