centos7/8发行版eth0网络设置-nmcli
问题描述
el7/el8发行版本,设置网络配置,利用命令的形式自动生成配置
问题解决
nmcli
[root@192 ~]# nmcli con show # 查看device -> connection
NAME UUID TYPE DEVICE
Wired connection 1 2afba89b-008c-3b31-9638-ac378f6f23c0 ethernet eth0
ens3 d5c98548-2748-498d-99b8-3bec1f81afff ethernet --
[root@192 ~]# nmcli con mod 'Wired connection 1' connection.id eth0 # 修改connection
[root@192 ~]#
[root@192 ~]# nmcli con show
NAME UUID TYPE DEVICE
eth0 2afba89b-008c-3b31-9638-ac378f6f23c0 ethernet eth0
ens3 d5c98548-2748-498d-99b8-3bec1f81afff ethernet --
#修改连接名字(按需)
nmcli con mod xxx connection.id eth1
#修改eth0的ip/gateway/dns
nmcli con mod eth0 ipv4.address 192.168.1.120/24 ipv4.gateway 192.168.1.1 ipv4.dns "223.5.5.5 8.8.8.8" //dns1 dns2
#设置网络是手动设置
nmcli con mod eth0 ipv4.method manual
#配置生效
nmcli con up/down eth0
or
systemctl restart network /NetworkManager
static network config*
/etc/sysconfig/network-scripts/ifcfg-ethx