Home
Network Configuration Using NetworkManager's CLI (nmcli)
- To check whether NetworkManager daemon is running or not.
[root@localhost ~]# nmcli -t -f RUNNING general
running
- To check overall status of NetworkManager daemon.
[root@localhost ~]# nmcli -t -f STATE general
connected
- To list all connections NetworkManager daemon has along with its state.
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
enp0s9-connection bb53a5ca-2dc3-4ebe-ba35-ad3664475fa9 802-3-ethernet enp0s9
enp0s3-connection e805e43e-e3cb-474d-984c-def0226c279a 802-3-ethernet enp0s3
enp0s8-connection b38fa076-ea97-44d2-a30c-05b3959a1775 802-3-ethernet enp0s8
enp0s10-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-connection
UUID: bb53a5ca-2dc3-4ebe-ba35-ad3664475fa9
TYPE: 802-3-ethernet
TIMESTAMP: 1427419991
TIMESTAMP-REAL: Thu 26 Mar 2015 09:33:11 PM EDT
AUTOCONNECT: yes
READONLY: no
DBUS-PATH: /org/freedesktop/NetworkManager/Settings/2
ACTIVE: yes
DEVICE: enp0s9
STATE: activated
ACTIVE-PATH: /org/freedesktop/NetworkManager/ActiveConnection/23
-------------------------------------------------------------------------------
NAME: enp0s3-connection
UUID: e805e43e-e3cb-474d-984c-def0226c279a
TYPE: 802-3-ethernet
TIMESTAMP: 1427419991
TIMESTAMP-REAL: Thu 26 Mar 2015 09:33:11 PM EDT
AUTOCONNECT: yes
READONLY: no
DBUS-PATH: /org/freedesktop/NetworkManager/Settings/1
ACTIVE: yes
DEVICE: enp0s3
STATE: activated
ACTIVE-PATH: /org/freedesktop/NetworkManager/ActiveConnection/21
-------------------------------------------------------------------------------
NAME: enp0s8-connection
UUID: b38fa076-ea97-44d2-a30c-05b3959a1775
TYPE: 802-3-ethernet
TIMESTAMP: 1427419991
TIMESTAMP-REAL: Thu 26 Mar 2015 09:33:11 PM EDT
AUTOCONNECT: yes
READONLY: no
DBUS-PATH: /org/freedesktop/NetworkManager/Settings/0
ACTIVE: yes
DEVICE: enp0s8
STATE: activated
ACTIVE-PATH: /org/freedesktop/NetworkManager/ActiveConnection/22
-------------------------------------------------------------------------------
NAME: enp0s10-connection
UUID: 4474b5b1-e576-45bd-babb-c3ce22d41166
TYPE: 802-3-ethernet
TIMESTAMP: 1427419991
TIMESTAMP-REAL: Thu 26 Mar 2015 09:33:11 PM EDT
AUTOCONNECT: yes
READONLY: no
DBUS-PATH: /org/freedesktop/NetworkManager/Settings/3
ACTIVE: yes
DEVICE: enp0s10
STATE: activated
ACTIVE-PATH: /org/freedesktop/NetworkManager/ActiveConnection/20
-------------------------------------------------------------------------------
- To check all currently active connections
[root@localhost ~]# nmcli connection show --active
NAME UUID TYPE DEVICE
enp0s9-connection bb53a5ca-2dc3-4ebe-ba35-ad3664475fa9 802-3-ethernet enp0s9
enp0s3-connection e805e43e-e3cb-474d-984c-def0226c279a 802-3-ethernet enp0s3
enp0s8-connection b38fa076-ea97-44d2-a30c-05b3959a1775 802-3-ethernet enp0s8
enp0s10-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 s
NAME AUTOCONNECT
enp0s9-connection yes
enp0s3-connection yes
enp0s8-connection yes
enp0s10-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-connection
connection.uuid: 4474b5b1-e576-45bd-babb-c3ce22d41166
connection.interface-name: --
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.timestamp: 1427419991
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: 08:00:27:94:3E:02
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.routes:
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.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: --
-------------------------------------------------------------------------------
===============================================================================
Activate connection details (4474b5b1-e576-45bd-babb-c3ce22d41166)
===============================================================================
GENERAL.NAME: enp0s10-connection
GENERAL.UUID: 4474b5b1-e576-45bd-babb-c3ce22d41166
GENERAL.DEVICES: enp0s10
GENERAL.STATE: activated
GENERAL.DEFAULT: yes
GENERAL.DEFAULT6: no
GENERAL.VPN: no
GENERAL.ZONE: --
GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/20
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/3
GENERAL.SPEC-OBJECT: --
GENERAL.MASTER-PATH: --
-------------------------------------------------------------------------------
IP4.ADDRESS[1]: ip = 192.168.50.6/24, gw = 192.168.50.1
IP4.DNS[1]: 10.66.9.204
IP4.DNS[2]: 10.66.15.201
IP4.DOMAIN[1]: in.ril.com
-------------------------------------------------------------------------------
DHCP4.OPTION[1]: requested_domain_search = 1
DHCP4.OPTION[2]: dhcp_message_type = 5
DHCP4.OPTION[3]: requested_time_offset = 1
DHCP4.OPTION[4]: requested_domain_name = 1
DHCP4.OPTION[5]: requested_rfc3442_classless_static_routes = 1
DHCP4.OPTION[6]: requested_broadcast_address = 1
DHCP4.OPTION[7]: requested_classless_static_routes = 1
DHCP4.OPTION[8]: expiry = 1427421261
DHCP4.OPTION[9]: domain_name = in.ril.com
DHCP4.OPTION[10]: next_server = 0.0.0.0
DHCP4.OPTION[11]: broadcast_address = 192.168.50.255
DHCP4.OPTION[12]: requested_interface_mtu = 1
DHCP4.OPTION[13]: requested_subnet_mask = 1
DHCP4.OPTION[14]: dhcp_lease_time = 1200
DHCP4.OPTION[15]: ip_address = 192.168.50.6
DHCP4.OPTION[16]: requested_nis_domain = 1
DHCP4.OPTION[17]: routers = 192.168.50.1
DHCP4.OPTION[18]: requested_wpad = 1
DHCP4.OPTION[19]: requested_static_routes = 1
DHCP4.OPTION[20]: requested_nis_servers = 1
DHCP4.OPTION[21]: domain_name_servers = 10.66.9.204 10.66.15.201
DHCP4.OPTION[22]: requested_domain_name_servers = 1
DHCP4.OPTION[23]: requested_ntp_servers = 1
DHCP4.OPTION[24]: requested_routers = 1
DHCP4.OPTION[25]: requested_ms_classless_static_routes = 1
DHCP4.OPTION[26]: subnet_mask = 255.255.255.0
DHCP4.OPTION[27]: requested_host_name = 1
DHCP4.OPTION[28]: network_number = 192.168.50.0
DHCP4.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-connection
GENERAL.UUID: 4474b5b1-e576-45bd-babb-c3ce22d41166
GENERAL.DEVICES: enp0s10
GENERAL.STATE: activated
GENERAL.DEFAULT: yes
GENERAL.DEFAULT6: no
GENERAL.VPN: no
GENERAL.ZONE: --
GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/20
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/3
GENERAL.SPEC-OBJECT: --
GENERAL.MASTER-PATH: --
IP4.ADDRESS[1]: ip = 192.168.50.6/24, gw = 192.168.50.1
IP4.DNS[1]: 10.66.9.204
IP4.DNS[2]: 10.66.15.201
IP4.DOMAIN[1]: in.ril.com
DHCP4.OPTION[1]: requested_domain_search = 1
DHCP4.OPTION[2]: dhcp_message_type = 5
DHCP4.OPTION[3]: requested_time_offset = 1
DHCP4.OPTION[4]: requested_domain_name = 1
DHCP4.OPTION[5]: requested_rfc3442_classless_static_routes = 1
DHCP4.OPTION[6]: requested_broadcast_address = 1
DHCP4.OPTION[7]: requested_classless_static_routes = 1
DHCP4.OPTION[8]: expiry = 1427421261
DHCP4.OPTION[9]: domain_name = in.ril.com
DHCP4.OPTION[10]: next_server = 0.0.0.0
DHCP4.OPTION[11]: broadcast_address = 192.168.50.255
DHCP4.OPTION[12]: requested_interface_mtu = 1
DHCP4.OPTION[13]: requested_subnet_mask = 1
DHCP4.OPTION[14]: dhcp_lease_time = 1200
DHCP4.OPTION[15]: ip_address = 192.168.50.6
DHCP4.OPTION[16]: requested_nis_domain = 1
DHCP4.OPTION[17]: routers = 192.168.50.1
DHCP4.OPTION[18]: requested_wpad = 1
DHCP4.OPTION[19]: requested_static_routes = 1
DHCP4.OPTION[20]: requested_nis_servers = 1
DHCP4.OPTION[21]: domain_name_servers = 10.66.9.204 10.66.15.201
DHCP4.OPTION[22]: requested_domain_name_servers = 1
DHCP4.OPTION[23]: requested_ntp_servers = 1
DHCP4.OPTION[24]: requested_routers = 1
DHCP4.OPTION[25]: requested_ms_classless_static_routes = 1
DHCP4.OPTION[26]: subnet_mask = 255.255.255.0
DHCP4.OPTION[27]: requested_host_name = 1
DHCP4.OPTION[28]: network_number = 192.168.50.0
DHCP4.OPTION[29]: dhcp_server_identifier = 192.168.50.3
IP6.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-connection
connection.uuid: 4474b5b1-e576-45bd-babb-c3ce22d41166
connection.interface-name: --
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.timestamp: 1427420291
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: 08:00:27:94:3E:02
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.routes:
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.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: --
- 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 enp0s9
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/32)
- To check status for all devices.
[root@localhost ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
enp0s10 ethernet connected enp0s10-connection
enp0s3 ethernet connected enp0s3-connection
enp0s8 ethernet connected enp0s8-connection
enp0s9 ethernet connected enp0s9-connection
lo 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 status
DEVICE TYPE STATE CONNECTION
enp0s10 ethernet connected enp0s10-connection
enp0s3 ethernet connected enp0s3-connection
enp0s8 ethernet connected enp0s8-connection
enp0s9 ethernet connected enp0s9-connection
lo loopback unmanaged --
[root@localhost ~]# nmcli dev disconnect enp0s10
[root@localhost ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
enp0s3 ethernet connected enp0s3-connection
enp0s8 ethernet connected enp0s8-connection
enp0s9 ethernet connected enp0s9-connection
enp0s10 ethernet disconnected --
lo loopback unmanaged --
[root@localhost ~]# nmcli dev connect enp0s10
Device 'enp0s10' successfully activated with '4474b5b1-e576-45bd-babb-c3ce22d41166'.
[root@localhost ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
enp0s10 ethernet connected enp0s10-connection
enp0s3 ethernet connected enp0s3-connection
enp0s8 ethernet connected enp0s8-connection
enp0s9 ethernet connected enp0s9-connection
lo 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, dcb
nmcli> ?
------------------------------------------------------------------------------
---[ Main menu ]---
goto [<setting> | <prop>] :: go to a setting or property
remove <setting>[.<prop>] | <prop> :: remove setting or reset property value
set [<setting>.<prop> <value>] :: set property value
describe [<setting>.<prop>] :: describe property
print [all] :: print the connection
verify [all] :: verify the connection
save [persistent|temporary] :: save the connection
activate [<ifname>] [/<ap>|<nsp>] :: activate the connection
back :: go one level up (back)
help/? [<command>] :: print this help
nmcli <conf-option> <value> :: nmcli configuration
quit :: exit nmcli
------------------------------------------------------------------------------
nmcli> print
===============================================================================
Connection profile details (enp0s3-connection)
===============================================================================
connection.id: enp0s3-connection
connection.uuid: e805e43e-e3cb-474d-984c-def0226c279a
connection.interface-name: --
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.timestamp: 1427422691
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: 08:00:27:41:A7:79
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.routes:
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.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> quit
No comments:
Post a Comment