• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Configure nmcli Tool

{{postValue.id}}

To Configure and Manage Network Connections Using nmcli Tool

" nmcli" is the command line tool, used by both users and scripts for controlling the Network Manager. This article explains how to configure and manage network connections using nmcli tool.


To Check devices

Run the following command to check our devices.

[root@linuxhelp ~]# nmcli dev status
DEVICE          TYPE        STATE           CONNECTION
eno16777736     ethernet    connected       static1    
virbr0          bridge      disconnected    --      
virbr0-nic      ethernet    unavailable     --    
vmnet1          ethernet    unmanaged       --
vmnet8          ethernet    unmanaged       --        
lo              loopback    unmanaged       --         

We should set a “ connection profiles” for our devices to achieve network connectivity and perform their functions.

[root@linuxhelp ~]# cd /etc/sysconfig/network-scripts/
[root@linuxhelp network-scripts]# ls
ifcfg-lo          ifdown-ipv6      ifdown-tunnel   ifup-isdn      ifup-TeamPort
ifcfg-Myoffice1   ifdown-isdn      ifup            ifup-plip      ifup-tunnel
ifcfg-static1     ifdown-post      ifup-aliases    ifup-plusb     ifup-wireless
ifdown            ifdown-ppp       ifup-bnep       ifup-post      init.ipv6-global
ifdown-bnep       ifdown-routes    ifup-eth        ifup-ppp       network-functions
ifdown-eth        ifdown-sit       ifup-ib         ifup-routes    network-functions-ipv6
ifdown-ib         ifdown-Team      ifup-ippp       ifup-sit
ifdown-ippp       ifdown-TeamPort  ifup-ipv6       ifup-Team

The file-name starting with ifcfg- (interface configuration) are connection profiles. When we create a new connection or modify an existing one with nmcli or nmtui, the results are saved as connection profiles.

Here we are modifying, one with a DHCP configuration and another with static IP configuration.


Static IP configuration

[root@linuxhelp network-scripts]# cat ifcfg-static1

Display_Staticip


DHCP configuration

[root@linuxhelp network-scripts]# cat ifcfg-Myoffice1

Display_Interface
Explanation

  • GATEWAY - the gateway IP.
  • DNS1, DNS2 - to notify the two dns servers .
  • ONBOOT - helps the connection up on booting the system.
  • DEVICE - the name of the network device which is associated with this profile.
  • BOOTPROTO - if it has value “ dhcp” then our connection profile takes dynamic IP from DHCP server
  • if it has value “ none” then it takes no dynamic IP and probably we assign a static IP.
  • IPADDR - the static IP that we assign to our profile.
  • PREFIX - the subnet mask.

Run the following command to check the connection.

[root@linuxhelp network-scripts]# nmcli connection show

Network_Connections
The last column " device" shows us which connection is ' UP' .
Run the following command to check only the active devices.

[root@linuxhelp network-scripts]# nmcli connection show -a
NAME      UUID                                   TYPE              DEVICE
static1   d984b921-d708-4029-90a1-78b24078fbd1   802-3-ethernet    eno16777736

To check the IP Address, use " ip a" command.

[root@linuxhelp network-scripts]# ip a

ipaddress
Here, eno16777736 took the 192.168.7.56 IP from ethernet, because in the connection profile static1 which is up has a manual configuration.
To make a new ethernet connection with name Myhome1, assigned to device eno16777736

[root@linuxhelp network-scripts]# nmcli con add type ethernet con-name Myhome1 ifname eno16777736
Connection ' Myhome1'   (19a43cb0-699d-46a3-8ad3-aed336755879) successfully added.

To make a connection profile we must define type, ifname and con-name:
Now, Check its configuration by running the following command

[root@linuxhelp network-scripts]# cat ifcfg-Myhome1

Display_interface_details
You can note that BOOTPROTO=dhcp, as we didn' t give any static IP address.

We can modify any connection with the “ nmcli con mod“ command. However if you modify a DHCP connection and change it to " static" then you have to change its “ ipv4.method” from “ auto” to “ manual” . Otherwise you will get with two IP addresses: one from DHCP server and the static one.

Now lets make a new Ethernet connection profile with static2, which will be assigned to device eno16777736, with static IP 192.168.7.137, subnet mask 255.255.255.0=24 and gateway 192.168.1.1 . Then check its configuration.

[root@linuxhelp network-scripts]#nmcli con add type ethernet con-name static2 ifname eno16777736 ip4 192.168.7.137/24 gw4 192.168.7.1
 Connection ' static2'   (9ecfadc6-d0d6-437b-9b06-6aecd2baf0e5) successfully added.
[root@linuxhelp network-scripts]# cat ifcfg-static2

Display_Interface_Information
Now lets modify the last connection profile and add two dns servers.

[root@linuxhelp network-scripts]# nmcli con mod static2 ipv4.dns “ 8.8.8.8 8.8.4.4” 

When you add connections you use “ ip4” and “ gw4” , when you modify them you use “ ipv4” and “ gwv4” .
To bring up this connection profile.

[root@linuxhelp network-scripts]# nmcli con up static2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/39)

As you can see, the device eno16777736 has now IP address 192.168.7.137.

[root@linuxhelp network-scripts]# ip a

ipaddress
Type the following command with the connection name to get result of properties to be modified.

[root@linuxhelp network-scripts]# nmcli con show static2

Display_Connection_Information

When you bring down a connection profile, the Network Manager searches for another connection profile and brings it up automatically. If you don’ t want your connection profile to auto connect then run the following command

[root@linuxhelp network-scripts]# nmcli con mod static2 connection.autoconnect no

If you want to provide access only to specific user then type the following command.

[root@linuxhelp network-scripts]# nmcli connection modify static2 connection.permissions user1

To give permissions for more than one users, type user:user1,user2 without blank space between them.

[root@linuxhelp network-scripts]# nmcli con modify static2 connection.permissions user:user2,user3
[root@linuxhelp network-scripts]# nmcli con show static2

connection_details
If you login as another user you can’ t bring “ UP” this connection profile.

[root@linuxhelp network-scripts]#su - abc
Last login: Wed Apr 27 08:59:14 EDT 2016 on pts/1
[abc@linuxhelp ~]$
[abc@linuxhelp ~]$ nmcli con up static2
Error: Connection ' static2'  does not exist.
[abc@linuxhelp ~]$ ls /etc/sysconfig/network-scripts

Network_interface_configuration_files

Tags:
eli
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

Is there a way to change the existing IP address immediately from one command line

A

use nmcli editor by nmcli con mod net-eth0 ipv4.addresses "X.X.X.X" similarly set as manual

Q

Connection is always done after every reboot

A

Set nmcli connectio up interface name!!!

Q

Really good article!!! Very Useful!

A

Thank you for your appreciation

Q

How to set dns? Via command nmcli line?

A

nmcli con mod static2 ipv4.dns “8.8.8.8 8.8.4.4”

Q

What is the nmcli?

A

nmcli stands for Network Manager Command Line Interface.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ganesh Konka ?
Zentya 6.1 http proxy configuration

please send link for creating zentyal 6.1 for http proxy and firewall as gateway.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.