nmcli命令和etc/sysconfig/network-scripts/ifcfg-*配置文件对应关系

nmcli/etc/sysconfig/network-scripts/ifcfg-*意思
ipv4.method manualBOOTPROTO=none不指定协议
ipv4.method autoBOOTPROTO=dhcp指定DHCP协议
ipv4.address “192.168.1.1/24”IPADDR0=192.168.1.1 PREFIX0=24 GATEWAY0=192.16.1.254设置IP,子网掩码和网关
ipv4.dns 8.8.8.8DNS1=8.8.8.8设置DNS服务器
ipv4.dns-search example.comDOMAIN=example.com设置域
ipv4.igore-auto-dns turePEERDNS=no防止从 DHCP 服务器接收的 DNS 服务器更新
connection.autoconnect yesONBOOT=yes系统启动时是否开启
connection.id eth0NAME=eth0设置名字
connection.interface-name eth0DEVICE=eth0网卡名称
802-3-ethernet.mac-addressHWADDR网卡设备MAC地址

查看网卡设备连接情况

nmcli device

LOCE

查看网卡信息

nmcli connection show
nmcli connection show --active //显示活动的网卡

LOVE
LOVE

查看具体信息

nmcli connection show ens33

LOVE

重启网络

systemctl restart network
nmcli connetion reload

删除一个网卡

nmcli connection delete ens33

LOVE

添加一个网卡

nmcli connection add type ethernet eth0 ifname ens33

LOVE

开启和关闭网卡

nmcli connection down ethernet-ens33
nmcli connection up ethernet-ens33

LOVE

设置网卡IP和子网掩码和网关

nmcli connection modify eth0 ipv4.address 192.168.1.10/24 ipv4.gateway 192.168.1.254
nmcli connection modify eth0 +ipv4.address 192.168.1.11/24 //添加一个ip
nmcli connection modify eth0 -ipv4.address 192.168.1.11/24 //删除一个ip

IP获取方式设置为手动或DHCP

nmcli connection modify eth0 ipv4.method manual
nmcli connection modify eth0 ipv4.method auto

设置DNS

nmcli connection modify eth0 ipv4.dns 8.8.8.8 //添加一个DNS
nmcli connection modify eth0 -ipv4.dns 8.8.8.8 //删除一个DNS

综合设置

nmcli connection modify eth0 ipv4.address 192.168.1.10/24 ipv4.gateway 192.168.1.254 ipv4.dns 8.8.8.8 ipv4.dns-search example.com ipv4.method manual connection.autoconnect yes connection,interface-name eth0
Logo

更多推荐