nmcli几个常用命令

Posted cloudapecs

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nmcli几个常用命令相关的知识,希望对你有一定的参考价值。

1.nmcli connection 用于查看连接

2.nmcli device用于查看当前网络设备

3.nmcli connection modify用于修改当前连接配置

4.nmcli connection reload 重新加载连接配置

 

简单示例如下:

[root@localhost /]# nmcli connection
NAME    UUID                                  TYPE      DEVICE
eno1    6b06dff7-65a3-4ca7-bfc7-c3bf1af8d52f  ethernet  eno1   
virbr0  1486fe12-2531-42a1-a413-ecba62d34a84  bridge    virbr0
eno1    2df29981-3b89-4862-9b23-652e7b5027b7  ethernet  --     
[root@localhost /]# nmcli connection show
NAME    UUID                                  TYPE      DEVICE
eno1    6b06dff7-65a3-4ca7-bfc7-c3bf1af8d52f  ethernet  eno1   
virbr0  1486fe12-2531-42a1-a413-ecba62d34a84  bridge    virbr0
eno1    2df29981-3b89-4862-9b23-652e7b5027b7  ethernet  --     
[root@localhost /]# nmcli connection show eno1
connection.id:                          eno1
connection.uuid:                        6b06dff7-65a3-4ca7-bfc7-c3bf1af8d52f
........................
ipv4.method:                            manual
ipv4.dns:                               192.168.1.1
ipv4.dns-search:                        --
ipv4.dns-options:                       ""
ipv4.dns-priority:                      0
ipv4.addresses:                         192.168.1.2/24
ipv4.gateway:                           192.168.1.1
ipv4.routes:                            --
ipv4.route-metric:                      -1
ipv4.route-table:                       0 (unspec)
[root@localhost /]# nmcli connection show -active
NAME    UUID                                  TYPE      DEVICE
eno1    6b06dff7-65a3-4ca7-bfc7-c3bf1af8d52f  ethernet  eno1   
virbr0  1486fe12-2531-42a1-a413-ecba62d34a84  bridge    virbr0
[root@localhost /]# nmcli connection show eno1
connection.id:                          eno1
connection.uuid:                        6b06dff7-65a3-4ca7-bfc7-c3bf1af8d52f
................
ipv4.method:                            manual
ipv4.dns:                               192.168.1.1
ipv4.dns-search:                        --
ipv4.dns-options:                       ""
ipv4.dns-priority:                      0
ipv4.addresses:                         192.168.1.2/24
ipv4.gateway:                           192.168.1.1

[root@localhost /]# nmcli device
DEVICE      TYPE      STATE      CONNECTION
eno1        ethernet  connected  eno1       
virbr0      bridge    connected  virbr0     
lo          loopback  unmanaged  --         
virbr0-nic  tun       unmanaged  --         
[root@localhost /]# nmcli device show
GENERAL.DEVICE:                         eno1
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         90:B1:1C:8F:4C:33
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     eno1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveC>
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS:                             192.168.1.2/24
IP4.GATEWAY:                            192.168.1.1
IP4.ROUTE:                               dst = 192.168.1.0/24, nh = 0.0.0.0, mt >
IP4.DNS:                                 192.168.1.1
[root@localhost /]# nmcli device show eno1
GENERAL.DEVICE:                         eno1
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         90:B1:1C:8F:4C:33
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     eno1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveC>
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS:                             192.168.1.2/24
IP4.GATEWAY:                            192.168.1.1
IP4.ROUTE:                               dst = 192.168.1.0/24, nh = 0.0.0.0, mt >
IP4.DNS:                                 192.168.1.1


[root@localhost /]# nmcli connection modify eno1 ipv4.method manual ipv4.addresses 192.168.1.2/24 ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.1



[root@localhost /]# nmcli connection reload



以上是关于nmcli几个常用命令的主要内容,如果未能解决你的问题,请参考以下文章

基于RHEL8/CentOS8的nmcli常用命令总结

centos 7 工具nmcli

网络基础

CentOS 7网卡配置-nmcli

常用的几个linux命令

linux运维必须知道的几个常用命令