Home
Network Configuration Using NetworkManager's CLI (nmcli)
- To check whether NetworkManager daemon is running or not.
[root@localhost ~]# nmcli -t -f RUNNING generalrunning
- To check overall status of NetworkManager daemon.
[root@localhost ~]# nmcli -t -f STATE generalconnected
- To list all connections NetworkManager daemon has along with its state.
[root@localhost ~]# nmcli connection showNAME UUID TYPE DEVICEenp0s9-connection bb53a5ca-2dc3-4ebe-ba35-ad3664475fa9 802-3-ethernet enp0s9enp0s3-connection e805e43e-e3cb-474d-984c-def0226c279a 802-3-ethernet enp0s3enp0s8-connection b38fa076-ea97-44d2-a30c-05b3959a1775 802-3-ethernet enp0s8enp0s10-connection 4474b5b1-e576-45bd-babb-c3ce22d41166 802-3-ethernet enp0s10
- To check all configured connections in multi-line mode.
[root@localhost ~]# nmcli -p -m multiline -f all con show=============================================================================== NetworkManager connection profiles===============================================================================NAME: enp0s9-connectionUUID: bb53a5ca-2dc3-4ebe-ba35-ad3664475fa9TYPE: 802-3-ethernetTIMESTAMP: 1427419991TIMESTAMP-REAL: Thu 26 Mar 2015 09:33:11 PM EDTAUTOCONNECT: yesREADONLY: noDBUS-PATH: /org/freedesktop/NetworkManager/Settings/2ACTIVE: yesDEVICE: enp0s9STATE: activatedACTIVE-PATH: /org/freedesktop/NetworkManager/ActiveConnection/23-------------------------------------------------------------------------------NAME: enp0s3-connectionUUID: e805e43e-e3cb-474d-984c-def0226c279aTYPE: 802-3-ethernetTIMESTAMP: 1427419991TIMESTAMP-REAL: Thu 26 Mar 2015 09:33:11 PM EDTAUTOCONNECT: yesREADONLY: noDBUS-PATH: /org/freedesktop/NetworkManager/Settings/1ACTIVE: yesDEVICE: enp0s3STATE: activatedACTIVE-PATH: /org/freedesktop/NetworkManager/ActiveConnection/21-------------------------------------------------------------------------------NAME: enp0s8-connectionUUID: b38fa076-ea97-44d2-a30c-05b3959a1775TYPE: 802-3-ethernetTIMESTAMP: 1427419991TIMESTAMP-REAL: Thu 26 Mar 2015 09:33:11 PM EDTAUTOCONNECT: yesREADONLY: noDBUS-PATH: /org/freedesktop/NetworkManager/Settings/0ACTIVE: yesDEVICE: enp0s8STATE: activatedACTIVE-PATH: /org/freedesktop/NetworkManager/ActiveConnection/22-------------------------------------------------------------------------------NAME: enp0s10-connectionUUID: 4474b5b1-e576-45bd-babb-c3ce22d41166TYPE: 802-3-ethernetTIMESTAMP: 1427419991TIMESTAMP-REAL: Thu 26 Mar 2015 09:33:11 PM EDTAUTOCONNECT: yesREADONLY: noDBUS-PATH: /org/freedesktop/NetworkManager/Settings/3ACTIVE: yesDEVICE: enp0s10STATE: activatedACTIVE-PATH: /org/freedesktop/NetworkManager/ActiveConnection/20-------------------------------------------------------------------------------
- To check all currently active connections
[root@localhost ~]# nmcli connection show --activeNAME UUID TYPE DEVICEenp0s9-connection bb53a5ca-2dc3-4ebe-ba35-ad3664475fa9 802-3-ethernet enp0s9enp0s3-connection e805e43e-e3cb-474d-984c-def0226c279a 802-3-ethernet enp0s3enp0s8-connection b38fa076-ea97-44d2-a30c-05b3959a1775 802-3-ethernet enp0s8enp0s10-connection 4474b5b1-e576-45bd-babb-c3ce22d41166 802-3-ethernet enp0s10
- To check all connection profile names and their auto-connect property
[root@localhost ~]# nmcli -f name,autoconnect c sNAME AUTOCONNECTenp0s9-connection yesenp0s3-connection yesenp0s8-connection yesenp0s10-connection yes
- To check details for a individual connection profile.
[root@localhost ~]# nmcli -p connection show "enp0s10-connection"=============================================================================== Connection profile details (enp0s10-connection)===============================================================================connection.id: enp0s10-connectionconnection.uuid: 4474b5b1-e576-45bd-babb-c3ce22d41166connection.interface-name: --connection.type: 802-3-ethernetconnection.autoconnect: yesconnection.timestamp: 1427419991connection.read-only: noconnection.permissions:connection.zone: --connection.master: --connection.slave-type: --connection.secondaries:connection.gateway-ping-timeout: 0-------------------------------------------------------------------------------802-3-ethernet.port: --802-3-ethernet.speed: 0802-3-ethernet.duplex: --802-3-ethernet.auto-negotiate: yes802-3-ethernet.mac-address: 08:00:27:94:3E:02802-3-ethernet.cloned-mac-address: --802-3-ethernet.mac-address-blacklist:802-3-ethernet.mtu: auto802-3-ethernet.s390-subchannels:802-3-ethernet.s390-nettype: --802-3-ethernet.s390-options:-------------------------------------------------------------------------------ipv4.method: autoipv4.dns:ipv4.dns-search:ipv4.addresses:ipv4.routes:ipv4.ignore-auto-routes: noipv4.ignore-auto-dns: noipv4.dhcp-client-id: --ipv4.dhcp-send-hostname: yesipv4.dhcp-hostname: --ipv4.never-default: noipv4.may-fail: yes-------------------------------------------------------------------------------ipv6.method: autoipv6.dns:ipv6.dns-search:ipv6.addresses:ipv6.routes:ipv6.ignore-auto-routes: noipv6.ignore-auto-dns: noipv6.never-default: noipv6.may-fail: yesipv6.ip6-privacy: -1 (unknown)ipv6.dhcp-hostname: ---------------------------------------------------------------------------------=============================================================================== Activate connection details (4474b5b1-e576-45bd-babb-c3ce22d41166)===============================================================================GENERAL.NAME: enp0s10-connectionGENERAL.UUID: 4474b5b1-e576-45bd-babb-c3ce22d41166GENERAL.DEVICES: enp0s10GENERAL.STATE: activatedGENERAL.DEFAULT: yesGENERAL.DEFAULT6: noGENERAL.VPN: noGENERAL.ZONE: --GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/20GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/3GENERAL.SPEC-OBJECT: --GENERAL.MASTER-PATH: ---------------------------------------------------------------------------------IP4.ADDRESS[1]: ip = 192.168.50.6/24, gw = 192.168.50.1IP4.DNS[1]: 10.66.9.204IP4.DNS[2]: 10.66.15.201IP4.DOMAIN[1]: in.ril.com-------------------------------------------------------------------------------DHCP4.OPTION[1]: requested_domain_search = 1DHCP4.OPTION[2]: dhcp_message_type = 5DHCP4.OPTION[3]: requested_time_offset = 1DHCP4.OPTION[4]: requested_domain_name = 1DHCP4.OPTION[5]: requested_rfc3442_classless_static_routes = 1DHCP4.OPTION[6]: requested_broadcast_address = 1DHCP4.OPTION[7]: requested_classless_static_routes = 1DHCP4.OPTION[8]: expiry = 1427421261DHCP4.OPTION[9]: domain_name = in.ril.comDHCP4.OPTION[10]: next_server = 0.0.0.0DHCP4.OPTION[11]: broadcast_address = 192.168.50.255DHCP4.OPTION[12]: requested_interface_mtu = 1DHCP4.OPTION[13]: requested_subnet_mask = 1DHCP4.OPTION[14]: dhcp_lease_time = 1200DHCP4.OPTION[15]: ip_address = 192.168.50.6DHCP4.OPTION[16]: requested_nis_domain = 1DHCP4.OPTION[17]: routers = 192.168.50.1DHCP4.OPTION[18]: requested_wpad = 1DHCP4.OPTION[19]: requested_static_routes = 1DHCP4.OPTION[20]: requested_nis_servers = 1DHCP4.OPTION[21]: domain_name_servers = 10.66.9.204 10.66.15.201DHCP4.OPTION[22]: requested_domain_name_servers = 1DHCP4.OPTION[23]: requested_ntp_servers = 1DHCP4.OPTION[24]: requested_routers = 1DHCP4.OPTION[25]: requested_ms_classless_static_routes = 1DHCP4.OPTION[26]: subnet_mask = 255.255.255.0DHCP4.OPTION[27]: requested_host_name = 1DHCP4.OPTION[28]: network_number = 192.168.50.0DHCP4.OPTION[29]: dhcp_server_identifier = 192.168.50.3-------------------------------------------------------------------------------IP6.ADDRESS[1]: ip = fe80::a00:27ff:fe94:3e02/64, gw = ::-------------------------------------------------------------------------------
- To check details for individual active connection, like IP, DHCP information, etc.
[root@localhost ~]# nmcli -f active connection show "enp0s10-connection"GENERAL.NAME: enp0s10-connectionGENERAL.UUID: 4474b5b1-e576-45bd-babb-c3ce22d41166GENERAL.DEVICES: enp0s10GENERAL.STATE: activatedGENERAL.DEFAULT: yesGENERAL.DEFAULT6: noGENERAL.VPN: noGENERAL.ZONE: --GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/20GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/3GENERAL.SPEC-OBJECT: --GENERAL.MASTER-PATH: --IP4.ADDRESS[1]: ip = 192.168.50.6/24, gw = 192.168.50.1IP4.DNS[1]: 10.66.9.204IP4.DNS[2]: 10.66.15.201IP4.DOMAIN[1]: in.ril.comDHCP4.OPTION[1]: requested_domain_search = 1DHCP4.OPTION[2]: dhcp_message_type = 5DHCP4.OPTION[3]: requested_time_offset = 1DHCP4.OPTION[4]: requested_domain_name = 1DHCP4.OPTION[5]: requested_rfc3442_classless_static_routes = 1DHCP4.OPTION[6]: requested_broadcast_address = 1DHCP4.OPTION[7]: requested_classless_static_routes = 1DHCP4.OPTION[8]: expiry = 1427421261DHCP4.OPTION[9]: domain_name = in.ril.comDHCP4.OPTION[10]: next_server = 0.0.0.0DHCP4.OPTION[11]: broadcast_address = 192.168.50.255DHCP4.OPTION[12]: requested_interface_mtu = 1DHCP4.OPTION[13]: requested_subnet_mask = 1DHCP4.OPTION[14]: dhcp_lease_time = 1200DHCP4.OPTION[15]: ip_address = 192.168.50.6DHCP4.OPTION[16]: requested_nis_domain = 1DHCP4.OPTION[17]: routers = 192.168.50.1DHCP4.OPTION[18]: requested_wpad = 1DHCP4.OPTION[19]: requested_static_routes = 1DHCP4.OPTION[20]: requested_nis_servers = 1DHCP4.OPTION[21]: domain_name_servers = 10.66.9.204 10.66.15.201DHCP4.OPTION[22]: requested_domain_name_servers = 1DHCP4.OPTION[23]: requested_ntp_servers = 1DHCP4.OPTION[24]: requested_routers = 1DHCP4.OPTION[25]: requested_ms_classless_static_routes = 1DHCP4.OPTION[26]: subnet_mask = 255.255.255.0DHCP4.OPTION[27]: requested_host_name = 1DHCP4.OPTION[28]: network_number = 192.168.50.0DHCP4.OPTION[29]: dhcp_server_identifier = 192.168.50.3IP6.ADDRESS[1]: ip = fe80::a00:27ff:fe94:3e02/64, gw = ::
- To check static configuration details of the connection profile with specified name.
[root@localhost ~]# nmcli -f profile con s "enp0s10-connection"connection.id: enp0s10-connectionconnection.uuid: 4474b5b1-e576-45bd-babb-c3ce22d41166connection.interface-name: --connection.type: 802-3-ethernetconnection.autoconnect: yesconnection.timestamp: 1427420291connection.read-only: noconnection.permissions:connection.zone: --connection.master: --connection.slave-type: --connection.secondaries:connection.gateway-ping-timeout: 0802-3-ethernet.port: --802-3-ethernet.speed: 0802-3-ethernet.duplex: --802-3-ethernet.auto-negotiate: yes802-3-ethernet.mac-address: 08:00:27:94:3E:02802-3-ethernet.cloned-mac-address: --802-3-ethernet.mac-address-blacklist:802-3-ethernet.mtu: auto802-3-ethernet.s390-subchannels:802-3-ethernet.s390-nettype: --802-3-ethernet.s390-options:ipv4.method: autoipv4.dns:ipv4.dns-search:ipv4.addresses:ipv4.routes:ipv4.ignore-auto-routes: noipv4.ignore-auto-dns: noipv4.dhcp-client-id: --ipv4.dhcp-send-hostname: yesipv4.dhcp-hostname: --ipv4.never-default: noipv4.may-fail: yesipv6.method: autoipv6.dns:ipv6.dns-search:ipv6.addresses:ipv6.routes:ipv6.ignore-auto-routes: noipv6.ignore-auto-dns: noipv6.never-default: noipv6.may-fail: yesipv6.ip6-privacy: -1 (unknown)ipv6.dhcp-hostname: --
- To activates the connection profile with specified name on an interface. The -p option makes nmcli show progress of the activation.
[root@localhost ~]# nmcli -p con up "enp0s9-connection" ifname enp0s9Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/32)
- To check status for all devices.
[root@localhost ~]# nmcli device statusDEVICE TYPE STATE CONNECTIONenp0s10 ethernet connected enp0s10-connectionenp0s3 ethernet connected enp0s3-connectionenp0s8 ethernet connected enp0s8-connectionenp0s9 ethernet connected enp0s9-connectionlo loopback unmanaged --
- To disconnect a connection profile on interface enp0s10 and marks the device as unavailable for auto connecting. As a result, no connection will automatically be activated on the device until the device's 'autoconnect' is set to TRUE or the user manually activates a connection.
[root@localhost ~]# nmcli device statusDEVICE TYPE STATE CONNECTIONenp0s10 ethernet connected enp0s10-connectionenp0s3 ethernet connected enp0s3-connectionenp0s8 ethernet connected enp0s8-connectionenp0s9 ethernet connected enp0s9-connectionlo loopback unmanaged --[root@localhost ~]# nmcli dev disconnect enp0s10[root@localhost ~]# nmcli device statusDEVICE TYPE STATE CONNECTIONenp0s3 ethernet connected enp0s3-connectionenp0s8 ethernet connected enp0s8-connectionenp0s9 ethernet connected enp0s9-connectionenp0s10 ethernet disconnected --lo loopback unmanaged --[root@localhost ~]# nmcli dev connect enp0s10Device 'enp0s10' successfully activated with '4474b5b1-e576-45bd-babb-c3ce22d41166'.[root@localhost ~]# nmcli device statusDEVICE TYPE STATE CONNECTIONenp0s10 ethernet connected enp0s10-connectionenp0s3 ethernet connected enp0s3-connectionenp0s8 ethernet connected enp0s8-connectionenp0s9 ethernet connected enp0s9-connectionlo loopback unmanaged --
- non-interactively adds an Ethernet connection tied to eth0 interface with automatic IP configuration (DHCP), and disables the connection's "autoconnect" flag.
nmcli connection add type ethernet autoconnect no ifname eth0
- To edit existing connection in the interactive editor.
[root@localhost ~]# nmcli connection edit enp0s3-connection===| nmcli interactive connection editor |===Editing existing '802-3-ethernet' connection: 'enp0s3-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, dcbnmcli> ?---------------------------------------------------------------------------------[ Main menu ]---goto [<setting> | <prop>] :: go to a setting or propertyremove <setting>[.<prop>] | <prop> :: remove setting or reset property valueset [<setting>.<prop> <value>] :: set property valuedescribe [<setting>.<prop>] :: describe propertyprint [all] :: print the connectionverify [all] :: verify the connectionsave [persistent|temporary] :: save the connectionactivate [<ifname>] [/<ap>|<nsp>] :: activate the connectionback :: go one level up (back)help/? [<command>] :: print this helpnmcli <conf-option> <value> :: nmcli configurationquit :: exit nmcli------------------------------------------------------------------------------nmcli> print=============================================================================== Connection profile details (enp0s3-connection)===============================================================================connection.id: enp0s3-connectionconnection.uuid: e805e43e-e3cb-474d-984c-def0226c279aconnection.interface-name: --connection.type: 802-3-ethernetconnection.autoconnect: yesconnection.timestamp: 1427422691connection.read-only: noconnection.permissions:connection.zone: --connection.master: --connection.slave-type: --connection.secondaries:connection.gateway-ping-timeout: 0-------------------------------------------------------------------------------802-3-ethernet.port: --802-3-ethernet.speed: 0802-3-ethernet.duplex: --802-3-ethernet.auto-negotiate: yes802-3-ethernet.mac-address: 08:00:27:41:A7:79802-3-ethernet.cloned-mac-address: --802-3-ethernet.mac-address-blacklist:802-3-ethernet.mtu: auto802-3-ethernet.s390-subchannels:802-3-ethernet.s390-nettype: --802-3-ethernet.s390-options:-------------------------------------------------------------------------------ipv4.method: autoipv4.dns:ipv4.dns-search:ipv4.addresses:ipv4.routes:ipv4.ignore-auto-routes: noipv4.ignore-auto-dns: noipv4.dhcp-client-id: --ipv4.dhcp-send-hostname: yesipv4.dhcp-hostname: --ipv4.never-default: noipv4.may-fail: yes-------------------------------------------------------------------------------ipv6.method: autoipv6.dns:ipv6.dns-search:ipv6.addresses:ipv6.routes:ipv6.ignore-auto-routes: noipv6.ignore-auto-dns: noipv6.never-default: noipv6.may-fail: yesipv6.ip6-privacy: -1 (unknown)ipv6.dhcp-hostname: ---------------------------------------------------------------------------------nmcli> quit
No comments:
Post a Comment