Rocky Linux 9 配置IP并生效

背景

  1. Rocky Linux9系统
  2. 修改IP的方式有不同,不再是修改/etc/sysconfig/network-scripts/之下的脚本,系统也没有名叫network的服务。
  3. 系统通过NetworkManger和网络connetions来管理网卡和IP。

实际操作

Rocky Linux通过“系统连接”管理网卡及IP,修改、新增*.nmconneciton文件可以完成对操作系统的IP配置。
此处修改初始IP的配置命令如下:

[root@localhost system-connections]# cd /etc/NetworkManager/system-connections/
[root@localhost system-connections]# ll
total 4
-rw-------. 1 root root 256 Nov 15  2022 'Ethernet connection 1.nmconnection'
[root@localhost system-connections]# vim Ethernet\ connection\ 1.nmconnection 
[root@localhost system-connections]# 

连接文件具体内容如下:

[connection]
id=ens192
uuid=14d47b8e-b926-4fa9-b962-f057bc015d8b
type=ethernet
interface-name=ens192
timestamp=1681721746

[ethernet]

[ipv4]
address1=192.168.1.250/24,192.168.1.1
dns=8.8.8.8;
method=auto

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

[proxy]

3. 重启生效:

两种方式
systemctl restart NetworkManager

nmcli device
nmcli connection down ens192
nmcli connection up ens192

设置命令行启动


 systemctl get-default                      获取默认启动项

systemctl set-default multi-user.target     设置命令行启动
 
systemctl set-default  graphical.target     设置图形化启动

版权声明:
作者:凯影
链接:https://www.sxszhian.com/archives/11416
来源:上海永驰网络科技有限公司
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
< <上一篇
下一篇>>