修改配置文件 70-persistent-net.rules,该文件存在路径 /etc/udev/rules.d/ 下。
我是在虚拟机上装的Ubuntu系统,该文件内容如下:
# This file maintains persistent names for network interfaces.
# See udev(7) for syntax.
#
# Entries are automatically added by the 75-persistent-net-generator.rules
# file; however you are also free to add your own entries.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:9c:ad:4e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:26:b3:95", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:34:9f:6f", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# USB device 0x0bda:0x8187 (usb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:18:00:00:8f:59", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
此时只要修改一下该文件中对应网卡的 NAME 值,即可修改网卡名称。
或者通过修改虚拟机网卡Mac地址,改为对应值,即可修改网卡名称,如下
两种方法均可修改网卡名称,注意修改后要重启网络服务:
/etc/init.d/networking restart
CentOS 7将网卡名称eno16777736改为eth0:http://www.linuxdiyf.com/linux/14344.html
centos6.x修改网卡名称em1、2...为eth0、1...:http://www.linuxdiyf.com/linux/13843.html