问题:Centos8 执行:systemctl restart network
提示:Failed to restart network.service_ Unit network.service not found
方法1:nmcli networking off && nmcli networking on
方法2:nmcli con down ens33 && nmcli con up ens33
[root@host104 ~]# nmcli connection
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet ens33
显示具体的网络接口信息
# nmcli connection show ens33
显示所有设配状态 :nmcli device status
修改配置文件执行生效:# nmcli connection reload
显示所有活动连接:# nmcli connection show --active
删除一个网卡连接
# nmcli connection delete eth0
添加网卡
# nmcli connection add type ethernet con-name eth0
给eth0添加一个IP(IPADDR)
# nmcli connection modify eth0 ipv4.addresses 192.168.0.58
给eth0添加一个子网掩码(NETMASK)
# nmcli connection modify eth0 ipv4.addresses 192.168.0.58/24
IP获取方式设置成手动(BOOTPROTO=static/none)
# nmcli connection modify eth0 ipv4.method manual
添加一个ipv4
# nmcli connection modify eth0 +ipv4.addresses 192.168.0.59/24
删除一个ipv4
# nmcli connection modify eth0 -ipv4.addresses 192.168.0.59/24
添加DNS
# nmcli connection modify eth0 ipv4.dns 114.114.114.114
删除DNS
# nmcli connection modify eth0 -ipv4.dns 114.114.114.114
添加一个网关(GATEWAY)
# nmcli connection modify eth0 ipv4.gateway 192.168.0.2
可一块写入:nmcli connection modify eth0 ipv4.dns 114.114.114.114 ipv4.gateway 192.168.0.2