本文将介绍如何修改网卡名称。
TODO 如何在Linux中修改网卡的名称
可以使用命令ip link直接修改网络接口名:
# 关闭网卡 ip link set dev peth0 down ifconfig peth0 down # 修改网卡名 ip link set peth0 name eth0 # 启动网卡 ip link set dev eth0 up ifconfig eth0 up系统环境:Debian
修改/etc/udev/rules.d/73-special-net-names.rules文件,加入如下配置:
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="<MAC Address>", NAME="<New Interface Name>"
参数说明:ATTR{address}=="<MAC Address>"中的<MAC Address>为MAC地址,根据自己的网卡进行修改;NAME="<New Interface Name>"中的<New Interface Name>为要使用的新命名; 如果73-special-net-names.rules文件不存在,创建即可,或者写入其他配置文件也可以;
在Debian中,可以修改/etc/default/grub文件中的GRUB_CMDLINE_LINUX_DEFAULT参数,加入net.ifnames=1配置,然后执行update-grub2命令,重启系统。
注意:如果修改修改了网卡接口名,不要忘记更新相关的配置文件。
K4NZ / 修改网卡接口名Change Network Interface Name: eth0,eth1,eth2+Arch/Network ConfigurationRename a Linux network interface without Udev/RebootNetwork naming on Arch LinuxHow to enable “Predictable Network Interface Names”?