centos7 MAC地址和网卡地址名称绑定

 

 

 

网卡信息

 1 [root@localhost ~]# ifconfig 
 2 ens10: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
 3         inet6 fe80::e187:ded2:a0f5:171  prefixlen 64  scopeid 0x20<link>
 4         ether 52:54:00:82:54:70  txqueuelen 1000  (Ethernet)
 5         RX packets 0  bytes 0 (0.0 B)
 6         RX errors 0  dropped 0  overruns 0  frame 0
 7         TX packets 12  bytes 1992 (1.9 KiB)
 8         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 9 
10 ens11: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
11         inet6 fe80::5805:640f:54fd:29e3  prefixlen 64  scopeid 0x20<link>
12         ether 52:54:00:61:cd:56  txqueuelen 1000  (Ethernet)
13         RX packets 0  bytes 0 (0.0 B)
14         RX errors 0  dropped 0  overruns 0  frame 0
15         TX packets 12  bytes 1992 (1.9 KiB)
16         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
17 
18 ens12: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
19         inet6 fe80::b1c2:80e0:6fbe:7e1a  prefixlen 64  scopeid 0x20<link>
20         ether 52:54:00:b0:be:eb  txqueuelen 1000  (Ethernet)
21         RX packets 0  bytes 0 (0.0 B)
22         RX errors 0  dropped 0  overruns 0  frame 0
23         TX packets 13  bytes 2334 (2.2 KiB)
24         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
25 
26 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
27         inet 172.31.134.111  netmask 255.255.255.0  broadcast 172.31.134.255
28         inet6 fe80::d15e:8bad:26de:9f37  prefixlen 64  scopeid 0x20<link>
29         inet6 fe80::75a3:131c:422d:3f17  prefixlen 64  scopeid 0x20<link>
30         inet6 fe80::272:d886:b039:554d  prefixlen 64  scopeid 0x20<link>
31         ether 52:54:00:6d:ee:f5  txqueuelen 1000  (Ethernet)
32         RX packets 796  bytes 80233 (78.3 KiB)
33         RX errors 0  dropped 28  overruns 0  frame 0
34         TX packets 179  bytes 22938 (22.4 KiB)
35         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
36 
37 lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
38         inet 127.0.0.1  netmask 255.0.0.0
39         inet6 ::1  prefixlen 128  scopeid 0x10<host>
40         loop  txqueuelen 1000  (Local Loopback)
41         RX packets 0  bytes 0 (0.0 B)
42         RX errors 0  dropped 0  overruns 0  frame 0
43         TX packets 0  bytes 0 (0.0 B)
44         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
45 
46 [root@localhost ~]# 

 

修改70-persistent-net.rules 文件,然后重启程序,即可实现MAC地址和网卡名称的对应。 

 1 [root@localhost rules.d]# pwd 
 2 /etc/udev/rules.d
 3 [root@localhost rules.d]# cat 70-persistent-net.rules 
 4 
 5 SUBSYSTEM=="net",
 6 ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:6d:ee:f5",
 7 ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
 8 ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:82:54:70",
 9 ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="ens10"
10 ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:61:cd:56",
11 ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="ens11"
12 ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:b0:be:eb",
13 ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="ens12"
14 [root@localhost rules.d]# 

 

 

posted @ 2019-11-27 15:20  凌空a  阅读(2980)  评论(0编辑  收藏  举报