CentOS Stream怎么设置固定IP

发布时间 2023-11-09 09:43:43作者: minseo

参考:https://blog.csdn.net/qq_36393978/article/details/127999172
CentOS Stream设置ip方式和之前CentOS不一样

环境查看

# cat /etc/redhat-release 
CentOS Stream release 9
# uname -a
Linux localhost.localdomain 5.14.0-381.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Oct 30 23:56:21 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

修改配置文件

# cat /etc/NetworkManager/system-connections/ens3.nmconnection 
[connection]
id=ens3
uuid=09bcb246-d013-36dd-975b-cac8484af6c4
type=ethernet
autoconnect-priority=-999
interface-name=ens3
timestamp=1699436140

[ethernet]

[ipv4]
#method=auto
#自动修改为手动
method=manual
#设置ip地址和网关
address1=192.168.3.203/24,192.168.3.1
#设置DNS
dns=192.168.3.1;114.114.114.114

[ipv6]
addr-gen-mode=eui64
method=auto

[proxy]

设置生效

# 重置网络
#sudo nmcli c reload
# 启动网卡,名称ens3根据网卡实际名称修改
#sudo nmcli c up ens3