方法二:修改rules文件
1、文件没有的话可以手动创建,后缀是.rules,按照顺序将MAC地址与网卡名称绑定
cat /etc/udev/rules.d/70-persistent-ipoib.rules
# This is a sample udev rules file that demonstrates how to get udev to
# set the name of IPoIB interfaces to whatever you wish. There is a
# 16 character limit on network device names though, so don't go too nuts
#
# Important items to note: ATTR{type}=="32" is IPoIB interfaces, and the
# ATTR{address} match must start with ?* and only reference the last 8
# bytes of the address or else the address might not match on any given
# start of the IPoIB stack
#
# Note: as of rhel7, udev is case sensitive on the address field match
# and all addresses need to be in lower case.
#
# ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="?*00:02:c9:03:00:31:78:f2", NAME="mlx4_ib3"
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="?*00:0c:29:7a:1e:16", NAME="eth0" 2、修改网卡配置文件,配置DEVICE和NAME,并加入HWADDR
注:DEVICE、NAME和HWADDR 要和.rules 里面相对应
cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
NAME=eth0
#UUID=408326bb-7565-4aa5-b156-c89a0ba839d2
HWADDR=00:0c:29:7a:1e:16
DEVICE=eth0
ONBOOT=yes
IPADDR=172.16.18.188
NETMASK=255.255.255.0
GATEWAY=172.16.18.1
DNS=219.141.136.10 3、reboot