nmcli网络常用配置命令
这里的enxxxx为网卡名,具体以实际显示为准
查看网卡信息命令
查看所有网络连接
# nmcli connection show
查看活动的网络连接
# nmcli connection show -active
查看指定网卡的详细信息
# nmcli connection show enxxx
显示设备的连接状态
# nmcli device status
显示所有网络设备详情信息
# nmcli device show
显示指定网络设备的详细信息
# nmcli device show enxxx
网卡状态修改命令
启用网络连接
# nmcli connection up enxxxx
停用网络连接(可被自动激活)
# nmcli connection down enxxxx
禁用网卡
# nmcli device disconnect enxxxx
删除网络连接的配置文件
# nmcli connection delete enxxxx
重新加载网络配置文件
# nmcli connection reload
修改网卡配置
设置自动启动网卡
# nmcli connection modify enxxxx connection.autoconnect yes
设置IP获取方式
手动:# nmcli connection modify enxxxx ipv4.method manual ipv4.addresses 192.168.0.100
DHCP:# nmcli connection modify enxxxx ipv4.method auto
修改IP
# nmcli connection modify enxxxx ipv4.addresses 192.168.0.102
修改网关
# nmcli connection modify enxxxx ipv4.gateway 192.168.0.1
添加DNS
# nmcli connection modify enxxxx ipv4.dns 114.114.114.114
添加第二个DNS
# nmcli connection modify enxxxx +ipv4.dns 8.8.8.8
删除第二个DNS
# nmcli connection modify enxxxx -ipv4.dns 8.8.8.8
参考文章
https://blog.csdn.net/u010599211/article/details/86672940
https://www.cnblogs.com/mind-water/p/12079647.html (对官网文档的整理翻译,比较完整且比官网更加精炼)
https://developer.gnome.org/NetworkManager/unstable/nmcli.html (关于nmcli的官网文档)

浙公网安备 33010602011771号