Show Table of Contents
8.9. 禁用一致网络设备命名
请选择以下方法之一禁用一致网络设备命名:
- 通过屏蔽默认策略中的 udev 规则文件,禁止分配固定名称,以便重新使用不可预期的内核名称。可为
/dev/null生成一个符号链接完成“屏蔽”。请作为root用户运行以下命令:~]#
ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules - 创建自己的手动命名方案。例如:将接口命名为 “internet0”、“dmz0” 或 “lan0”。要创建自己的 udev 规则文件,并为那些设备设置 NAME 属性。确定在使用默认策略文件前使用该文件。例如:将其命名为
/etc/udev/rules.d/70-my-net-names.rules。 - 修改策略文件,使其选择不同的命名方案后。例如:默认根据接口的 MAC 地址命名所有接口。作为
root复制默认策略文件,如下:~]#
在cp /usr/lib/udev/rules.d/80-net-name-slot.rules /etc/udev/rules.d/80-net-name-slot.rules/etc/udev/rules.d/目录中编辑文件,并根据需要修改。 - 在 GRUB 2 菜单的内核命令行中添加以下指令:
net.ifnames=0
更新所有 GRUB 2 内核菜单条目,作为root用户输入以下命令:~]#
有关使用 GRUB 2 的详情请查看《Red Hat Enterprise Linux 7 系统管理员指南》。grubby --update-kernel=ALL --args=net.ifnames=0

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.