linux中修改网卡设备名称

Table of Contents

如果测试机器或服务器上有多个网卡,可能由于不同网卡的特性不同而需要启用/禁用网卡控制器,调整的过程可能需要调整网卡的名称,如eth1改成eth0,自己调整了两三次,把经验分享一下:

1.shutdown 相应接口,将
/etc/sysconfig/network-scripts/ifcfg-eth0中的
DEVICE=eth0
HWADDR=00:1e:ec:0f:79:f6
修改或添加,注意mac地址和device名称要和对应的配置文件名称中的eth0对应。
并将下面文件中修改成和上述一致
/etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x14e4:0x1713 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1e:ec:0f:79:f6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x14e4:0x1713 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1e:ec:0f:79:f7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

2. service udev-post stop; service udev-post start

3. ifup eth0/eth1