CentOS 8 重启网络服务nmcli

CentOS 8中使用systemctl network.service 命令已失效,使用nmcli代替了传统的network.service。

nmcli命令重启网络服务

1.查看网络配置信息,找到本机IP的网卡名称ens3

ifconfig

ens3: flags=4163  mtu 1500
        inet 192.168.0.12  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::f816:3eff:fe12:c139  prefixlen 64  scopeid 0x20
        ether fa:16:3e:12:c1:39  txqueuelen 1000  (Ethernet)
        RX packets 43925023  bytes 17475183883 (16.2 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 55032055  bytes 20430800482 (19.0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
....

2.网络的修改配置信息(网卡名称ens3)

#默认路径

vim /etc/sysconfig/network-scripts/ifcfg-ens3 

3.重启网卡之前一定要重新载入一下配置文件,不然不能立即生效 

nmcli c reload

4.nmcli device查看网卡链接状态

nmcli device

DEVICE  TYPE      STATE                   CONNECTION  
ens3    ethernet  connected               System ens3 
virbr0  bridge    connected (externally)  virbr0      
lo      loopback  unmanaged               --        

5.重启⽹卡(下⾯的三条命令都可以)

nmcli c up System\ ens3

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
 

nmcli d reapply ens3

Connection successfully reapplied to device 'ens3'.
 

nmcli d connect ens3

Device 'ens3' successfully activated with '21d47e65-8523-1a06-af22-6f121086f085'.
 

你可能感兴趣的:(centos,linux,服务器)