systemd 和 udev 引入了一种新的网络设备命名方式:一致网络设备命名(CONSISTENT NETWORK DEVICE NAMING)。根据固件、拓扑、位置信息来设置固定名字,带来的好处是命名自动化,名字完全可预测,在硬件坏了以后更换也不会影响设备的命名,这样可以让硬件的更换无缝化。带来的不利是新的设备名称比传统的名称难以阅读,比如心得名称是enp5s0。
默认情况下,systemd会按照以下规则为网卡命名:
- 规则1:将依据Firmware或BIOS提供的设备索引编号为网卡命名。(比如eno1)如果这两个值不可用或不适用则使用规则2。
- 规则2:将依据Firmware或Bios的PCI-E热插拔slot索引编号为网卡命名。(比如ens1)如果这两个值不可用或不适用则使用规则3。
- 规则3:将依据硬件连接器的物理位置进行命名。(比如enp2s0)如果适用则应用,否则则采用规则5。
- 规则4:将根据网卡接口的MAC地址进行命名,(比如enx78e7d1ea46da)默认将不采用该方式,但用户可配置启用该方式。
- 规则5:其他方法都失败的情况下,最后采用传统的(不可预测编号)内核命名方式。(比如eth0)
- 上面的所有命名规则依赖于biosdevname,改程序默认启用。
The names have two-character prefixes based on the type of interface:
-
en
for Ethernet, -
wl
for wireless LAN (WLAN), -
ww
for wireless wide area network (WWAN).
The names have the following types:
- o<index>
- on-board device index number s<slot>[f<function>][d<dev_id>]
- hotplug slot index number. All multi-function PCI devices will carry the
[f<function>]
number in the device name, including the function0
device. x<MAC> - MAC address [P<domain>]p<bus>s<slot>[f<function>][d<dev_id>]
- PCI geographical location. In PCI geographical location, the
[P<domain>]
number is only mentioned if the value is not0
. For example:ID_NET_NAME_PATH=P1enp5s0
[P<domain>]p<bus>s<slot>[f<function>][u<port>][..][c<config>][i<interface>] - USB port number chain. For USB devices, the full chain of port numbers of hubs is composed. If the name gets longer than the maximum number of 15 characters, the name is not exported. If there are multiple USB devices in the chain, the default values for USB configuration descriptors
(c1)
and USB interface descriptors(i0)
are suppressed.