With
systemd 197we have added native support for a number of different naming policies intosystemd/udevdproper and made a scheme similar tobiosdevname's (but generally more powerful, and closer to kernel-internal device identification schemes) the default. The following different naming schemes for network interfaces are now supported byudevnatively:
- Names incorporating Firmware/BIOS provided index numbers for on-board devices (example:
eno1)- Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example:
ens1)- Names incorporating physical/geographical location of the connector of the hardware (example:
enp2s0)- Names incorporating the interfaces's MAC address (example:
enx78e7d1ea46da)- Classic, unpredictable kernel-native ethX naming (example:
eth0)
source: PredictableNetworkInterfaceNames
# less /lib/systemd/network/99-default.link# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Link]
NamePolicy=kernel database onboard slot path
MACAddressPolicy=persistentYou SHOULD NOT modify this file, it COULD be regularly reverted by packages updates.
# /etc/systemd/network/99-default.link
[Match]
OriginalName=*
[Link]
NamePolicy=mac path
MACAddressPolicy=none
NamePolicy=An ordered, space-separated list of policies by which the interface name should be set.NamePolicy=may be disabled by specifyingnet.ifnames=0on the kernel command line. Each of the policies may fail, and the first successful one is used. The name is not set directly, but is exported toudevas the propertyID_NET_NAME, which is, by default, used by audev(7), rule to setNAME. The policies used above are:
pathThe name is set based on the device's physical location, as exported by theudevpropertyID_NET_NAME_PATH.macThe name is set based on the device's persistent MAC address, as exported by theudevpropertyID_NET_NAME_MAC.
source: systemd.link — Network device configuration
GRUB_CMDLINE_LINUX="net.ifnames=1"# sudo update-grub
# sudo update-initramfs -u
# sudo reboot# ls /sys/class/net/(cd /sys/class/net && find * -maxdepth 1) | grep -Ev '^lo$' | \
head -1 | \
perl -pe "s/\n//" | \
xargs -r0I {} sudo udevadm test /sys/class/net/{} 2> /dev/null | grep NAMESample output:
ID_NET_NAME_MAC=enx9c5c8e538309
ID_NET_NAME_ONBOARD=eno1
ID_NET_NAME_PATH=enp0s25