nmcli的基本使用

介紹NetworkManager、centos8、nmcli

CentOS 7中同時支援network.service和NetworkManager.service(簡稱NM)2種方式配置網路,而在CentOS 8中已經廢棄network.service,必須通過NetworkManager.service配置網路。

nmcli是用於控制NetworkManager和報告網路狀態的命令行工具。它可以用來替代nm-applet或其他圖形客戶機。nmcli用於創建、顯示、編輯、刪除、激活和停用網路連接,以及控制和顯示網路設備狀態。

nmcli語法及常用選項

Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

OPTIONS
  -a, --ask                                ask for missing parameters              ## 使用此選項時,nmcli將停止並請求任何缺少的必需參數,因此不要將此選項用於腳本等非交互目的。例如,此選項控制在連接到網路時是否需要輸入密碼。
  -c, --colors auto|yes|no                 whether to use colors in output         ## 高亮顯示結果到標準輸出
  -e, --escape yes|no                      escape columns separators in values     ## 指定欄位分隔符
  -f, --fields <field,...>|all|common      specify fields to output                ## 指定顯示的欄位
  -g, --get-values <field,...>|all|common  shortcut for -m tabular -t -f           ## 過濾欄位,適用於腳本-m, --mode tabular|multiline             output mode                             ## 指定輸出格式。tabular以表格形式顯示。multiline多行顯示-p, --pretty                             pretty output                           ## 優雅的展示結果-t, --terse                              terse output                            ## 簡潔輸出-w, --wait <seconds>                     set timeout waiting for finishing operations  ## 指定超時時間

OBJECT
  g[eneral]       NetworkManager's general status and operations
  n[etworking]    overall networking control
  r[adio]         NetworkManager radio switches
  c[onnection]    NetworkManager's connections
  d[evice]        devices managed by NetworkManager
  a[gent]         NetworkManager secret agent or polkit agent
  m[onitor]       monitor NetworkManager changes

-a

-f 以指定欄位顯示網卡資訊

可用欄位GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS。不區分大小寫

[root@test ~]# nmcli -p -f ip4,ip6,general,wifi-properties device show eth0
===============================================================================
                             Device details (eth0)
===============================================================================
IP4.ADDRESS[1]:                         172.17.201.88/20
IP4.GATEWAY:                            172.17.207.253
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 172.17.207.253, mt = 100
IP4.ROUTE[2]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.DNS[1]:                             100.100.2.136
IP4.DNS[2]:                             100.100.2.138
-------------------------------------------------------------------------------
IP6.ADDRESS[1]:                         fe80::216:3eff:fe0e:4531/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 256
IP6.ROUTE[2]:                           dst = ff00::/8, nh = ::, mt = 256, table=255
-------------------------------------------------------------------------------
GENERAL.DEVICE:                         eth0
GENERAL.TYPE:                           ethernet
GENERAL.NM-TYPE:                        NMDeviceEthernet
GENERAL.VENDOR:                         Red Hat, Inc.
GENERAL.PRODUCT:                        Virtio network device
GENERAL.DRIVER:                         virtio_net
GENERAL.DRIVER-VERSION:                 1.0.0
GENERAL.FIRMWARE-VERSION:               --
GENERAL.HWADDR:                         00:16:3E:0E:45:31
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.REASON:                         0 (No reason given)
GENERAL.IP4-CONNECTIVITY:               4 (full)
GENERAL.IP6-CONNECTIVITY:               4 (full)
GENERAL.UDI:                            /sys/devices/pci0000:00/0000:00:05.0/virtio2/net/eth0
GENERAL.IP-IFACE:                       eth0
GENERAL.IS-SOFTWARE:                    no
GENERAL.NM-MANAGED:                     yes
GENERAL.AUTOCONNECT:                    yes
GENERAL.FIRMWARE-MISSING:               no
GENERAL.NM-PLUGIN-MISSING:              no
GENERAL.PHYS-PORT-ID:                   --
GENERAL.CONNECTION:                     System eth0
GENERAL.CON-UUID:                       5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/1
GENERAL.METERED:                        no (guessed)
-------------------------------------------------------------------------------

 

常用的object

g[eneral] 常規選項

語法:nmcli general {status | hostname | permissions | logging} [ARGUMENTS…]

使用此命令可以顯示NetworkManager的狀態和許可權。也可以獲取和更改系統主機名,以及NetworkManager的日誌級別和域。包含4個命令,即status、hostname、permissions、logging

status

顯示NetworkManager的狀態,這是默認選項

[root@test ~]# nmcli general status
STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN    
connected  full          enabled  enabled  enabled  enabled
 
[root@test ~]# nmcli g status
STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN    
connected  full          enabled  enabled  enabled  enabled 

[root@test ~]# nmcli g 
STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN    
connected  full          enabled  enabled  enabled  enabled 

hostname

預設時,通過讀取/etc/hostname文件獲取當前主機的主機名。

[root@test ~]# cat /etc/hostname
test

[root@test ~]# nmcli general hostname 
test

當指定新的主機名時,NetworkManager會設置一個新的主機名,從而修改/etc/hostname文件

[root@test ~]# nmcli general hostname  hehe

[root@test ~]# nmcli general hostname 
hehe

[root@test ~]# cat /etc/hostname
hehe

permissions

顯示當前用戶對NetworkManager的操作許可權。 如啟用和禁用網路、更改WI-FI和WWAN狀態、修改連接等

[root@test ~]# nmcli g 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                         yes     
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           yes     
org.freedesktop.NetworkManager.settings.modify.global-dns         yes     
org.freedesktop.NetworkManager.reload                             yes     
org.freedesktop.NetworkManager.checkpoint-rollback                yes     
org.freedesktop.NetworkManager.enable-disable-statistics          yes     
org.freedesktop.NetworkManager.enable-disable-connectivity-check  yes     
org.freedesktop.NetworkManager.wifi.scan                          unknown 

logging

獲取和更改NetworkManager日誌記錄級別和域,沒有任何參數當前日誌記錄級別和域顯示

[root@test ~]# nmcli -m multiline  g logging 
LEVEL:                                  INFO
DOMAINS:                                PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,INFINIBAND,FIREWALL,ADSL,BOND,VLAN,BRIDGE,TEAM,CONCHECK,DCB,DISPATCH,AUDIT,SYSTEMD,PROXY

n[etworking] 網路控制

語法:nmcli networking {on | off | connectivity} [ARGUMENTS…]

查詢NetworkManager的網路狀態,開啟和關閉網路。有三個命令:

on:開啟所有網路介面

off:關閉所有網路介面

connectivity:獲取網路狀態。check參數告訴NetworkManager重新檢測網路連接性,否則將顯示最近感知的網路狀態,並且不重新檢測

  • none :主機未連接到任何網路
  • portal:主機在一個被捕獲的入口之後並且無法訪問整個互聯網路。
  • limited:主機已經連接到網路,但是無法訪問互聯網
  • full:主機已經連接到網路,並且可以訪問互聯網
  • unknown:未知狀態
[root@hehe ~]# uname -a
Linux hehe 4.18.0-147.5.1.el8_1.x86_64 

[root@hehe ~]# nmcli n               ## 這時,無法遠程連接
disabled

[root@hehe ~]# nmcli n on

[root@hehe ~]# nmcli n 
enabled
[root@hehe ~]# nmcli n connectivity check
full
[root@hehe ~]# nmcli n connectivity 
full

r[adio] 無線限傳輸控制

語法:nmcli radio {all | wifi | wwan} [ARGUMENTS…]

顯示無線交換機開關狀態,或開啟和關閉交換機

[root@hehe ~]# nmcli g
STATE      CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN    
connected  full          enabled  enabled  enabled  enabled 
[root@hehe ~]# nmcli r
WIFI-HW  WIFI     WWAN-HW  WWAN    
enabled  enabled  enabled  enabled 
[root@hehe ~]# nmcli r all off
[root@hehe ~]# ping baidu.com
PING baidu.com (39.156.69.79) 56(84) bytes of data.
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=1 ttl=52 time=5.38 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=2 ttl=52 time=5.24 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=3 ttl=52 time=5.25 ms
^C
--- baidu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 4ms
rtt min/avg/max/mdev = 5.238/5.291/5.382/0.087 ms
[root@hehe ~]# nmcli r 
WIFI-HW  WIFI      WWAN-HW  WWAN     
enabled  disabled  enabled  disabled 

connection 連接管理

語法: nmcli connection {show | up | down | modify | add | edit | clone | delete | monitor | reload | load | import | export} [ARGUMENTS…]

命令參數:

show 有兩種用法

1、查看活動的連接,也可以進行排序(+-為升降序)默認為升序

[root@hehe ~]# nmcli c s 
NAME         UUID                                  TYPE      DEVICE 
System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  ethernet  eth0 

[root@hehe ~]# nmcli c s --order -active
NAME         UUID                                  TYPE      DEVICE 
System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  ethernet  eth0

 將所有連接按類型排序

[root@hehe ~]# nmcli c show --order -type
NAME         UUID                                  TYPE      DEVICE 
System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  ethernet  eth0   

add

添加一個新的連接,需要指定新創建連接的屬性,語法與modify相同。

  • con-name連接名稱
  • type:網路類型
  • autoconnect:自動連接
  • ifname:連接到的設備名
[root@hehe ~]# nmcli c add con-name eth2 type ethernet autoconnect yes ifname eth2
Connection 'eth2' (dd7e45de-6910-4a7b-88c0-be1ed28b23ae) successfully added.
[root@hehe
~]# nmcli c s NAME UUID TYPE DEVICE eth1 69609727-cbbf-479d-ae87-a76256c520b9 ethernet eth0 eth2 dd7e45de-6910-4a7b-88c0-be1ed28b23ae ethernet -- System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet --

modify

更改的屬性可以使用nmcli connection show 設備名 進行獲取,然後進行修改、添加或刪除屬性,如果要設置屬性,只需指定屬性名稱和值,空值將刪除屬性,同一屬性使用+添加,- 刪除

添加多個ip

[root@hehe ~]# nmcli connection modify eth1 +ipv4.addresses 172.16.100.7/24
[root@hehe ~]# nmcli connection modify eth1 +ipv4.addresses 192.168.50.7/24

[root@hehe ~]# nmcli -f IP4 connection show eth1
IP4.ADDRESS[1]:                         172.17.203.6/20
IP4.ADDRESS[2]:                         172.17.201.88/20
IP4.GATEWAY:                            172.17.207.253
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 172.17.207.253, mt = 100
IP4.ROUTE[2]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.ROUTE[3]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.DNS[1]:                             100.100.2.136
IP4.DNS[2]:                             100.100.2.138

[root@hehe ~]# nmcli connection up eth1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)

[root@hehe ~]# nmcli -f IP4 connection show eth1
IP4.ADDRESS[1]:                         172.16.100.7/24
IP4.ADDRESS[2]:                         172.17.203.6/20
IP4.ADDRESS[3]:                         192.168.50.7/24
IP4.ADDRESS[4]:                         172.17.201.88/20
IP4.GATEWAY:                            172.17.207.253
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 172.17.207.253, mt = 100
IP4.ROUTE[2]:                           dst = 172.16.100.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[3]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.ROUTE[4]:                           dst = 192.168.50.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[5]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.DNS[1]:                             100.100.2.136
IP4.DNS[2]:                             100.100.2.138

刪除指定的IP

[root@hehe ~]# nmcli -f IP4 connection show eth1
IP4.ADDRESS[1]:                         172.16.100.7/24
IP4.ADDRESS[2]:                         172.17.203.6/20
IP4.ADDRESS[3]:                         192.168.50.7/24
IP4.ADDRESS[4]:                         172.17.201.88/20
IP4.GATEWAY:                            172.17.207.253
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 172.17.207.253, mt = 100
IP4.ROUTE[2]:                           dst = 172.16.100.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[3]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.ROUTE[4]:                           dst = 192.168.50.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[5]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.DNS[1]:                             100.100.2.136
IP4.DNS[2]:                             100.100.2.138

刪除索引為2的資訊 [root@hehe
~]# nmcli connection modify eth1 -ipv4.addresses 2
查看刪除後的路由 [root@hehe
~]# nmcli -f IP4 c show eth1 IP4.ADDRESS[1]: 172.16.100.7/24 IP4.ADDRESS[2]: 172.17.203.6/20 IP4.ADDRESS[3]: 192.168.50.7/24 IP4.ADDRESS[4]: 172.17.201.88/20 IP4.GATEWAY: 172.17.207.253 IP4.ROUTE[1]: dst = 0.0.0.0/0, nh = 172.17.207.253, mt = 100 IP4.ROUTE[2]: dst = 172.16.100.0/24, nh = 0.0.0.0, mt = 100 IP4.ROUTE[3]: dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100 IP4.ROUTE[4]: dst = 192.168.50.0/24, nh = 0.0.0.0, mt = 100 IP4.ROUTE[5]: dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100 IP4.DNS[1]: 100.100.2.136 IP4.DNS[2]: 100.100.2.138
激活網卡 [root@hehe
~]# nmcli c u eth1 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)

再次查看 [root@hehe
~]# nmcli -f IP4 c show eth1 IP4.ADDRESS[1]: 172.16.100.7/24 IP4.ADDRESS[2]: 172.17.203.6/20 IP4.ADDRESS[3]: 172.17.201.88/20 IP4.GATEWAY: 172.17.207.253 IP4.ROUTE[1]: dst = 0.0.0.0/0, nh = 172.17.207.253, mt = 100 IP4.ROUTE[2]: dst = 172.16.100.0/24, nh = 0.0.0.0, mt = 100 IP4.ROUTE[3]: dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100 IP4.ROUTE[4]: dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100 IP4.DNS[1]: 100.100.2.136 IP4.DNS[2]: 100.100.2.138

delete刪除連接

[root@hehe ~]# nmcli c delete System\ eth0 
Connection 'System eth0' (5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03) successfully deleted.
[root@hehe ~]# nmcli c s
NAME  UUID                                  TYPE      DEVICE 
eth1  69609727-cbbf-479d-ae87-a76256c520b9  ethernet  eth0   
eth1  fde9a03d-8f6d-4f0c-98f9-619f430f7051  ethernet  --     

up

激活連接,提供連接名稱或uuid進行激活,若未提供,則可以使用ifname指定設備名進行激活。

[root@hehe ~]# nmcli connection up eth1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)

[root@hehe ~]# nmcli c s
NAME  UUID                                  TYPE      DEVICE 
eth1  69609727-cbbf-479d-ae87-a76256c520b9  ethernet  eth0   
eth1  fde9a03d-8f6d-4f0c-98f9-619f430f7051  ethernet  -- 

[root@hehe ~]# nmcli c clone eth1 eth0
eth1 (69609727-cbbf-479d-ae87-a76256c520b9) cloned as eth0 (d97737e6-6d9c-4033-bff3-078e5773b3c4).

[root@hehe ~]# nmcli connection up eth0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)

 

[root@hehe ~]# nmcli connection delete eth0
Connection ‘eth0’ (d97737e6-6d9c-4033-bff3-078e5773b3c4) successfully deleted.

clone

從一個已經存在的連接克隆一個新連接,連接名稱和uuid是新生成的

[root@hehe ~]# nmcli c clone eth1 eth0
eth1 (69609727-cbbf-479d-ae87-a76256c520b9) cloned as eth0 (d97737e6-6d9c-4033-bff3-078e5773b3c4).
[root@hehe ~]# nmcli c show 
NAME  UUID                                  TYPE      DEVICE 
eth1  69609727-cbbf-479d-ae87-a76256c520b9  ethernet  eth0   
eth0  d97737e6-6d9c-4033-bff3-078e5773b3c4  ethernet  --     
eth1  fde9a03d-8f6d-4f0c-98f9-619f430f7051  ethernet  --   

device 設備管理

語法:

nmcli device {status | show | set | connect | reapply | modify | disconnect | delete | monitor | wifi | lldp} [ARGUMENTS…]

顯示和管理設備介面。該選項有很多功能,例如連接wifi,創建熱點,掃描無線,鄰近發現等,下面僅列出常用選項。

status 查看設備狀態

[root@hehe ~]# nmcli device status 
DEVICE  TYPE      STATE      CONNECTION 
eth0    ethernet  connected  eth1       
lo      loopback  unmanaged  --    

show 顯示所有介面詳細資訊

[root@hehe ~]# nmcli device show
GENERAL.DEVICE:                         eth0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:16:3E:0E:45:31
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     eth1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/9
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         172.16.100.7/24
IP4.ADDRESS[2]:                         172.17.203.6/20
IP4.ADDRESS[3]:                         172.17.201.88/20
IP4.GATEWAY:                            172.17.207.253
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 172.17.207.253, mt = 100
IP4.ROUTE[2]:                           dst = 172.16.100.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[3]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.ROUTE[4]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.DNS[1]:                             100.100.2.136
IP4.DNS[2]:                             100.100.2.138
IP6.ADDRESS[1]:                         fe80::7fb8:d6e7:1c09:caae/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 100
IP6.ROUTE[2]:                           dst = ff00::/8, nh = ::, mt = 256, table=255

GENERAL.DEVICE:                         lo
GENERAL.TYPE:                           loopback
GENERAL.HWADDR:                         00:00:00:00:00:00
GENERAL.MTU:                            65536
GENERAL.STATE:                          10 (unmanaged)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --
IP4.ADDRESS[1]:                         127.0.0.1/8
IP4.GATEWAY:                            --
IP6.ADDRESS[1]:                         ::1/128
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = ::1/128, nh = ::, mt = 256

set設置設備屬性

[root@hehe ~]# nmcli device set eth0 autoconnect yes  

connect

連接設備。提供一個設備介面,網路管理器將嘗試找到一個合適的連接, 將被激活。它還將考慮未設置為自動連接的連接。(默認超時為90s)

[root@hehe ~]# nmcli device connect eth0 
Device 'eth0' successfully activated with '69609727-cbbf-479d-ae87-a76256c520b9'.

modify

修改設備上處於活動的設備,但該修改只是臨時的,並不會寫入文件。(語法與 nmcli connection modify 相同)

[root@hehe ~]# nmcli device modify eth0 con-name eth1 ifname eth0 autoconnect yes +ipv4.addresses 172.16.100.91/24
Connection successfully reapplied to device 'eth0'.


[root@hehe ~]# nmcli -f IP4 connection show eth1
IP4.ADDRESS[1]:                         172.16.100.7/24
IP4.ADDRESS[2]:                         172.16.100.91/24
IP4.ADDRESS[3]:                         172.17.203.6/20
IP4.ADDRESS[4]:                         172.17.201.88/20
IP4.GATEWAY:                            172.17.207.253
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 172.17.207.253, mt = 100
IP4.ROUTE[2]:                           dst = 172.16.100.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[3]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.ROUTE[4]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.ROUTE[5]:                           dst = 172.16.100.0/24, nh = 0.0.0.0, mt = 100
IP4.DNS[1]:                             100.100.2.136
IP4.DNS[2]:                             100.100.2.138

刪除IP

[root@hehe ~]# nmcli device modify eth0 -ipv4.addresses 0
Connection successfully reapplied to device 'eth0'.
[root@hehe ~]# nmcli device show eth0
GENERAL.DEVICE:                         eth0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:16:3E:0E:45:31
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     eth1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/11
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         172.16.100.7/24
IP4.ADDRESS[2]:                         172.17.201.88/20
IP4.GATEWAY:                            172.17.207.253
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 172.17.207.253, mt = 100
IP4.ROUTE[2]:                           dst = 172.16.100.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[3]:                           dst = 172.17.192.0/20, nh = 0.0.0.0, mt = 100
IP4.DNS[1]:                             100.100.2.136
IP4.DNS[2]:                             100.100.2.138
IP6.ADDRESS[1]:                         fe80::7fb8:d6e7:1c09:caae/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 100