nmcli command Network Manager command Line tool RHEL 7/Centos 7

A new Operating system came with new nmcli command Network Manager command line tool RHEL 7/Centos 7. Using nmcli command we can manage Ethernet Card devices, Assigning Static IP Address, DHCP client, WIFI connections, bridge connections, Bonds, Teaming and VLAN’s. 

No need of editing configuration files to configure IP address, routing and configuring Network devices

Let’s start with nmcli command

nmcli command syntax

[root@TechTutorials ~]# nmcli
Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

Manage Network devices

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

[root@TechTutorials ~]# nmcli device show
GENERAL.DEVICE: eno16777736
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 00:0C:29:3D:FA:DD
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: eth0
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES.CARRIER: on
IP4.ADDRESS[1]: 192.168.4.20/24
IP4.GATEWAY: 192.168.4.2
IP4.DNS[1]: 8.8.8.8
IP6.ADDRESS[1]: fe80::20c:29ff:fe3d:fadd/64
IP6.GATEWAY:

# Below command disconnects device
[root@TechTutorials ~]# nmcli device disconnect eno16777736

# Below command connects device
[root@TechTutorials ~]# nmcli device connect eno16777736
Device 'eno16777736' successfully activated with 'a80360f3-0972-4843-8d86-a27ae37d8751'.


To manage Network connections flexible, using nmcli command we can create N number of logical connections and we can active them based on requirement.  Basically we can’t active multiple connections yet a time but the thing is we can active each connection yet a time. 

Example: Network 1 IP series 192.168.1.x

                    Network 2 IP series 10.10.90.x

                   Network 2 IP series 172.168.2.x

every time when you want to change network connectivity to different network you have to change IP address to that series, But here create multiple connections and active them based on requirement. See below example, using single physical NIC card created multiple logical connections and activated one connection yet a time.

[root@TechTutorials ~]# nmcli connection add con-name 172series ifname eno16777736 type ethernet
Connection '172series' (ad091ed0-c221-4cd9-9e7a-6eb2063de4fe) successfully added.

[root@TechTutorials ~]# nmcli connection add con-name 192series ifname eno16777736 type ethernet
Connection '192series' (6c3ba921-b303-4ded-b8cb-dbade432bc66) successfully added.

[root@TechTutorials ~]# nmcli connection add con-name 10series ifname eno16777736 type ethernet
Connection '10series' (e717f706-539b-422a-a94a-f7fe49edb83e) successfully added.


[root@TechTutorials ~]# nmcli connection show
NAME UUID TYPE DEVICE
192series 6c3ba921-b303-4ded-b8cb-dbade432bc66 802-3-ethernet --
172series ad091ed0-c221-4cd9-9e7a-6eb2063de4fe 802-3-ethernet --
eth0 a80360f3-0972-4843-8d86-a27ae37d8751 802-3-ethernet eno16777736
10series e717f706-539b-422a-a94a-f7fe49edb83e 802-3-ethernet --

List out active connections only

[root@TechTutorials ~]# nmcli connection show --active
NAME UUID TYPE DEVICE
eth0 a80360f3-0972-4843-8d86-a27ae37d8751 802-3-ethernet eno16777736

Assigning static IP Address to existing connection

[root@TechTutorials ~]# nmcli connection modify 10series ipv4.addresses 10.10.90.2 ipv4.gateway 10.10.90.1 ipv4.dns 4.4.4.4 +ipv4.dns 8.8.8.8

make connections to connect automatically after server reboot

[root@TechTutorials ~]# nmcli connection modify 10series connection.autoconnect yes

above command will make sure that connection should connect automatically after server reboot

Know the status of NetworkManager

[root@TechTutorials ~]# nmcli -t -f RUNNING general
running

It will tell whether NetworkManager is Running OR Not

[root@TechTutorials ~]# nmcli -t -f STATE general
connected

To the State of NetworkManager

[root@TechTutorials ~]# nmcli radio wifi off
[root@TechTutorials ~]# nmcli radio wifi on
[root@TechTutorials ~]# nmcli radio all
WIFI-HW WIFI WWAN-HW WWAN
enabled enabled enabled enabled

Switch off / Switch on and know the status of Wifi connection

To see all configured profile details in multiline information using below command

[root@TechTutorials ~]# nmcli -p -m multiline -f all con show
======================================================
 NetworkManager connection profiles
======================================================
NAME: eth0
UUID: a80360f3-0972-4843-8d86-a27ae37d8751
TYPE: 802-3-ethernet
TIMESTAMP: 1471705850
TIMESTAMP-REAL: Sat 20 Aug 2016 08:40:50 PM IST
AUTOCONNECT: yes
AUTOCONNECT-PRIORITY: 0
READONLY: no
DBUS-PATH: /org/freedesktop/NetworkManager/Settings/2
ACTIVE: yes
DEVICE: eno16777736
STATE: activated
ACTIVE-PATH: /org/freedesktop/NetworkManager/ActiveConnection/0
---------------------------------------------------------

Using below command to list only active connections, As we can see eth0 is in active state.

[root@TechTutorials ~]# nmcli connection show --active
NAME UUID TYPE DEVICE
eth0 a80360f3-0972-4843-8d86-a27ae37d8751 802-3-ethernet eno16777736

To enable auto connect connections after every reboot, to check whether connections are in autoconnect or not

[root@TechTutorials ~]# nmcli -f name,autoconnect c s
NAME AUTOCONNECT
eth0 yes
192series yes
10series yes
172series yes

Objects we can use as like above we have used c and s

general NetworkManager’s general status and operations
networking overall networking control
radio NetworkManager radio switches
connection NetworkManager’s connections
device devices managed by NetworkManager
agent NetworkManager secret agent or polkit agent

Profile connection details full and complete details using below command

[root@TechTutorials ~]# nmcli -p connection show eth0
===============================================================================
 Connection profile details (eth0)
===============================================================================
connection.id: eth0
connection.uuid: a80360f3-0972-4843-8d86-a27ae37d8751
connection.interface-name: eno16777736
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.timestamp: 1471706450
connection.read-only: no
connection.permissions:
connection.zone: --
connection.master: --
connection.slave-type: --
connection.secondaries:
connection.gateway-ping-timeout: 0
OUTPUT TRUNCATED...

Show profile with all passwords of Wifi

[root@TechTutorials ~]# nmcli connection show --show-secrets "WiFi"

Show details about wifi connection profile with all passwords

[root@TechTutorials ~]# nmcli -f active connection show eth0
GENERAL.NAME: eth0
GENERAL.UUID: a80360f3-0972-4843-8d86-a27ae37d8751
GENERAL.DEVICES: eno16777736
GENERAL.STATE: activated
GENERAL.DEFAULT: yes
GENERAL.DEFAULT6: no
GENERAL.VPN: no
GENERAL.ZONE: --
GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/0
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/2
GENERAL.SPEC-OBJECT: /
GENERAL.MASTER-PATH: --
IP4.ADDRESS[1]: 192.168.4.20/24
IP4.GATEWAY: 192.168.4.2
IP4.DNS[1]: 8.8.8.8
IP6.ADDRESS[1]: fe80::20c:29ff:fe3d:fadd/64
IP6.GATEWAY:

shows details for “eth0” active connection, like IP, DHCP information, etc.

Thanks for the read.

Related Articles

Generating Linux Audit Reports

Screen Recording Software RHEL

How to install adobe flash player in Ubuntu Linux

Root user password reset in RHEL 7

Thanks for your wonderful Support and Encouragement

ARK

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

2 Responses

  1. Balaji says:

    hi i have installed RHEL 7.4 how to configure wifi ???

  2. zero liquid discharge India says:

    I like the helpful information you provide to your articles.
    I’ll bookmark your blog and take a look at once more right here frequently.
    I am somewhat certain I’ll learn many new stuff right here!
    Good luck for the next!

Leave a Reply

Your email address will not be published.