双十一活动
火爆
Centos Stream9 配置静态IP
发布时间:2024-06-27 18:41
阅读量:623
查看下当前网卡信息:
[root@stream9 ~]# 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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:af:75:1d brd ff:ff:ff:ff:ff:ff altname enp2s1 inet6 fe80::20c:29ff:feaf:751d/64 scope link noprefixroute valid_lft forever preferred_lft forever
cd到/etc/sysconfig/network-scripts/目录下ll查看,发现不存在之前版本CentOS的网卡配置文件ifcfg-ens33
[root@stream9 network-scripts]# cd /etc/sysconfig/network-scripts/
[root@stream9 network-scripts]# ll
总用量 4 -rw-r--r--. 1 root root 1244 6月 2 00:13 readme-ifcfg-rh.txt
使用grep查找一下ens33网卡配置文件
[root@stream9 network-scripts]# grep -rnw '/etc' -e 'ens33' /etc/NetworkManager/system-connections/ens33.nmconnection:2:id=ens33 /etc/NetworkManager/system-connections/ens33.nmconnection:6:interface-name=ens33
修改 ens33.nmconnection 配置文件 [ipv4]
[root@stream9 network-scripts]# vi /etc/NetworkManager/system-connections/ens33.nmconnection [connection] id=ens33 uuid=c85ddafe-0502-3ab8-918d-be5862430432 type=ethernet autoconnect-priority=-999 interface-name=ens33 timestamp=1655465382 [ethernet] [ipv4] address1=192.168.137.40/24 method=manual [ipv6] addr-gen-mode=eui64 method=auto [proxy]
使用nmcli命令重启网卡服务,network服务已经被移除,无法用service和systemctl来重启network服务
[root@stream9 network-scripts]# nmcli c reload #重新加载配置文件 [root@stream9 network-scripts]# nmcli c up ens33 #重启ens33网卡 连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/6)
重启网卡后查看ip,可以看到新的静态ip已经配置成功
[root@stream9 network-scripts]# 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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:af:75:1d brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.137.40/24 brd 192.168.137.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:feaf:751d/64 scope link noprefixroute valid_lft forever preferred_lft forever