用NetworkManager的 nmcli connection modify 连接的名称或UUID ipv4.address 来设置IPV4
NetworkManager Documentation https://networkmanager.dev/docs/
nmcli官方例子 nmcli-examples — usage examples of nmcli
Fedora40xfce默认没有nmtui命令
用NetworkManager的 nmcli connection modify 连接的名称或UUID ipv4.address 来设置IP 的模板
只设置修改IP
覆盖原有设置: ipv4.addresses或ipv4.addr或ipv4.a
NameOrUuidOfConnection="连接名或UUID" #### 连接的名称或UUID可用 nmcli c 或 nmcli c s 或 nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}" \
ipv4.addresses "1.2.3.1/8 , 1.2.3.2/8, 1.2.3.3/8,1.2.3.4/8" ;
sudo nmcli connection down "${NameOrUuidOfConnection}"; sudo nmcli connection up "${NameOrUuidOfConnection}"; #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭
只添加IP
在原有基础上添加:前面加加号 +ipv4.addresses或+ipv4.addr或+ipv4.a
NameOrUuidOfConnection="连接名或UUID" #### 连接的名称或UUID可用 nmcli c 或 nmcli c s 或 nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}" \
+ipv4.addresses "1.2.3.1/8 , 1.2.3.2/8, 1.2.3.3/8,1.2.3.4/8" ;
sudo nmcli connection down "${NameOrUuidOfConnection}"; sudo nmcli connection up "${NameOrUuidOfConnection}"; #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭
删除指定IP
在原有基础上添加:前面加减号 -ipv4.addresses或-ipv4.addr或-ipv4.a
NameOrUuidOfConnection="连接名或UUID" #### 连接的名称或UUID可用 nmcli c 或 nmcli c s 或 nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}" \
-ipv4.addresses "1.2.3.1/8 , 1.2.3.2/8, 1.2.3.3/8,1.2.3.4/8" ;
sudo nmcli connection down "${NameOrUuidOfConnection}"; sudo nmcli connection up "${NameOrUuidOfConnection}"; #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭
设置静态IP的模板1
NameOrUuidOfConnectionTempVar="有线连接 1" #### 连接名或UUID 连接的名称或UUID可用 nmcli c 或 nmcli c s 或 nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnectionTempVar}" \
ipv4.method 'manual' \
ipv4.addresses "1.40.2.1/8 , 1.40.2.12/8 , 1.40.2.13/8 " \
+ipv4.ad 1.40.2.14/8,1.40.2.15/8 \
-ipv4.addr 1.40.2.14/8,1.40.2.15/8 \
ipv4.gateway "1.0.0.2" \
ipv4.ignore-auto-routes "no" \
ipv4.ignore-auto-dns 'yes' \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5 1.1.1.1,8.8.8.8,114.114.114.114,114.114.115.115 , 4.2.2.1,4.2.2.2" \
ipv4.dns-search 'baidu.com,qq.com,搜索域逗号分隔,可以不要.com,留着也无所谓.com'
sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ; #### 重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli conn down "${NameOrUuidOfConnectionTempVar}"; sudo nmcli conn up "${NameOrUuidOfConnectionTempVar}"; #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭
ip addr | grep 'inet ' ### 从 ip address show 筛选出本机的ipv4
nmcli|grep inet4 ### 从 nmcli 筛选出本机的ipv4
ipv4.method 取值 < manual手动(静态IP) | auto(自动获取IP)> ; 当设为auto,又指定了ip时, 自动获取的IP将和手动制定的静态IP同时存在
助记: ip address 对比 ipv4.addresses 在之前版本中可简写为 ip a和ipv4.a
ubuntu24 和 fedora40 的 ipv4.addresses 只能简写到 ipv4.ad , 不能简写到 ipv4.a
更多注释说明
### nmcli接 connection modify = connect modify = conn modi = con mod = co mo = c m 接连接的名称或UUID ; 连接的名称或UUID可用 nmcli c 或 nmcli c s 或 nmcli connection show 查看
### ipv4.method取值 <[ auto(自动获取ip)(默认值) | manual(手动设置静态ip) ]> , 即使设置为auto,也能再通过ipv4.addresses设置静态ip, 自动获取的ip将与手动设置的ip同时存在
### ipv4.addresses设置一或多ip ; +ipv4.addresses添加一或多ip ; -ipv4.addresses移除一个或多个ip ; addresses可简写为ad,以前版本可简写为ipv4.a ; ip用逗号分隔,可无空格,加空格要加单或双引号 ; ip/斜杠接子网掩码,无为32
### ipv4.gateway 设置网关,只能一个
### ipv4.ignore-auto-routes 是否跳过自动路由, 取值: 默认:[false, no, off](自动获取,不跳过) | [true, yes, on](跳过自动获取)
### ipv4.ignore-auto-dns 是否跳过自动DNS, 取值: 默认:[false, no, off](自动获取,不跳过) | [true, yes, on](跳过自动获取)
### ipv4.dns 设置DNS; 百度dns:180.76.76.76 , 阿里dns:223.6.6.6 , 腾讯dns:119.29.29.29
### ipv4.dns-search 搜索域, 可删除不要
NameOrUuidOfConnectionTempVar="有线连接 1" #### 连接名或UUID 连接的名称或UUID可用 nmcli c 或 nmcli c s 或 nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnectionTempVar}" \
ipv4.method 'manual' \
ipv4.addresses "1.40.2.1/8 , 1.40.2.12/8 , 1.40.2.13/8 " \
+ipv4.ad 1.40.2.14/8,1.40.2.15/8,1.40.2.16 \
-ipv4.addr 1.40.2.14/8,1.40.2.15/8 \
ipv4.gateway 1.0.0.2 \
ipv4.ignore-auto-routes "no" \
ipv4.ignore-auto-dns 'on' \
ipv4.dns "180.76.76.76 , 223.6.6.6 , 119.29.29.29, 223.5.5.5 1.1.1.1,8.8.8.8,114.114.114.114,114.114.115.115 , 4.2.2.1,4.2.2.2" \
ipv4.dns-search 'baidu.com,qq.com,搜索域逗号分隔,可以不要.com,留着也无所谓.com'
sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ; #### 重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli conn down "${NameOrUuidOfConnectionTempVar}"; #### 断开指定的网络 从设备停用连接(无需阻止设备再次自动激活)。要停用的配置集由它的名称、UUID 或 D-Bus 路径来确定。
sudo nmcli conn up "${NameOrUuidOfConnectionTempVar}"; #### 连接指定的网络 激活设备上的连接。要激活的配置集由它的名称、UUID 或 D-Bus 路径来确定。
sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ; #### 重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
ip addr | grep 'inet ' ### 从 ip address show 筛选出本机的ipv4
nmcli|grep inet4 ### 从 nmcli 筛选出本机的ipv4
上面的配置对应 /etc/NetworkManager/system-connections/'有线连接 1.nmconnection'
cd /etc/NetworkManager/system-connections
查看
sudo cat /etc/NetworkManager/system-connections/'有线连接 1.nmconnection'
内容如下👇
[connection]
id=有线连接 1
uuid=4e2bf48e-2d12-3efc-9ce3-20b31fe32b41
type=ethernet
autoconnect-priority=-999
interface-name=ens160
timestamp=1720296826
[ethernet]
[ipv4]
address1=1.40.2.1/8,1.0.0.2
address2=1.40.2.12/8
address3=1.40.2.13/8
address4=1.40.2.16/32
dns=180.76.76.76;223.6.6.6;119.29.29.29;223.5.5.5;1.1.1.1;8.8.8.8;114.114.114.114;114.114.115.115;4.2.2.1;4.2.2.2;
dns-search=baidu.com;qq.com;搜索域逗号分隔;可以不要.com;留着也无所谓.com;
ignore-auto-dns=true
method=manual
[ipv6]
addr-gen-mode=stable-privacy
method=auto
[proxy]
没看到 ipv4.ignore-auto-routes 选项是因为其值为默认值 [false, no, off]
ipv4.ignore-auto-routes 和ipv4.ignore-auto-dns , 当其值为默认值 [false, no, off]时, 就不会在/etc/NetworkManager/system-connections/中的文件内容中出现. 当设置为 [true, yes, on] 时, 无论是true,yes,on, 在xxx..nmconnection文件中都显示为 true
代码说明 , 不能直接粘贴使用, 反斜杠\之后必须换行, 空格都不能有
"${NameOrUuidOfConnection}"要加双引号,不加的话连接名称不能有空格
NameOrUuidOfConnection="ba4afbc8-c846-3a49-b222-18ee39f8c6cc" #### 连接名或UUID 连接的名称或UUID可用 nmcli c 或 nmcli c s 或 nmcli connection show 查看
sudo nmcli connection modify "${NameOrUuidOfConnection}" \ ### "${NameOrUuidOfConnection}"要加双引号,不加的话连接名称不能有空格
### nmcli connection modified 后接连接的名称或UUID, 等效 nmcli connection modified 等效 nmcli co mo 等效 nmcli c m ; 连接的名称或UUID可用 nmcli c 或 nmcli c s 或 nmcli connection show 查看
ipv4.method 'manual' \ ### 取值 manual手动(静态IP) | auto(自动获取IP) ; 当设为auto,又指定了ip时, 自动获取的IP将和手动制定的静态IP同时存在
ipv4.addresses "1.20.46.30/8 , 1.20.46.31/8,
1.20.46.32/8 ,1.20.46.33/8,1.20.46.34/8,1.20.46.35/8 ,1.2.3.4,5.6.7.8,1.2.3.4/6,5.6.7.8/6 , 192.168.3.3 , 192.168.3.3/8 ,
192.168.3.3/16 , 192.168.3.3/24 , 192.168.3.3/32 " \ ###设置ip, 完全覆盖原有内容, 可单可多,用逗号分隔,有空格要加单或双引号, ipv4.a等效ipv4.addr等效ipv4.address, 若不设置子掩,则子掩为32, 1.2.3.4等效1.2.3.4/32
+ipv4.ad 1.20.46.35/8,1.20.46.36/8,1.20.46.37/8,1.20.46.38/8,1.20.46.39/8,1.20.46.40/8 \ ###增加ip, 在原有内容上增加, 可单可多,用逗号分隔,如无空格可不加引号,+ipv4.ad等效+ipv4.addr等效+ipv4.address , ubuntu24 和 fedora40 的 ipv4.addresses 只能简写到 ipv4.ad , 不能简写到 ipv4.a
-ipv4.addr 1.20.46.30/8,1.20.46.37/8,1.20.46.39/8,1.20.46.40/8,1.20.46.41,1.20.46.42/8 \ ###删除ip, 可单可多,用逗号分隔,如无空格可不加引号, -ipv4.a等效-ipv4.addr等效-ipv4.address
ipv4.gateway "1.0.0.2" \ #### 网关
ipv4.ignore-auto-routes "no" \ ####
ipv4.ignore-auto-dns 'true' \ #### true或yes跳过自动DNS,手动指定DNS | no或false自动获取DNS
ipv4.dns "180.76.76.76 , 223.6.6.6 ,
119.29.29.29, 223.5.5.5 1.1.1.1,8.8.8.8,114.114.114.114 , 114.114.115.115" \ #### 设置DNS , 生成到 /etc/NetworkManager/system-connections 的配置文件中的DNS使用分号分隔的, 但这里是逗号分隔的, 这里用分号会报错
ipv4.dns-search 'baidu.com' ; \ #### 搜索域,可以省略.
sudo systemctl reload NetworkManager ; sudo systemctl restart NetworkManager ; #### 重启NetworkManager, 好像没效果, 要关闭再打开连接或重启系统,才生效
sudo nmcli c down "${NameOrUuidOfConnection}"; sudo nmcli c up "${NameOrUuidOfConnection}"; #### nmcli connection dowan 和 nmcli connection up 效果如同图形界面桌面右上角网络设置的开启和关闭
nmcli官方例子 nmcli-examples — usage examples of nmcli
---------------------------------------------------------------------------
ipv4.method: auto 可取 manual | auto
ipv4.dns:
ipv4.dns-search:
ipv4.addresses:
ipv4.gateway: --
ipv4.routes:
ipv4.route-metric: -1
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.never-default: no
ipv4.may-fail: yes
---------------------------------------------------------------------------
ipv6.method: auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.gateway: --
ipv6.routes:
ipv6.route-metric: -1
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.dhcp-hostname: --
---------------------------------------------------------------------------
---------------------------------------------------------------------------
ipv4.method: manual
ipv4.dns: 8.8.8.8,8.8.4.4
ipv4.dns-search:
ipv4.addresses: 192.168.1.100/24
ipv4.gateway: 192.168.1.1
ipv4.routes:
ipv4.route-metric: -1
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.never-default: no
ipv4.may-fail: yes
---------------------------------------------------------------------------
ipv6.method: auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.gateway: --
ipv6.routes:
ipv6.route-metric: -1
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.dhcp-hostname: --
---------------------------------------------------------------------------
nmcli connection edit ethernet-em1-2
edits existing "ethernet-em1-2" connection in the interactive editor.
nmcli connection edit type ethernet con-name "yet another Ethernet connection"
adds a new Ethernet connection in the interactive editor.
nmcli con mod ethernet-2 connection.autoconnect no
modifies 'autoconnect' property in the 'connection' setting of 'ethernet-2' connection.
nmcli con mod "Home Wi-Fi" wifi.mtu 1350
modifies 'mtu' property in the 'wifi' setting of 'Home Wi-Fi' connection.
nmcli con mod em1-1 ipv4.method manual ipv4.addr "192.168.1.23/24 192.168.1.1, 10.10.1.5/8, 10.0.0.11"
sets manual addressing and the addresses in em1-1 profile.
nmcli con modify ABC +ipv4.dns 8.8.8.8
appends a Google public DNS server to DNS servers in ABC profile.
nmcli con modify ABC -ipv4.addresses "192.168.100.25/24 192.168.1.1"
removes the specified IP address from (static) profile ABC.
nmcli-examplesnmcli-examples — usage examples of nmcli |
Synopsis
nmcli [OPTIONS...]
Description
nmcli is a command-line client for NetworkManager. It allows controlling NetworkManager and reporting its status. For more information please refer to nmcli(1) manual page.
The purpose of this manual page is to provide you with various examples and usage scenarios of nmcli.
Examples
Example 1. Listing available Wi-Fi APs
$ nmcli device wifi list * SSID MODE CHAN RATE SIGNAL BARS SECURITY netdatacomm_local Infra 6 54 Mbit/s 37 ▂▄__ WEP * F1 Infra 11 54 Mbit/s 98 ▂▄▆█ WPA1 LoremCorp Infra 1 54 Mbit/s 62 ▂▄▆_ WPA2 802.1X Internet Infra 6 54 Mbit/s 29 ▂___ WPA1 HPB110a.F2672A Ad-Hoc 6 54 Mbit/s 22 ▂___ -- Jozinet Infra 1 54 Mbit/s 19 ▂___ WEP VOIP Infra 1 54 Mbit/s 20 ▂___ WEP MARTINA Infra 4 54 Mbit/s 32 ▂▄__ WPA2 N24PU1 Infra 7 11 Mbit/s 22 ▂___ -- alfa Infra 1 54 Mbit/s 67 ▂▄▆_ WPA2 bertnet Infra 5 54 Mbit/s 20 ▂___ WPA1 WPA2nmcli device wifi list* SSID MODE CHAN RATE SIGNAL BARS SECURITY netdatacomm_local Infra 6 54 Mbit/s 37 ▂▄__ WEP * F1 Infra 11 54 Mbit/s 98 ▂▄▆█ WPA1 LoremCorp Infra 1 54 Mbit/s 62 ▂▄▆_ WPA2 802.1X Internet Infra 6 54 Mbit/s 29 ▂___ WPA1 HPB110a.F2672A Ad-Hoc 6 54 Mbit/s 22 ▂___ -- Jozinet Infra 1 54 Mbit/s 19 ▂___ WEP VOIP Infra 1 54 Mbit/s 20 ▂___ WEP MARTINA Infra 4 54 Mbit/s 32 ▂▄__ WPA2 N24PU1 Infra 7 11 Mbit/s 22 ▂___ -- alfa Infra 1 54 Mbit/s 67 ▂▄▆_ WPA2 bertnet Infra 5 54 Mbit/s 20 ▂___ WPA1 WPA2
This command shows how to list available Wi-Fi networks (APs). You can also use --fields option for displaying different columns. nmcli -f all dev wifi list will show all of them.
Example 2. Connect to a password-protected wifi network
$ nmcli device wifi connect "$SSID" password "$PASSWORD"nmcli device wifi connect "$SSID" password "$PASSWORD"
$ nmcli --ask device wifi connect "$SSID"nmcli --ask device wifi connect "$SSID"
Example 3. Showing general information and properties for a Wi-Fi interface
$ nmcli -p -f general,wifi-properties device show wlan0
===========================================================================
Device details (wlan0)
===========================================================================
GENERAL.DEVICE: wlan0
GENERAL.TYPE: wifi
GENERAL.VENDOR: Intel Corporation
GENERAL.PRODUCT: PRO/Wireless 5100 AGN [Shiloh] Network Connection
GENERAL.DRIVER: iwlwifi
GENERAL.DRIVER-VERSION: 3.8.13-100.fc17.x86_64
GENERAL.FIRMWARE-VERSION: 8.83.5.1 build 33692
GENERAL.HWADDR: 00:1E:65:37:A1:D3
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.REASON: 0 (No reason given)
GENERAL.UDI: /sys/devices/pci0000:00/0000:00:1c.1/net/wlan0
GENERAL.IP-IFACE: wlan0
GENERAL.IS-SOFTWARE: no
GENERAL.NM-MANAGED: yes
GENERAL.AUTOCONNECT: yes
GENERAL.FIRMWARE-MISSING: no
GENERAL.CONNECTION: My Alfa WiFi
GENERAL.CON-UUID: 85194f4c-d496-4eec-bae0-d880b4cbcf26
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/
10
---------------------------------------------------------------------------
WIFI-PROPERTIES.WEP: yes
WIFI-PROPERTIES.WPA: yes
WIFI-PROPERTIES.WPA2: yes
WIFI-PROPERTIES.TKIP: yes
WIFI-PROPERTIES.CCMP: yes
WIFI-PROPERTIES.AP: no
WIFI-PROPERTIES.ADHOC: yes
---------------------------------------------------------------------------nmcli -p -f general,wifi-properties device show wlan0
===========================================================================
Device details (wlan0)
===========================================================================
GENERAL.DEVICE: wlan0
GENERAL.TYPE: wifi
GENERAL.VENDOR: Intel Corporation
GENERAL.PRODUCT: PRO/Wireless 5100 AGN [Shiloh] Network Connection
GENERAL.DRIVER: iwlwifi
GENERAL.DRIVER-VERSION: 3.8.13-100.fc17.x86_64
GENERAL.FIRMWARE-VERSION: 8.83.5.1 build 33692
GENERAL.HWADDR: 00:1E:65:37:A1:D3
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.REASON: 0 (No reason given)
GENERAL.UDI: /sys/devices/pci0000:00/0000:00:1c.1/net/wlan0
GENERAL.IP-IFACE: wlan0
GENERAL.IS-SOFTWARE: no
GENERAL.NM-MANAGED: yes
GENERAL.AUTOCONNECT: yes
GENERAL.FIRMWARE-MISSING: no
GENERAL.CONNECTION: My Alfa WiFi
GENERAL.CON-UUID: 85194f4c-d496-4eec-bae0-d880b4cbcf26
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/
10
---------------------------------------------------------------------------
WIFI-PROPERTIES.WEP: yes
WIFI-PROPERTIES.WPA: yes
WIFI-PROPERTIES.WPA2: yes
WIFI-PROPERTIES.TKIP: yes
WIFI-PROPERTIES.CCMP: yes
WIFI-PROPERTIES.AP: no
WIFI-PROPERTIES.ADHOC: yes
---------------------------------------------------------------------------
This command shows information about a Wi-Fi device.
Example 4. Listing NetworkManager polkit permissions
$ nmcli general permissions
PERMISSION VALUE
org.freedesktop.NetworkManager.enable-disable-network yes
org.freedesktop.NetworkManager.enable-disable-wifi yes
org.freedesktop.NetworkManager.enable-disable-wwan yes
org.freedesktop.NetworkManager.enable-disable-wimax yes
org.freedesktop.NetworkManager.sleep-wake no
org.freedesktop.NetworkManager.network-control yes
org.freedesktop.NetworkManager.wifi.share.protected yes
org.freedesktop.NetworkManager.wifi.share.open yes
org.freedesktop.NetworkManager.settings.modify.system yes
org.freedesktop.NetworkManager.settings.modify.own yes
org.freedesktop.NetworkManager.settings.modify.hostname auth
org.freedesktop.NetworkManager.settings.modify.global-dns auth
org.freedesktop.NetworkManager.reload authnmcli general permissions
PERMISSION VALUE
org.freedesktop.NetworkManager.enable-disable-network yes
org.freedesktop.NetworkManager.enable-disable-wifi yes
org.freedesktop.NetworkManager.enable-disable-wwan yes
org.freedesktop.NetworkManager.enable-disable-wimax yes
org.freedesktop.NetworkManager.sleep-wake no
org.freedesktop.NetworkManager.network-control yes
org.freedesktop.NetworkManager.wifi.share.protected yes
org.freedesktop.NetworkManager.wifi.share.open yes
org.freedesktop.NetworkManager.settings.modify.system yes
org.freedesktop.NetworkManager.settings.modify.own yes
org.freedesktop.NetworkManager.settings.modify.hostname auth
org.freedesktop.NetworkManager.settings.modify.global-dns auth
org.freedesktop.NetworkManager.reload auth
This command shows configured polkit permissions for various NetworkManager operations. These permissions or actions (using polkit language) are configured by a system administrator and are not meant to be changed by users. The usual place for the polkit configuration is /usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy. pkaction command can display description for polkit actions.
pkaction --action-id org.freedesktop.NetworkManager.network-control --verbose
More information about polkit can be found at http://www.freedesktop.org/wiki/Software/polkit.
Example 5. Listing NetworkManager log level and domains
$ nmcli general logging
LEVEL DOMAINS
INFO PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,WIFI_SCAN,IP4,IP6,A
UTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,
WIMAX,INFINIBAND,FIREWALL,ADSL,BOND,VLAN,BRIDGE,DBUS_PROPS,TEAM,CONCHECK,DC
B,DISPATCHnmcli general logging
LEVEL DOMAINS
INFO PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,WIFI_SCAN,IP4,IP6,A
UTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,
WIMAX,INFINIBAND,FIREWALL,ADSL,BOND,VLAN,BRIDGE,DBUS_PROPS,TEAM,CONCHECK,DC
B,DISPATCH
This command shows current NetworkManager logging status.
Example 6. Changing NetworkManager logging
$ nmcli g log level DEBUG domains CORE,ETHER,IP
$ nmcli g log level INFO domains DEFAULTnmcli g log level DEBUG domains CORE,ETHER,IP
$ nmcli g log level DEBUG domains CORE,ETHER,IP
$ nmcli g log level INFO domains DEFAULTnmcli g log level DEBUG domains CORE,ETHER,IP
$ nmcli g log level INFO domains DEFAULTnmcli g log level INFO domains DEFAULT
The first command makes NetworkManager log in DEBUG level, and only for CORE, ETHER and IP domains. The second command restores the default logging state. Please refer to the NetworkManager.conf(5) manual page for available logging levels and domains.
Example 7. Activating a VPN connection profile requiring interactive password input
$ nmcli --ask con up my-vpn-connmcli --ask con up my-vpn-con
This command activates a VPN connection profile enabling nmcli to interact with the user ('--ask'): this will allow nmcli to prompt for the VPN password on the command line when the password-flags are set to '0x02' ('always ask', see nm-settings-nmcli(5) ). This is particularly useful for OTP based VPNs, as the user needs to be prompted for the password each time the connection is activated.
Example 8. Adding a bonding master and two slave connection profiles
$ nmcli con add type bond ifname mybond0 mode active-backup
$ nmcli con add type ethernet ifname eth1 master mybond0
$ nmcli con add type ethernet ifname eth2 master mybond0nmcli con add type bond ifname mybond0 mode active-backup
$ nmcli con add type bond ifname mybond0 mode active-backup
$ nmcli con add type ethernet ifname eth1 master mybond0
$ nmcli con add type ethernet ifname eth2 master mybond0nmcli con add type bond ifname mybond0 mode active-backup
$ nmcli con add type ethernet ifname eth1 master mybond0
$ nmcli con add type ethernet ifname eth2 master mybond0nmcli con add type ethernet ifname eth1 master mybond0
$ nmcli con add type bond ifname mybond0 mode active-backup
$ nmcli con add type ethernet ifname eth1 master mybond0
$ nmcli con add type ethernet ifname eth2 master mybond0nmcli con add type bond ifname mybond0 mode active-backup
$ nmcli con add type bond ifname mybond0 mode active-backup
$ nmcli con add type ethernet ifname eth1 master mybond0
$ nmcli con add type ethernet ifname eth2 master mybond0nmcli con add type bond ifname mybond0 mode active-backup
$ nmcli con add type ethernet ifname eth1 master mybond0
$ nmcli con add type ethernet ifname eth2 master mybond0nmcli con add type ethernet ifname eth1 master mybond0
$ nmcli con add type ethernet ifname eth2 master mybond0nmcli con add type ethernet ifname eth2 master mybond0
This example demonstrates adding a bond master connection and two slaves. The first command adds a master bond connection, naming the bonding interface mybond0 and using active-backup mode. The next two commands add slaves connections, both enslaved to mybond0. The first slave will be bound to eth1 interface, the second to eth2.
Example 9. Adding a team master and two slave connection profiles
$ nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
$ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1
$ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
$ nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
$ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1
$ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
$ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1
$ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1
$ nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
$ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1
$ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
$ nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
$ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1
$ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
$ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1
$ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1nmcli con add type ethernet con-name Team1-slave1 ifname em1 master Team1
$ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1nmcli con add type ethernet con-name Team1-slave2 ifname em2 master Team1
This example demonstrates adding a team master connection profile and two slaves. It is very similar to the bonding example. The first command adds a master team profile, naming the team interface and the profile Team1. The team configuration for the master is read from team1-master-json.conf file. Later, you can change the configuration with modify command (nmcli con modify Team1 team.config team1-master-another-json.conf). The last two commands add slaves profiles, both enslaved to Team1. The first slave will be bound to the em1 interface, the second to em2. The slaves don't specify config and thus teamd will use its default configuration. You will activate the whole setup by activating both slaves:
$ nmcli con up Team1-slave1
$ nmcli con up Team1-slave2nmcli con up Team1-slave1
$ nmcli con up Team1-slave1
$ nmcli con up Team1-slave2nmcli con up Team1-slave1
$ nmcli con up Team1-slave2nmcli con up Team1-slave2
By default, the created profiles are marked for auto-activation. But if another connection has been activated on the device, the new profile won't activate automatically and you need to activate it manually.
Example 10. Adding a bridge and two slave profiles
$ nmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type bridge con-name TowerBridge ifname TowerBridge
$ nmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type ethernet con-name br-slave-1 ifname ens3 master TowerBridge
$ nmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con add type ethernet con-name br-slave-2 ifname ens4 master TowerBridge
$ nmcli con modify TowerBridge bridge.stp nonmcli con modify TowerBridge bridge.stp no
This example demonstrates adding a bridge master connection and two slaves. The first command adds a master bridge connection, naming the bridge interface and the profile as TowerBridge. The next two commands add slaves profiles, both will be enslaved to TowerBridge. The first slave will be tied to ens3 interface, the second to ens4. The last command will disable 802.1D STP for the TowerBridge profile.
Example 11. Adding an ethernet connection profile with manual IP configuration
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con add con-name my-con-em1 ifname em1 type ethernet \
ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
$ nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 ipv4.dns "8.8.8.8 8.8.4.4"
$ nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 +ipv4.dns 1.2.3.4
$ nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli con mod my-con-em1 ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
$ nmcli -p con show my-con-em1nmcli -p con show my-con-em1
The first command adds an Ethernet connection profile named my-con-em1 that is bound to interface name em1. The profile is configured with static IP addresses. Three addresses are added, two IPv4 addresses and one IPv6. The first IP 192.168.100.100 has a prefix of 24 (netmask equivalent of 255.255.255.0). Gateway entry will become the default route if this profile is activated on em1 interface (and there is no connection with higher priority). The next two addresses do not specify a prefix, so a default prefix will be used, i.e. 32 for IPv4 and 128 for IPv6. The second, third and fourth commands modify DNS parameters of the new connection profile. The last con show command displays the profile so that all parameters can be reviewed.
Example 12. Convenient field values retrieval for scripting
$ nmcli -g ip4.address connection show my-con-eth0
192.168.1.12/24nmcli -g ip4.address connection show my-con-eth0
192.168.1.12/24
$ nmcli -g ip4.address,ip4.dns connection show my-con-eth0
192.168.1.12/24
192.168.1.1nmcli -g ip4.address,ip4.dns connection show my-con-eth0
192.168.1.12/24
192.168.1.1
$ nmcli -g ip4 connection show my-con-eth0
IP4:192.168.1.12/24:192.168.1.1::192.168.1.1::nmcli -g ip4 connection show my-con-eth0
IP4:192.168.1.12/24:192.168.1.1::192.168.1.1::
This example shows retrieval of ip4 connection field values via the --get-values option. Multiple comma separated fields can be provided: they will be printed one per line. If a whole section is provided instead of a single field, the name of the section will be printed followed by all the related field values on the same line. See also --terse, --mode, --fields and --escape options in nmcli(1) manual page for more customized output.
Example 13. Adding an Ethernet connection and configuring SR-IOV VFs
$ nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con add type ethernet con-name EthernetPF ifname em1
$ nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
$ nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
$ nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'nmcli con modify EthernetPF +sriov.vfs '2 max-tx-rate=20'
This example demonstrates adding an Ethernet connection for physical function (PF) ens4 and configuring 3 SR-IOV virtual functions (VFs) on it. The first VF is configured with MAC address 00:11:22:33:44:55 and VLAN 10, the second one has the trust and spoof-check features respectively enabled and disabled. VF number 2 has a maximum transmission rate of 20Mbps. The kernel is instructed to not automatically instantiate a network interface for the VFs.
Example 14. Escaping colon characters in tabular mode
$ nmcli -t -f general -e yes -m tab dev show eth0
GENERAL:eth0:ethernet:Intel Corporation:82567LM Gigabit Network Connection:
e1000e:2.1.4-k:1.8-3:00\:22\:68\:15\:29\:21:1500:100 (connected):0 (No reas
on given):/sys/devices/pci0000\:00/0000\:00\:19.0/net/eth0:eth0:yes:yes:no:
ethernet-13:89cbcbc6-dc85-456c-9c8b-bd828fee3917:/org/freedesktop/NetworkMa
nager/ActiveConnection/9nmcli -t -f general -e yes -m tab dev show eth0
GENERAL:eth0:ethernet:Intel Corporation:82567LM Gigabit Network Connection:
e1000e:2.1.4-k:1.8-3:00\:22\:68\:15\:29\:21:1500:100 (connected):0 (No reas
on given):/sys/devices/pci0000\:00/0000\:00\:19.0/net/eth0:eth0:yes:yes:no:
ethernet-13:89cbcbc6-dc85-456c-9c8b-bd828fee3917:/org/freedesktop/NetworkMa
nager/ActiveConnection/9
This example shows escaping colon characters in tabular mode. It may be useful for script processing, because ':' is used as a field separator.
Example 15. nmcli usage in a NetworkManager dispatcher script to make Ethernet and Wi-Fi mutually exclusive
#!/bin/bash export LC_ALL=Cenable_disable_wifi () { result=result" ]; then nmcli radio wifi off else nmcli radio wifi on fi }
if [ "$2" = "up" ]; then enable_disable_wifi fi
if [ "$2" = "down" ]; then enable_disable_wifi fi
This dispatcher script makes Wi-Fi mutually exclusive with wired networking. When a wired interface is connected, Wi-Fi will be set to airplane mode (rfkilled). When the wired interface is disconnected, Wi-Fi will be turned back on. Name this script e.g. 70-wifi-wired-exclusive.sh and put it into /etc/NetworkManager/dispatcher.d/ directory. See NetworkManager(8) manual page for more information about NetworkManager dispatcher scripts.
Example sessions of interactive connection editor
Example 16. Adding an ethernet connection profile in interactive editor (a)
$ nmcli connection edit type ethernet
===| nmcli interactive connection editor |===
Adding a new '802-3-ethernet' connection
Type 'help' or '?' for available commands.
Type 'describe [<setting>.<prop>]' for detailed property description.
You may edit the following settings: connection, 802-3-ethernet (ethernet),
802-1x, ipv4, ipv6, dcb
nmcli> print
Connection details
===========================================================================
connection.id: ethernet-4
connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
connection.interface-name: --
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.timestamp: 0
connection.read-only: no
connection.permissions:
connection.zone: --
connection.master: --
connection.slave-type: --
connection.secondaries:
connection.gateway-ping-timeout: 0
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: yes
802-3-ethernet.mac-address: --
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu: auto
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options:
ipv4.method: auto
ipv4.dns:
ipv4.dns-search:
ipv4.addresses:
ipv4.gateway: --
ipv4.routes:
ipv4.route-metric: -1
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv6.method: auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.gateway: --
ipv6.routes:
ipv6.route-metric: -1
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.dhcp-hostname: --
nmcli> goto ethernet
You may edit the following properties: port, speed, duplex, auto-negotiate,
mac-address, cloned-mac-address, mac-address-blacklist, mtu, s390-subchann
els, s390-nettype, s390-options
nmcli 802-3-ethernet> set mtu 1492
nmcli 802-3-ethernet> b
nmcli> goto ipv4.addresses
nmcli ipv4.addresses> desc
=== [addresses] ===
[NM property description]
Array of IP addresses.
[nmcli specific description]
Enter a list of IPv4 addresses formatted as:
ip[/prefix], ip[/prefix],...
Missing prefix is regarded as prefix of 32.
Example: 192.168.1.5/24, 10.0.0.11/24
nmcli ipv4.addresses> set 192.168.1.100/24
Do you also want to set 'ipv4.method' to 'manual'? [yes]: yes
nmcli ipv4.addresses>
nmcli ipv4.addresses> print
addresses: 192.168.1.100/24
nmcli ipv4.addresses> back
nmcli ipv4> b
nmcli> set ipv4.gateway 192.168.1.1
nmcli> verify
Verify connection: OK
nmcli> print
Connection details
===========================================================================
connection.id: ethernet-4
connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
connection.interface-name: --
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.timestamp: 0
connection.read-only: no
connection.permissions:
connection.zone: --
connection.master: --
connection.slave-type: --
connection.secondaries:
connection.gateway-ping-timeout: 0
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: yes
802-3-ethernet.mac-address: --
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu: 1492
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options:
ipv4.method: manual
ipv4.dns:
ipv4.dns-search:
ipv4.addresses: 192.168.1.100/24
ipv4.gateway: 192.168.1.1
ipv4.routes:
ipv4.route-metric: -1
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv6.method: auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.routes:
ipv6.route-metric: -1
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.dhcp-hostname: --
nmcli> set ipv4.dns 8.8.8.8 8.8.4.4
nmcli> print
Connection details
===========================================================================
connection.id: ethernet-4
connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
connection.interface-name: --
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.timestamp: 0
connection.read-only: no
connection.permissions:
connection.zone: --
connection.master: --
connection.slave-type: --
connection.secondaries:
connection.gateway-ping-timeout: 0
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: yes
802-3-ethernet.mac-address: --
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu: 1492
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options:
ipv4.method: manual
ipv4.dns: 8.8.8.8,8.8.4.4
ipv4.dns-search:
ipv4.addresses: 192.168.1.100/24
ipv4.gateway: 192.168.1.1
ipv4.routes:
ipv4.route-metric: -1
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv6.method: auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.gateway: --
ipv6.routes:
ipv6.route-metric: -1
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.dhcp-hostname: --
nmcli> verify
Verify connection: OK
nmcli> save
Connection 'ethernet-4' (de89cdeb-a3e1-4d53-8fa0-c22546c775f4) successfully
saved.
nmcli> quitnmcli connection edit type ethernet
===| nmcli interactive connection editor |===
Adding a new '802-3-ethernet' connection
Type 'help' or '?' for available commands.
Type 'describe [<setting>.<prop>]' for detailed property description.
You may edit the following settings: connection, 802-3-ethernet (ethernet),
802-1x, ipv4, ipv6, dcb
nmcli> print
Connection details
===========================================================================
connection.id: ethernet-4
connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
connection.interface-name: --
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.timestamp: 0
connection.read-only: no
connection.permissions:
connection.zone: --
connection.master: --
connection.slave-type: --
connection.secondaries:
connection.gateway-ping-timeout: 0
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: yes
802-3-ethernet.mac-address: --
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu: auto
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options:
ipv4.method: auto
ipv4.dns:
ipv4.dns-search:
ipv4.addresses:
ipv4.gateway: --
ipv4.routes:
ipv4.route-metric: -1
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv6.method: auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.gateway: --
ipv6.routes:
ipv6.route-metric: -1
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.dhcp-hostname: --
nmcli> goto ethernet
You may edit the following properties: port, speed, duplex, auto-negotiate,
mac-address, cloned-mac-address, mac-address-blacklist, mtu, s390-subchann
els, s390-nettype, s390-options
nmcli 802-3-ethernet> set mtu 1492
nmcli 802-3-ethernet> b
nmcli> goto ipv4.addresses
nmcli ipv4.addresses> desc
=== [addresses] ===
[NM property description]
Array of IP addresses.
[nmcli specific description]
Enter a list of IPv4 addresses formatted as:
ip[/prefix], ip[/prefix],...
Missing prefix is regarded as prefix of 32.
Example: 192.168.1.5/24, 10.0.0.11/24
nmcli ipv4.addresses> set 192.168.1.100/24
Do you also want to set 'ipv4.method' to 'manual'? [yes]: yes
nmcli ipv4.addresses>
nmcli ipv4.addresses> print
addresses: 192.168.1.100/24
nmcli ipv4.addresses> back
nmcli ipv4> b
nmcli> set ipv4.gateway 192.168.1.1
nmcli> verify
Verify connection: OK
nmcli> print
Connection details
===========================================================================
connection.id: ethernet-4
connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
connection.interface-name: --
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.timestamp: 0
connection.read-only: no
connection.permissions:
connection.zone: --
connection.master: --
connection.slave-type: --
connection.secondaries:
connection.gateway-ping-timeout: 0
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: yes
802-3-ethernet.mac-address: --
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu: 1492
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options:
ipv4.method: manual
ipv4.dns:
ipv4.dns-search:
ipv4.addresses: 192.168.1.100/24
ipv4.gateway: 192.168.1.1
ipv4.routes:
ipv4.route-metric: -1
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv6.method: auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.routes:
ipv6.route-metric: -1
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.dhcp-hostname: --
nmcli> set ipv4.dns 8.8.8.8 8.8.4.4
nmcli> print
Connection details
===========================================================================
connection.id: ethernet-4
connection.uuid: de89cdeb-a3e1-4d53-8fa0-c22546c775f4
connection.interface-name: --
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.timestamp: 0
connection.read-only: no
connection.permissions:
connection.zone: --
connection.master: --
connection.slave-type: --
connection.secondaries:
connection.gateway-ping-timeout: 0
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: yes
802-3-ethernet.mac-address: --
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu: 1492
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options:
ipv4.method: manual
ipv4.dns: 8.8.8.8,8.8.4.4
ipv4.dns-search:
ipv4.addresses: 192.168.1.100/24
ipv4.gateway: 192.168.1.1
ipv4.routes:
ipv4.route-metric: -1
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv6.method: auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.gateway: --
ipv6.routes:
ipv6.route-metric: -1
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.dhcp-hostname: --
nmcli> verify
Verify connection: OK
nmcli> save
Connection 'ethernet-4' (de89cdeb-a3e1-4d53-8fa0-c22546c775f4) successfully
saved.
nmcli> quit
Example session in the nmcli interactive connection editor. The scenario creates an Ethernet connection profile with static addressing (IPs and DNS).
Example 17. Bluetooth connection profiles
NetworkManger supports both connecting to NAP and DUN devices as a client. It also supports sharing the network via a NAP server.
For NAP client connections, NetworkManager automatically creates a suitable in-memory profile for paired devices if none is available. You may use that generated profile directly, but you may also modify and persist it, which will prevent to automatically re-create it. You may also create a profile from scratch. For example, the following uses DHCP and IPv6 autoconf for address configuration:
$ nmcli connection add type bluetooth con-name "Profile for My Bluetooth Device (NAP)" autoconnect no bluetooth.type panu bluetooth.bdaddr "$BDADDR"nmcli connection add type bluetooth con-name "Profile for My Bluetooth Device (NAP)" autoconnect no bluetooth.type panu bluetooth.bdaddr "$BDADDR"
For DUN connections, the user needs to configure modem settings and hence no profile gets created automatically. The modem settings depend on your device and you either need a "gsm" or a "csma" section. For example,
$ nmcli connection add type bluetooth con-name "Profile for My Bluetooth Device (DUN)" autoconnect no bluetooth.type dun bluetooth.bdaddr "$BDADDR" gsm.apn apn.comnmcli connection add type bluetooth con-name "Profile for My Bluetooth Device (DUN)" autoconnect no bluetooth.type dun bluetooth.bdaddr "$BDADDR" gsm.apn apn.com
Finally, you can create a bluetooth hotspot. BlueZ implements those as a bridge device, so such profiles also have a bridge section. Also, you probably want to set IP methods as "shared", so that clients get automatic IP addressing. Note that the "shared" IPv4 method requires dnsmasq to be available.
$ nmcli connection add type bluetooth con-name "My Bluetooth Hotspot" autoconnect no ifname btnap0 bluetooth.type nap ipv4.method shared ipv6.method sharednmcli connection add type bluetooth con-name "My Bluetooth Hotspot" autoconnect no ifname btnap0 bluetooth.type nap ipv4.method shared ipv6.method shared
Example 18. Offline use
$ nmcli --offline con add type ethernet '
conn.id eth0 \
conn.interface-name eth0 \
>/sysroot/etc/NetworkManager/system-connections/eth0.nmconnectionnmcli --offline con add type ethernet '
conn.id eth0 \
conn.interface-name eth0 \
>/sysroot/etc/NetworkManager/system-connections/eth0.nmconnection
Creates a connection file in keyfile format without using the NetworkManager service. This allows for use of familiar nmcli syntax in situations where the service is not running, such as during system installation of image provisioning and ensures the resulting file is correctly formatted.
$ nmcli --offline con modify type ethernet '
conn.id eth0-ipv6 \
ipv4.method disabled \
</sysroot/etc/NetworkManager/system-connections/eth0.nmconnection \
>/sysroot/etc/NetworkManager/system-connections/eth0-ipv6.nmconnectionnmcli --offline con modify type ethernet '
conn.id eth0-ipv6 \
ipv4.method disabled \
</sysroot/etc/NetworkManager/system-connections/eth0.nmconnection \
>/sysroot/etc/NetworkManager/system-connections/eth0-ipv6.nmconnection
Read and write a connection file without using the NetworkManager service, modifying some properties along the way.
This allows templating of the connection profiles using familiar nmcli syntax in situations where the service is not running.
Example 19. Device Checkpoint and Restore
$ nmcli dev checkpoint eth0 -- nmcli dev dis eth0
Device 'eth0' successfully disconnected.
Type "Yes" to commit the changes: No
Checkpoint was removed.nmcli dev checkpoint eth0 -- nmcli dev dis eth0
Device 'eth0' successfully disconnected.
Type "Yes" to commit the changes: No
Checkpoint was removed.
In this example the device eth0 was disconnected with the eth0 checkpoint taken. The user didn't confirm that the change is good, so the eth0 was brought back to the state it was when the checkpoint was taken.
If the command being run unintentionaly brings down the remote connection (such as a ssh(1) session) to the very machine it's being run on, the user wouldn't be able to confirm the success and the connectivity would end up being restored after a timeout.
If, on the other hand, the command results in a success, the user could just confirm, causing the checkpoint to be abandoned without a rollback:
$ nmcli dev checkpoint -- ip link del br0
Type "Yes" to commit the changes: Yesnmcli dev checkpoint -- ip link del br0
Type "Yes" to commit the changes: Yes
See Also
nmcli(1), NetworkManager(8), NetworkManager.conf(5), nm-settings-nmcli(5), nm-online(1), nm-applet(1), nm-connection-editor(1)