文章目录
第一步:确定网卡硬件的magic值
[root@Zabbix-yuanzhan ~]# ip a
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether f0:4d:a2:73:9a:9a brd ff:ff:ff:ff:ff:ff
inet 156.236.93.10/25 brd 156.236.93.127 scope global em1
inet6 fe80::f24d:a2ff:fe73:9a9a/64 scope link
valid_lft forever preferred_lft forever
3: em2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether f0:4d:a2:73:9a:9b brd ff:ff:ff:ff:ff:ff
[root@Zabbix-yuanzhan ~]# lspci | grep Eth
02:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
02:00.3 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
[root@Zabbix-yuanzhan ~]# lspci -nn | grep Eth
02:00.0 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
02:00.3 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
解释:上面 [8086:1521] 中 1521为VenID,8086为DevID,magic的值为:0x15218086
#或者这样看,根据硬件地址来查询magic值
[root@Zabbix-yuanzhan ~]# lspci -s 02:00.3 -nn
02:00.3 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
第二:根据网卡当前的mac确定,其在ethtool中的存储位置
[root@Zabbix-yuanzhan ~]# ip a
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether f0:4d:a2:73:9a:9a brd ff:ff:ff:ff:ff:ff
inet 156.236.93.10/25 brd 156.236.93.127 scope global em1
inet6 fe80::f24d:a2ff:fe73:9a9a/64 scope link
valid_lft forever preferred_lft forever
3: em2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether f0:4d:a2:73:9a:9b brd ff:ff:ff:ff:ff:ff
[root@Zabbix-yuanzhan ~]# ethtool -e em2 | grep "9a 9b"
0x0000: f0 4d a2 73 9a 9b 00 08 ff ff 57 10 ff ff ff ff
解释:根据过滤知道这一行确实是我们上面看到的mac地址行,但只有前面6个才是mac地址,后面的不用理会
其中:f0 的定位是 0x0000 ; 4d的定位是 0x0001;以此类推
第三:修改mac地址,我们把 f0:4d:a2:73:9a:9b 改成f0:4d:a2:73:9a:9c
#语法格式:ethtool -E eth0 magic [magic地址] offset [定位值]
ethtool -E em2 magic 0x15218086 offset 0x0000 value 0xf0
ethtool -E em2 magic 0x15218086 offset 0x0001 value 0x4d
ethtool -E em2 magic 0x15218086 offset 0x0002 value 0xa2
ethtool -E em2 magic 0x15218086 offset 0x0003 value 0x73
ethtool -E em2 magic 0x15218086 offset 0x0004 value 0x9a
ethtool -E em2 magic 0x15218086 offset 0x0005 value 0x9c
第四:重启验证
[root@Zabbix-yuanzhan ~]# ip a
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether f0:4d:a2:73:9a:9a brd ff:ff:ff:ff:ff:ff
inet 156.236.93.10/25 brd 156.236.93.127 scope global em1
inet6 fe80::f24d:a2ff:fe73:9a9a/64 scope link
valid_lft forever preferred_lft forever
3: em2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether f0:4d:a2:73:9a:9c brd ff:ff:ff:ff:ff:ff
附:另一种修改mac的工具:macchanger 请自行测试
如果文章对你有帮助,欢迎点击上方按钮打赏作者
暂无评论