NetworkManager 是 RHEL 7 及 CentOS 7 的默认网络管理工具, 除了使用 GUI 接口外, NetworkManager 也可以透过 nmcli 指令控制, 以下会介绍 nmcli 的常见用法。
显示 NetworkManager 状态概况:
# nmcli general status
显示所有连线:
# nmcli connection show
只显示 active 的连线:
# nmcli connection show -a
显示所有 NetworkManager 辨识到的装置及它们目前的状态:
# nmcli device status
停用网卡:
# nmcli device disconnect eno16777736
启用网卡:
# nmcli device connect eno16777736
加入固定 IP:
# nmcli connection add type ethernet con-name NEW ifname eno16777736 ip4 [new-ip] gw4 [gateway-ip]
设定使用的 Dns Servers:
# nmcli connection modify NEW ipv4.dns “8.8.8.8 8.8.4.4”
启动新连结线:
# nmcli connection up NEW ifname eno16777736