默认为 networkmanager 管理
- 查看服务是否运行 systemctl status NetworkManager
- nmcli device status
是否管理了 eth0 等设备, 状态 connected
- 查看 /etc/sysconfig/network-scripts/ifcfg-*
是否配置
ONBOOT=yes
管理
NM_CONTROLLED=no
不管理
- sudo vim /etc/NetworkManager/NetworkManager.conf
查看配置文件
nmcli 为网卡的管理程序 (networkmanager 的前端管理)
- nmcli device status 网卡状态
- nmcli device status
网卡状态
- nmcli device show
网卡地址
- nmcli connection show
网卡所有链接
- nmcli connection show --active
查看活动连接
- nmcli connection up eth0
连接网络 (或更新配置) 注:eth0 主注意为 name 部分,有时为 System eth0
- nmcli connection down eth0
断开网络
- nmcli connection modify eth0 ipv4.dns "8.8.8.8 8.8.4.4"
设置 dns
- nmcli connection modify eth0 +ipv4.dns "114.114.114.114"
追加 dns
- nmcli connection modify eth0 ipv4.ignore-auto-dns no
不使用 dhcp 的 dns
- nmcli device wifi connect SSID_NAME password PASSWORD
连接 wifi
- nmcli connection add type ethernet ifname eth0 con-name eth0
为网卡设置 dhcp, 会生成配置文件 vpn_vpn.nmconnection
- nmcli general status
看全局状态
- nmcli connection modify eth0 ipv4.addresses "192.168.1.100/24" ipv4.gateway "192.168.1.1" ipv4.dns "8.8.8.8" ipv4.method manual
修改静态地址