Show Table of Contents
8.10. 网络设备命名故障排除
如果可能,会根据 第 8.2 节 “了解设备重命名过程” 所述过程为每个接口分配一个可预期的接口名称。要查看 udev 可能使用的名称列表,请作为
root 运行以下命令:
~]# udevadm info /sys/class/net/ifname | grep ID_NET_NAME
其中 ifname 是用以下命令中列出的接口之一:
~]$ ls /sys/class/net/
udev 会根据 第 8.2 节 “了解设备重命名过程” 所述规则应用可能的名称之一,并总结如下:
/usr/lib/udev/rules.d/60-net.rules- 来自 initscripts,/usr/lib/udev/rules.d/71-biosdevname.rules- 来自 biosdevname,/usr/lib/udev/rules.d/80-net-name-slot.rules- 来自systemd
从以上规则文件列表中可以看出,如果使用 iniscripts 或 biosdevname 完成接口命名,它总是优先于 udev 原始命名。但如果没有使用 iniscripts 命名,同时禁用了 biosdevname,那么要更改接口名称,就需要将
/usr/ 中的 80-net-name-slot.rules 复制到 /etc/,并相应编辑该文件。换句话说,根据具体顺序注释出或安排要使用的方案。
例 8.1. 有些接口使用来自内核名称空间的名称(eth[0,1,2...]),同时可使用 udev 重命名其他名称。
混合方案大多是因为内核无法向 udev 提供某些硬件的可用信息,因此无法确定为 udev 提供的名称或信息是否合适,比如非唯一设备 ID。后者更常见,通常可使用 ifcfg 文件中的秘密方案,或编辑 80-net-name-slot.rules 更改使用的 udev 方案解决这个问题。
例 8.2. 在 /var/log/messages 或 systemd 日志中可以看到为每个设备重新命名两次。
使用 ifcfg 内置命名方案,但未重新创建
initrd 映像的系统通常会遇到这个问题。最初,在引导初期且仍处于 initrd 中时分配该接口名称(使用 biosdevname 或 udev)。当切换到真实 rootfs 后,会第二次重新命名,并由 udev 衍生的 /usr/lib/udev/rename_device 二进制文件决定新接口名称,因为使用的是 60-net.rules。可忽略此类信息。
例 8.3. 在附带 ethX 名称的 ifcfg 文件中使用命名方案不可行
不建议使用来自内核名称空间的接口名称。要获得可预期且稳定的接口名称,请使用 "eth" 以外的其他前缀。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.