RockyLinux9配置静态IP

修改 NetworkManager 配置文件

ens160为我的网卡名称

1
vim /etc/NetworkManager/system-connections/ens160.nmconnection
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
[connection]
id=ens160
uuid=efb3926c-387d-3dcf-b732-9cb06feb2955
type=ethernet
autoconnect-priority=-999
interface-name=ens160
timestamp=1663499850

[ethernet]

[ipv4]
address1=192.168.50.82/24,192.168.50.1
dns=8.8.8.8;1.1.1.1;
may-fail=false
method=manual

[proxy]

重载配置

1
nmcli connection load /etc/NetworkManager/system-connections/ens160.nmconnection

激活配置

1
nmcli connection up /etc/NetworkManager/system-connections/ens160.nmconnection

测试是否生效

ping、ip a等方法

查询UUID

1
nmcli con
NAME     UUID                                  TYPE      DEVICE  
ens160   efb3926c-387d-3dcf-b732-9cb06feb2955  ethernet  ens160  
docker0  22323652-5f33-444f-bdb2-2f63e839c915  bridge    docker0
updatedupdated2024-10-282024-10-28