[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to avoid systemd/udev unpredictable NIC names



On Mon, Aug 30, 2021 at 10:20:46PM +0200, Steve Keller wrote:
> I plan to upgrade a server from	Debian stretch to buster.  Having read
> the release notes I wonder what's the best way to avoid the new scheme
> of unpredictable network interface names.

You say "server", so I'm guessing it has more than one NIC.  That means
the old way (net.ifnames=0) is not viable.

Your best strategy is to create systemd.link(5) files, and give the NICs
the names you want them to have, based on their MAC addresses.

For example:

unicorn:~$ cat /etc/systemd/network/10-lan0.link 
[Match]
MACAddress=18:60:24:77:5c:ec

[Link]
Name=lan0
unicorn:~$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: lan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 18:60:24:77:5c:ec brd ff:ff:ff:ff:ff:ff

This is also viable on a single-NIC machine (like mine), but in that
case net.ifnames=0 would also suffice.


Reply to: