- 网卡名称:ens32
- 原MAC地址:00:0c:29:3e:6e:74
- 修改后MAC地址:00:01:23:0a:0b:cd
- 原IP地址:192.168.3.8/24
[root@source ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:3e:6e:74 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.8/24 brd 192.168.3.255 scope global dynamic ens32
valid_lft 604648sec preferred_lft 604648sec
[root@source ~]#
临时修改
ifconfig ens32 down
ifconfig ens32 hw ether 00:01:23:0a:0b:cd
ifconfig ens32 up
# 重启网络不失效,但是重启系统失效
结果:
[root@source ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:01:23:0a:0b:cd brd ff:ff:ff:ff:ff:ff
inet 192.168.3.8/24 brd 192.168.3.255 scope global dynamic ens32
valid_lft 604181sec preferred_lft 604181sec
[root@source ~]#
永久修改
方式一:开机执行命令
cat >>/etc/rc.d/rc.local <<EOF
ifconfig ens32 down
ifconfig ens32 hw ether 00:01:23:0a:0b:cd
ifconfig ens32 up
EOF
chmod +x /etc/rc.d/rc.local
reboot -h now
结果:
[root@source ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:01:23:0a:0b:cd brd ff:ff:ff:ff:ff:ff
inet 192.168.3.8/24 brd 192.168.3.255 scope global dynamic ens32
valid_lft 604734sec preferred_lft 604734sec
[root@source ~]#
方拾二:修改配置文件
vim /etc/sysconfig/network-scripts/ifcfg-ens32
# 如果有HWADDR这一行则注释掉,追加如下一行
MACADDR=00:01:23:0a:0b:cd
完整配置如下:
# TYPE=Ethernet
# BOOTPROTO=dhcp
# NAME=ens32
# DEVICE=ens32
# ONBOOT=yes
# MACADDR=00:01:23:0a:0b:cd
systemctl restart network
# 或者
# ifconfig ens32 down && ifconfig ens32 up
结果:
[root@source ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:01:23:0a:0b:cd brd ff:ff:ff:ff:ff:ff
inet 192.168.3.15/24 brd 192.168.3.255 scope global dynamic ens32
valid_lft 604668sec preferred_lft 604668sec
[root@source ~]#