:: [DNG] if2mac init.d service for per…
Pàgina inicial
Delete this message
Reply to this message
Autor: tito
Data:  
A: dng
Assumpte: [DNG] if2mac init.d service for persistent network interface names
Hi,
a few days ago I was able to complete may new router
with 12 nics and 1 wifi. I moved the devuan drive from
my previous defunct box to the new one and experienced
all the problems reported in the "Ethernet names revisited"
thread.
I tried all the wise advice of the thread included my own
just to discover that nothing really works reliably.

Things I've tried in various combinations:

1) 70-persistent-net.rules with mac
2) 70-persistent-net.rules with pci bus numbers
3) 60-persistent-net.rules with mac
4) 60-persistent-net.rules with pci bus numbers
5) net.ifnames=0 / net.ifnames=1 in grub
6) biosdevname=0 in grub
7) renaming the interfaces in /etc/network/interfaces
8) using ifrename

Always the 12 nics came up with different names,
or some of them were missing due to collisions
during the rename process and the router was
borked with me yelling.
Especially sarcastic I've found the definition of
the new "predictable names" because there is
nothing really predictable about them and at every
reboot they can be totally different, one time being
enp5s0 and next time enp8s0f1 depending on
the BIOS initialization process ( I suppose....).
At the end I started thinking about a KISS way to get
my persistent interface names back without
using udev/eudev or other non cooperative software.
I've come up with a init script that I've called
if2mac that matches interfaces to mac addresses
early in the boot process before networking is set up,
that for me works reliably (after a night of reboots).
I post it here so that If some bold beta testers on the list
are interested they can try it out in the hope that
it works for them (and AT THEIR OWN RISK!!!).
To use it copy the script to /etc/init.d/:

cp if2mac /etc/init.d/
chmod +x /etc/init.d/if2mac
insserv if2mac

and the configuration file to /etc/if2mac.conf.

## Sample configuration file for if2mac.
##
## WIRED_MAC_LIST and WIRELESS_MAC_LIST contain a list of MAC
## addresses in the desired order top to down starting at
## position 0. For example:
## WIRED_MAC_LIST="\
## 00:11:22:33:44:54 \ <= The space is needed!!!
## 00:11:22:33:44:55 \
## 00:11:22:33:44:56"
## The WIRED_PREFIX and WIRELESS_PREFIX variables can be changed
## at your liking (opt, port, whatever).

WIRED_PREFIX="eth"

WIRED_MAC_LIST="\
00:12:21:c4:56:68 \
00:12:21:c4:56:69 \
00:13:21:c4:56:6a \
00:13:21:c4:56:6b \
00:33:18:04:a3:46 \
00:34:18:04:a3:47 \
00:35:18:04:a3:48 \
00:36:18:04:a3:49 \
00:36:18:04:a3:4a \
00:36:18:04:a3:4b \
00:36:18:04:a3:4c \
00:56:18:04:a3:4d"

WIRELESS_PREFIX="wlan"

WIRELESS_MAC_LIST="\
54:2a:a2:2b:b3:55"

Attached you will find the init script and a sample
configuration file. Multiple configuration files
to allow more prefixes are not supported because
this kind of renaming could be done in /etc/network/interfaces
once the interfaces came up with predictable and persistent names.
At this time only

en      Ethernet wired
et     Ethernet wired old
wl     Wireless local area network (WLAN)


interfaces are supported with both old style
and new "predictable" names.

Prerequisites are:
/bin/cat
/sbin/ip
and a mounted /sysfs.

Hints improvements and critics are welcome.
Eventually if there is some interest this could be packaged
(with the help of some devuan packaging gurus).

Hope this helps. Enjoy.
Ciao,
farmatito