CentOS8已无法正常使用network服务。
[root@localhost ~]# systemctl status network Unit network.service could not be found. [root@localhost ~]#
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no NAME=ens33 UUID=4a0c3fda-c0c4-4b84-af1f-257817c3592e DEVICE=ens33 ONBOOT=no IPADDR=192.168.10.20 PREFIX=24 GATEWAY=192.168.10.1 [root@localhost ~]# [root@localhost ~]# nmcli c reload [root@localhost ~]# nmcli c up nes33
# 添加IP nmcli connection modity ens33 ipv4.address 192.168.10.20 # 添加掩码 nmcli connection modity ens33 ipv4.address 192.168.10.20/24 # 添加网关 nmcli connection modity ens33 ipv4.gateway 192.168.10.1 # 设置IP获取方式为手动/自动 nmcli connection modity ens33 ipv4.method manual # 添加DNS nmcli connection modity ipv4.dns 114.114.114.114 # 查看网卡信息 nmcli connection # 显示具体的网络接口信息 nmcli connection ens33 # 显示所有活动连接 nmcli connection show --active # 删除一个网卡 nmcli connection delete ens33 # 删除DNS nmcli connection modity ens33 -ipv4.dns 114.114.114.114
可通过yum install network-scripts来安装传统的network服务。
[root@localhost ~]# nmcli connection delete ens33
[root@localhost ~]# cp /etc/default/grub /etc/default/grub.bak [root@localhost ~]# sed -i 's/rhgb/net.ifnames=0 &/' /etc/default/grub
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
# 不修改命名规则device名称无法生效 [root@localhost ~]# echo 'ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{address}=="00:0c:29:15:f5:64", NAME="eth0"' >>/usr/lib/udev/rules.d/60-net.rules
[root@localhost ~]# reboot
[root@localhost ~]# nmcli connection modity eth0 ipv4.address 192.168.10.20/24 ipv4.gateway 192.168.10.1 ipv4.method manual [root@localhost ~]# nmcli c reload [root@localhost ~]# nmcli c up eth0
[root@localhost ~]# nmtui