centos修改网卡mac地址

Catalogue
  1. 1. 永久修改
  2. 2. 暂时修改
  3. 3. 重点

永久修改

1
2
3
4
5
6
7
8
9
10
11
12
13
ifconfig eth0 down

cd /etc/sysconfig/network-scripts

vi ifcfg-eth0

删掉"HWADDR=xx:xx:xx:xx:xx:xx"
编辑"MACADDR=xx:xx:xx:xx:xx:xx"

ifconfig eth0 up

service network start

暂时修改

方法一

1
ip link set dev eth0 address 00:00:ff:bb:aa:00

方法二

这个没测试过

1
2
3
4
5
ifconfig eth0 down /*禁掉eth0网卡,这里以eth0网卡为例*/

ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE /*修改eth0网卡的MAC地址*/

ifconfig eth0 up /*重新启动eth0网卡*/

重点

udev规则的mac与网卡配置文件的mac(HWADDR,MACADDR)有啥区别

udev的mac是网卡的默认mac,即网卡出厂时固定的mac地址,被厂家写进芯片里的,需要用特殊的rom工具才能修改

1.MAC地址属于芯片中的一个属性,因为在接收数据包时需要根据这个值来做包过滤。

3.HWADDR保存到网卡芯片的ROM中,由芯片厂商出厂前写入,相当于是芯片的序列号一般不能修改。

3.系统中网卡的MAC地址默认值是从HWADDR中读出,如果我们没有配置MAC地址,它默认就是等于HWADDR的。

4.MACADDR是配置到网卡的mac地址,也就是ip a显示的mac地址,如果配了该参数,那么网卡的mac地址将变成MACADDR