1. 复制网卡配置文件,更名为指定文件
[root@bogon network-scripts]# cd /etc/sysconfig/network-scripts/
[root@bogon network-scripts]#
[root@bogon network-scripts]# cp ifcfg-swift216f0 ifcfg-p4p2
[root@bogon ~]# uuidgen p4p2
c9bdafd4-cd80-4951-aee9-2f48d19a8a19
2.查询 p4p2 网卡 MAC (ether)
# ifconfig
p4p2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether **:**:**:**:**:** txqueuelen 1000 (Ethernet)
RX packets 5 bytes 425 (425.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 420 bytes 70680 (69.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 166
3. 获取新网卡 p4p2 的 uuid
[root@bogon ~]# systemctl status NetworkManager
● NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-12-07 11:21:44 CST; 2h 14min ago
Docs: man:NetworkManager(8)
Main PID: 1794 (NetworkManager)
Tasks: 3
CGroup: /system.slice/NetworkManager.service
└─1794 /usr/sbin/NetworkManager --no-daemon[root@bogon ~]# uuidgen p4p2 # 每次执行,获取的uuid都唯一
c9bdafd4-cd80-4951-aee9-2f48d19a8a19
4. 修改网卡配置文件
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=11.1.1.2
IPV4_FAILURE_FATAL=no
PREFIX=24
DEFROUTE=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=p4p2
UUID=c9bdafd4-cd80-4951-aee9-2f48d19a8a19 // 根据step3 获取的uuid
DEVICE=p4p2
GATEWAY=0.0.0.0
IPV4_ROUTE_METRIC=102
ONBOOT=yes
HWADDR=**:**:**:**:**:** // 更改MAC,通过ifconfig 查询 ether value,根据step2 获取的mac
5. 重启网卡,使网卡生效
ifdown p4p2
ifup p4p2
如果此时连接还是有问题,建议reboot machine.