Skip to the content.

0.环境准备

[root@c02 ~]# uname -a
Linux c02 2.6.32-696.10.3.el6.x86_64 #1 SMP Tue Sep 26 18:14:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@c02 ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)

有时候进行虚拟机克隆的时候,会保留被克隆虚拟机的网卡,克隆后的网卡会排在后面,如eth1,eth2等,看着很不爽。

1.修改网卡名

# 修改配置文件,注意对应mac地址
[root@c02 ~]# vi /etc/udev/rules.d/70-persistent-net.rules
[root@c02 ~]# cat /etc/udev/rules.d/70-persistent-net.rules |grep eth0
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", 
ATTR{address}=="08:00:27:a6:84:fa", ATTR{type}=="1", 
KERNEL=="eth*", NAME="eth0"

# 重启网络服务或重启设备

[root@c02 ~]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:
Determining IP information for eth0... done.               [  OK  ]
或者:
[root@c02 ~]# init 6