centos8没法用systemctl restart network
和service restart network
方法:nmcli c reload +网卡名
查询网卡名
[root@localhost ~]# ifconfigenp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 192.168.0.168 netmask 255.255.255.0 broadcast 192.168.0.255inet6 fe80::adb4:388c:4129:ad4c prefixlen 64 scopeid 0x20<link>ether 08:00:27:9e:c4:42 txqueuelen 1000 (Ethernet)RX packets 33853 bytes 2474817 (2.3 MiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 120 bytes 22832 (22.2 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 12 bytes 1020 (1020.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 12 bytes 1020 (1020.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
可以看到网卡名为enp0s3
重启命令可以这样使用
例:nmcli c reload enp0s3
如果不行,可尝试以下命令
重载所有ifcfg或route到connection(不会立即生效)
nmcli c reload ifcfg-xxx
重载指定ifcfg或route到connection(不会立即生效)
nmcli c load /etc/sysconfig/network-scripts/ifcfg-enp0s3nmcli c load /etc/sysconfig/network-scripts/route-enp0s3
立即生效connection,有3种方法
nmcli c up enp0s3nmcli d reapply enp0s3nmcli d connect enp0s3