系统类型:Rocky Linux 9.6 (Blue Onyx)
Rocky 要给单网卡配置双 IP 地址,比CentOS更为便捷,不需要新增文件。
配置了第一个 IP 地址:192.168.100.110
vim /etc/NetworkManager/system-connections/ens160.nmconnection
[root@localhost system-connections]# vim /etc/NetworkManager/system-connections/ens160.nmconnection[connection]id=ens160uuid=54237e47-611f-380b-8b1e-1cab4953ab92type=ethernetautoconnect-priority=-999interface-name=ens160timestamp=1767107032[ethernet][ipv4]address1=192.168.100.110/24dns=114.114.114.114;8.8.8.8;gateway=192.168.100.1method=manual[ipv6]addr-gen-mode=eui64method=auto[proxy]
添加第二个 IP 地址:192.168.100.118
address2=192.168.100.118/24
[root@localhost system-connections]# vim /etc/NetworkManager/system-connections/ens160.nmconnection[connection]id=ens160uuid=54237e47-611f-380b-8b1e-1cab4953ab92type=ethernetautoconnect-priority=-999interface-name=ens160timestamp=1767107032[ethernet][ipv4]address1=192.168.100.110/24address2=192.168.100.118/24dns=114.114.114.114;8.8.8.8;gateway=192.168.100.1method=manual[ipv6]addr-gen-mode=eui64method=auto[proxy]
systemctl restart NetworkManager