Nmcli:修订间差异

来自三线的随记
无编辑摘要
无编辑摘要
 
(未显示同一用户的6个中间版本)
第1行: 第1行:
=== 安装 ===
===安装===
network-manager
network-manager


=== 相关命令 ===
===相关命令===
<pre>
nmcli[ OPTIONS ] OBJECT { COMMAND | help }&lt;/nowiki&gt;
nmcli[ OPTIONS ] OBJECT { COMMAND | help }</nowiki>
nmcli connection show
nmcli connection show  --active
nmcli device {disconnect|connect|show|status}


nmcli connection show
===例子1 [ 新增连接 Add ]===
 
====Define a new connection named "default" which will autoconnect as Ethern connection on the eth0 device using DHCP====
nmcli connection show  --active
</pre>
 
=== 例子 ===
===== Define a new connection named "default" whic will autoconnect as Ethern connection on the eth0 device using DHCP =====
  nmcli connection add con-name "default" type ethernet ifname eth0
  nmcli connection add con-name "default" type ethernet ifname eth0
===== Create a new connection named "static" and specify the IP address and gateway.Do not autoconnect =====
====Create a new connection named "static" and specify the IP address and gateway.Do not autoconnect====
  nmcli connection add con-name "static" ifname eth0 autoconnect no type ethernet ip4 172.25.x.x/24 gw4 172.25.x.254
  nmcli connection add con-name "static" ifname eth0 autoconnect no type ethernet ip4 172.25.x.x/24 gw4 172.25.x.254
===== The system will autoconnected with the DHCP connection at boot.Change to the static connection =====
====The system will autoconnected with the DHCP connection at boot.Change to the static connection====
  nmcli connection up "static"
  nmcli connection up "static"
===== Change back to the DHCP connection =====
====Change back to the DHCP connection====
  nmcli con up "default"
  nmcli con up "default"
===例子2 [ 修改连接 Modify ]===
====Turn off autoconnect====
nmcli connection mod "static" connection.autoconnect no
====Specify a DNS server====
nmcli connection mod "static" ipv4.dns 114.114.114.114
==== Specify multiple DNS servers ====
nmcli con mod $connectionName ipv4.dns "8.8.8.8 8.8.4.4"
====Some configuration arguments may have values added or removed.Add a +/- symbol in front of the argument.Add a secondary DNS server====
nmcli con mod "static" +ipv4.dns 8.8.8.8
===热点 [ wifi hotspot ]===
nmcli device wifi hotspot ifname wlx14cf92d7f77d con-name myHotspot ssid test password 1234567890
nmcli connection modify myHotspot connection.autoconnect yes
nmcli con modify myHotspot 802-11-wireless.ssid orangeWifi
[[category:Linux]]

2022年4月12日 (二) 16:16的最新版本

安装

network-manager

相关命令

nmcli[ OPTIONS ] OBJECT { COMMAND | help }</nowiki>

nmcli connection show

nmcli connection show  --active

nmcli device {disconnect|connect|show|status}

例子1 [ 新增连接 Add ]

Define a new connection named "default" which will autoconnect as Ethern connection on the eth0 device using DHCP

nmcli connection add con-name "default" type ethernet ifname eth0

Create a new connection named "static" and specify the IP address and gateway.Do not autoconnect

nmcli connection add con-name "static" ifname eth0 autoconnect no type ethernet ip4 172.25.x.x/24 gw4 172.25.x.254

The system will autoconnected with the DHCP connection at boot.Change to the static connection

nmcli connection up "static"

Change back to the DHCP connection

nmcli con up "default"

例子2 [ 修改连接 Modify ]

Turn off autoconnect

nmcli connection mod "static" connection.autoconnect no

Specify a DNS server

nmcli connection mod "static" ipv4.dns 114.114.114.114

Specify multiple DNS servers

nmcli con mod $connectionName ipv4.dns "8.8.8.8 8.8.4.4"

Some configuration arguments may have values added or removed.Add a +/- symbol in front of the argument.Add a secondary DNS server

nmcli con mod "static" +ipv4.dns 8.8.8.8


热点 [ wifi hotspot ]

nmcli device wifi hotspot ifname wlx14cf92d7f77d con-name myHotspot ssid test password 1234567890
nmcli connection modify myHotspot connection.autoconnect yes
nmcli con modify myHotspot 802-11-wireless.ssid orangeWifi