Rocky 9 静态IP网络配置

281次阅读
没有评论

共计 2401 个字符,预计需要花费 7 分钟才能阅读完成。

Rocky 9 静态IP网络配置

今天安装完rocky9后,发现与以往的rocky8的网卡配置不同,在/etc/sysconfig/network-scripts/ 下发现了readme-ifcfg-rh.txt 文件,里面介绍了rocky9在/etc/NetworkManager/system-connections/ 下进行网卡的配置,以下为该文件的解释

[root@localhost ~]# more /etc/sysconfig/network-scripts/readme-ifcfg-rh.txt 
NetworkManager stores new network profiles in keyfile format in the
/etc/NetworkManager/system-connections/ directory.

Previously, NetworkManager stored network profiles in ifcfg format
in this directory (/etc/sysconfig/network-scripts/). However, the ifcfg
format is deprecated. By default, NetworkManager no longer creates
new profiles in this format.

Connection profiles in keyfile format have many benefits. For example,
this format is INI file-based and can easily be parsed and generated.

Each section in NetworkManager keyfiles corresponds to a NetworkManager
setting name as described in the nm-settings(5) and nm-settings-keyfile(5)
man pages. Each key-value-pair in a section is one of the properties
listed in the settings specification of the man page.

If you still use network profiles in ifcfg format, consider migrating
them to keyfile format. To migrate all profiles at once, enter:

# nmcli connection migrate

This command migrates all profiles from ifcfg format to keyfile
format and stores them in /etc/NetworkManager/system-connections/.

Alternatively, to migrate only a specific profile, enter:

# nmcli connection migrate <profile_name|UUID|D-Bus_path>

For further details, see:
* nm-settings-keyfile(5)
* nmcli(1)

静态IP配置

备份网卡默认配置

[root@localhost ~]# cd /etc/NetworkManager/system-connections/
[root@localhost ~]# cp ens33.nmconnection ens33.nmconnection.bak
[root@localhost system-connections]# ll
total 8
-rw-------. 1 root root 277 Jan 23 03:08 ens33.nmconnection
-rw-------. 1 root root 206 Jan 23 02:47 ens33.nmconnection.bak

编辑网卡配置

[root@localhost system-connections]# more ens33.nmconnection
[connection]
id=ens33
uuid=4cdd786f-5ee3-3b61-82c0-81956a350f79
type=ethernet
autoconnect-priority=-999
interface-name=ens33

[ethernet]

[ipv4]
method=manual
address=10.110.141.102/24,10.110.141.254	#IP地址&掩码、网关配置(两者之间用,隔开)
dns=114.114.114.114;8.8.8.8					#DNS配置(多个dns地址之间用;分开)

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

[proxy]

重启网卡

[root@localhost system-connections]# nmcli connection reload 
[root@localhost system-connections]# nmcli connection up ens33 
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/16)

测试通过

[root@localhost system-connections]# ping baidu.com
PING baidu.com (110.242.68.66) 56(84) bytes of data.
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=51 time=22.5 ms
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=2 ttl=51 time=22.9 ms

正文完
 0
无能小子
版权声明:本站原创文章,由 无能小子 于2025-01-23发表,共计2401字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码

无能小子

热门文章
Ubuntu 24.04 网络配置教程:从 DHCP 到静态 IP 设置

Ubuntu 24.04 网络配置教程:从 DHCP 到静态 IP 设置

今天刚安装了Ubuntu24.04,发现网络和此前的老版本有了区别,如今所有的配置均可在一个文件下进行配置,现...
VMware安装飞牛OS,飞牛OS初体验!

VMware安装飞牛OS,飞牛OS初体验!

vmware安装飞牛OS 最近家庭NAS炒的沸沸扬扬,飞牛OS更是在一众OS系统中鹤立鸡群,今天我就用vmwa...
NAS吃灰终结者第1弹——Alist,实现思源笔记S3云同步

NAS吃灰终结者第1弹——Alist,实现思源笔记S3云同步

很多小伙伴一时兴起组装起来的NAS,后面放着放着就吃灰了,为了避免这个情况发生,今天给小伙伴分享个好玩的应用A...
NAS吃灰终结者第2弹——ERPNext,中小企业的免费开源供销存软件

NAS吃灰终结者第2弹——ERPNext,中小企业的免费开源供销存软件

很多小伙伴一时兴起组装起来的NAS,后面放着放着就吃灰了,为了避免这个情况发生,今天给小伙伴分享个好玩的应用E...
Rocky 9 静态IP网络配置

Rocky 9 静态IP网络配置

今天安装完rocky9后,发现与以往的rocky8的网卡配置不同,在/etc/sysconfig/networ...