# 查看ip(類似于ifconfig、ip addr)
nmcli
# 創(chuàng)建connection,配置靜態(tài)ip(等同于配置ifcfg,其中BOOTPROTO=none,并ifup啟動)
nmcli c add type ethernet con-name ethX ifname ethX ipv4.addr 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.method manual
# 創(chuàng)建connection,配置動態(tài)ip(等同于配置ifcfg,其中BOOTPROTO=dhcp,并ifup啟動)
nmcli c add type ethernet con-name ethX ifname ethX ipv4.method auto
# 修改ip(非交互式)
nmcli c modify ethX ipv4.addr '192.168.1.200/24'
nmcli c up ethX
# 修改ip(交互式)
nmcli c edit ethX
nmcli> goto ipv4.addresses
nmcli ipv4.addresses> change
Edit 'addresses' value: 192.168.1.200/24
Do you also want to set 'ipv4.method' to 'manual'? [yes]: yes
nmcli ipv4> save
nmcli ipv4> activate
nmcli ipv4> quit
# 啟用connection(相當于ifup)
nmcli c up ethX
# 停止connection(相當于ifdown)
nmcli c down
# 刪除connection(類似于ifdown并刪除ifcfg)
nmcli c delete ethX
# 查看connection列表
nmcli c show
# 查看connection詳細信息
nmcli c show ethX
# 重載所有ifcfg或route到connection(不會立即生效)
nmcli c reload
# 重載指定ifcfg或route到connection(不會立即生效)
nmcli c load /etc/sysconfig/network-scripts/ifcfg-ethX
nmcli c load /etc/sysconfig/network-scripts/route-ethX
# 立即生效connection,有3種方法
nmcli c up ethX
nmcli d reapply ethX
nmcli d connect ethX
# 查看device列表
nmcli d
# 查看所有device詳細信息
nmcli d show
# 查看指定device的詳細信息
nmcli d show ethX
# 激活網卡
nmcli d connect ethX
# 關閉無線網絡(NM默認啟用無線網絡)
nmcli r all off
# 查看NM納管狀態(tài)
nmcli n
# 開啟NM納管
nmcli n on
# 關閉NM納管(謹慎執(zhí)行)
nmcli n off
# 監(jiān)聽事件
nmcli m
# 查看NM本身狀態(tài)
nmcli
# 檢測NM是否在線可用
nm-online