Nmcli:修订间差异

来自三线的随记
无编辑摘要
无编辑摘要
第12行: 第12行:


=== 例子 ===
=== 例子 ===
===== Define a new connection named "default" whic will autoconnect as Ethern connection on the eth0 device using DHCP =====
==== 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"

2018年5月17日 (四) 13:35的版本

安装

network-manager

相关命令

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

nmcli connection show

nmcli connection show  --active

例子

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

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"