Rocky Linux9.0配置IP地址TCP/IP参数
时间:2023-03-02 10:48 来源:linux.it.net.cn 作者:IT
在Rocky9中,丢弃使用了传统的network 而使用新的NetworkManager管理方式
所有较之前的版本配置方式有所不同
先查看下未配置前现在的ip参数
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:bb:06:6b brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 192.168.252.151/24 brd 192.168.252.255 scope global dynamic noprefixroute ens160
valid_lft 1731sec preferred_lft 1731sec
inet6 fe80::20c:29ff:febb:66b/64 scope link noprefixroute
valid_lft forever preferred_lft forever
可以看到现在是dhcp获取的192.168.252.151
现在配置一下静态:
root@localhost ~]# vim /etc/NetworkManager/system-connections/ens160.nmconnection
[connection]
id=ens160
uuid=dd894cca-3086-3461-9acf-97d7cc6a8188
type=ethernet
autoconnect-priority=-999
interface-name=ens160
timestamp=1668700728
[ethernet]
[ipv4]
method=auto //自动获取
[ipv6]
addr-gen-mode=eui64
method=auto
[proxy]
更改 [ipv4] 那段:
[connection]
id=ens160
uuid=dd894cca-3086-3461-9acf-97d7cc6a8188
type=ethernet
autoconnect-priority=-999
interface-name=ens160
timestamp=1668700728
[ethernet]
[ipv4]
address1=192.168.1.1/24,192.168.1.254 //添加ip/子网掩码,网关
dns=192.168.1.1 //添加dns地址(多个用;隔开)
method=manual
[ipv6]
addr-gen-mode=eui64
method=auto
[proxy]
更改完成后保存退出
接下来写入配置文件
[root@localhost ~]# nmcli c reload
再更新一下网卡配置
[root@localhost ~]# nmcli c up ens160
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
静态ip已配置完成啦
再查看下现在的tcp/ip参数
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:bb:06:6b brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 192.168.1.1/24 brd 192.168.1.255 scope global noprefixroute ens160
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:febb:66b/64 scope link noprefixroute
valid_lft forever preferred_lft forever
可以看到现在未静态配置的192.168.1.1
再查看一下dns地址
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.1.1
可以看到均和上面配置的参数一致
整个就配置完成了
(责任编辑:IT)
在Rocky9中,丢弃使用了传统的network 而使用新的NetworkManager管理方式 所有较之前的版本配置方式有所不同 先查看下未配置前现在的ip参数 [root@localhost ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:bb:06:6b brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 192.168.252.151/24 brd 192.168.252.255 scope global dynamic noprefixroute ens160 valid_lft 1731sec preferred_lft 1731sec inet6 fe80::20c:29ff:febb:66b/64 scope link noprefixroute valid_lft forever preferred_lft forever 可以看到现在是dhcp获取的192.168.252.151 现在配置一下静态: root@localhost ~]# vim /etc/NetworkManager/system-connections/ens160.nmconnection [connection] id=ens160 uuid=dd894cca-3086-3461-9acf-97d7cc6a8188 type=ethernet autoconnect-priority=-999 interface-name=ens160 timestamp=1668700728 [ethernet] [ipv4] method=auto //自动获取 [ipv6] addr-gen-mode=eui64 method=auto [proxy] 更改 [ipv4] 那段: [connection] id=ens160 uuid=dd894cca-3086-3461-9acf-97d7cc6a8188 type=ethernet autoconnect-priority=-999 interface-name=ens160 timestamp=1668700728 [ethernet] [ipv4] address1=192.168.1.1/24,192.168.1.254 //添加ip/子网掩码,网关 dns=192.168.1.1 //添加dns地址(多个用;隔开) method=manual [ipv6] addr-gen-mode=eui64 method=auto [proxy] 更改完成后保存退出 接下来写入配置文件 [root@localhost ~]# nmcli c reload 再更新一下网卡配置 [root@localhost ~]# nmcli c up ens160 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6) 静态ip已配置完成啦 再查看下现在的tcp/ip参数 [root@localhost ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:bb:06:6b brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 192.168.1.1/24 brd 192.168.1.255 scope global noprefixroute ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:febb:66b/64 scope link noprefixroute valid_lft forever preferred_lft forever 可以看到现在未静态配置的192.168.1.1 再查看一下dns地址 [root@localhost ~]# cat /etc/resolv.conf # Generated by NetworkManager nameserver 192.168.1.1 可以看到均和上面配置的参数一致 整个就配置完成了 (责任编辑:IT) |