nmcli examples. nmcli cheatsheet in CentOS/RHEL 7/8. nmcli command exmaples. nmcli con reload. nmcli help. add ethernet connection using nmcli. nmclic command examples cheatsheet in linux. add bond connection using nmcli in linux. add and configure network teaming using nmcli. nmcli command cheatsheet. configure networkmanager using nmcli. nmcli examples. nmclic command examples cheatsheet. exit an existing connection with nmcli. nmcli command examples. nmcli enable dhcp. man nmcli examples. nmcli rename connection. nmcli remove static ipv4 address. nmcle cheat sheet. nmcli remove dns

Understanding nmcli

  • nmcli is a command-line tool for controlling NetworkManager and reporting network status.
  • It can be utilised as a replacement for nm-applet or other graphical clients. nmcli is used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status.
  • Connections are stored in configuration files
  • The NetworkManager service must be running to manage these files

Compare nm-settings with ifcfg-* directives (IPv4)

nmcli con mod ifcfg-* file Effect
ipv4.method manual BOOTPROTO=none IPv4 address configured statically
ipv4.method auto BOOTPROTO=dhcp Will look for configuration settings from a DHCPv4 server
ipv4.address "" IPADDR=
Set static IPv4 address, network prefix
ipv4.gateway GATEWAY= Set IPv4 Gateway
ipv4.dns DNS1= Modify /etc/resolv.conf to use this nameserver
ipv4.dns-search example.com DOMAIN=example.com Modify /etc/resolv.conf to use this domain in the search directive
ipv4.ignore-auto-dns true PEERDNS=no Ignore DNS Server information from the DHCP Server
connection.autoconnect yes ONBOOT=yes Automatically activate this connection on boot
connection.id eth0 NAME=eth0 The name of this connection
connection.interface-name eth0 DEVICE=eth0 The connection is bound to the network interface with this name
802-3-ethernet.mac-address 08:00:27:4b:7a:80 HWADDR=08:00:27:4b:7a:80 The connection is bound to the network interface with this MAC Address
ipv4.never-default no DEFROUTE=yes Never use provided interface’s gateway as default gateway

Compare nm-settings with ifcfg-* directives (IPv6)

nmcli con mod ifcfg-* file Effect
ipv6.method manual IPV6_AUTOCONF=no IPv6 is configured statically
ipv6.method auto IPV6_AUTOCONF=yes Will configure network settings using SLAAC from router advertisements.
ipv6.method dhcp IPV6_AUTOCONF=no
Will configure network settings by using DHCPv6, but not SLAAC
ipv6 . addresses
"2001:db8::a/64 2001:db8::1"
Sets static IPv6 Address and Gateway
ipv6.dns . . . DNS0=. . . Modify /etc/resolv.conf to use this nameserver
ipv6.dns-search example.com DOMAIN=example.com Modify /etc/resolv.conf to use to use this domain in the search directive
ipv6.ignore-auto-dns true IPV6_PEERDNS=no Ignore DNS server information from the DHCP server
connection.autoconnect yes ONBOOT=YES Automatically activates the connection at boot
connection.id eth0 NAME=eth0 The name of this connection
connection.interface-name eth0 DEVICE=eth0 The connection is bound to this network interface with this name
802-3-ethernet.mac-address . . . HWADDR=. . . The connection is bound to the network interface with this MAC Address

Brief list of nmcli commands syntax

Command Purpose
nmcli dev status Show the Network Manager status of all network interfaces
nmcli con show List all connections
nmcli con show name List the current settings for the connection name
nmcli con add con-name name .. Add a new connection named name
nmcli con mod name .. Modify the connection name
nmcli con reload Tell networkManager to reread the configuration files (useful after they have been edited by hand)
nmcli con up name Activate the connection name
nmcli dev dis dev Deactivate and disconnect the current connection on the network interface dev
nmcli con del name Delete the connection name and its configuration file

nmcli command examples (cheatsheet)

Below are some of the chosen nmcli command examples

1. Check if NetworkManager is running

You can use below command to check if NetworkManager is running or not

To get a general status

2. List all the available device

To view and list all the available devices on your Linux system

3. List all the available connections

To list all the available connections

4. List all the configuration of interface

To view all the configured values (default and custom) of an interface


5. Check physical network device status

Now the status of all the connection network devices

6. Change hostname using nmcli

You can ideally change hostname using hostnamectl command, but you can also update hostname using nmcli

To get the current hostname

Next to update the hostname

Verify the same

7. Create a new ethernet connection and assign static IP Address

In this example nmcli configures the eth2 interface statically, using the IPv4 address and network prefix and default gateway, but still auto connects at
startup and saves its configuration into /etc/sysconfig/network-scripts/ifcfg-eth2 file.

8. Create a new ethernet connection and assign DHCP IP Address

The following command will add a new connection for the interface eth2, which will get IPv4 networking information using DHCP and will autoconnect on startup. The configuration will be
saved in /etc/sysconfig/network-scripts/ifcfg-eth2 because the con-name is eth2

We can verify the same in the mapped interface configuration file


9. Create and configure bond connection (active-backup) with two slave interface

You can create bond connection with multiple slave interface using nmcli.

Delete any configuration file which exists for slave interface

Add bond interface using nmcli. This command adds a master bond connection, naming the bonding interface mybond0 and using active-backup mode. I have given some dummy values for MII, UPDELAY and DOWNDELAY. If you wish to add primary interface using “primary=<ifname>

Similarly for round-robin bonding you can use bond.options as “downdelay=5,miimon=100,mode=balance-rr,updelay=10

Next add the slaves for mybond0 using nmcli. This command binds first slave to eth1 interface

This command binds slave 2 to eth2 interface

List the active connections. So we have our bond and slave interface with us.


Here I am setting static IP Address, NetMask, Gateway, DNS and DNS Search to mybond0 using nmcli


To use DHCP IP, use ipv4.method auto and do not provide any IP Address related details in the above command

Verify your mybond0 configuration file

refresh/reload the network configuration change for mybond0

Verify the bond IP Address

Verify the list of available connection

10. Create and configure Network Bridge

I have written another article with detailed steps to create and configure network bridge using nmcli and nmtui separately on RHEL/CentOS 7 and 8 Linux.

11. Create and configure Network Teaming

I have written another article with detailed steps to create and configure NIC teaming with two slaves using nmcli validated on RHEL/CentOS 7/8 Linux

12. Reload connection using nmcli (restart)

Reload all connection files from disk. NetworkManager does not monitor changes to connection files by default. So you need to use this command in order to tell NetworkManager to re-read the connection profiles from disk when a change was made to them.


13. Interactively add/edit a connection

You can use nmcli con edit to Edit an existing connection or add a new one, using an interactive editor. In the below example we will edit eth1’s IP Address

Now verify your changes in eth1’s configuration file

14. Change ethernet connection BOOTPROTO from DHCP to Static

Now to change ethernet connection BOOTPROTO from DHCP to static using nmcli, we must modify ipv4.method directive to use manual

Now verify the network configuration file for eth2

15. Change ethernet connection BOOTPROTO from Static to DHCP

Similarly to change ethernet connection BOOTPROTO from static to DHCP using nmcli, we must modify ipv4.method directive to use auto

Now verify the eth2 network configuration file

As you see we still have IPADDR and other variables from previous command but they are considered null, because you can see my DHCP has assigned to eth2


16. Change ONBOOT directive using nmcli

By default ONBOOT is yes in the interface configuration file. So to disable ONBOOT we must modify connection.autoconnect directive using nmcli

Verify the ONBOOT value before changing this directive

Change ONBOOT directive, disable ONBOOT using nmcli

Re-verify the ONBOOT directive for eth2

17. Change DEFROUTE directive (Never use this network for default route)

By default any gateway we add for any ethernet connection will also be considered as default gateway, to turn off this directive use ipv4.never-default with nmcli

Before we make any change verify DEFROUTE directive in the eth2 configuration file

So by default this directive is ON, we will disable the default gateway option for eth2. To turn off this directive we must select ipv4.never-default as “yes

Next verify the DEFROUTE directive for eth2


18. Disable IPv6 Address for ethernet connection (IPV6INIT)

By default both IPv4 and IPv6 connection type (IPV6INIT) is enabled for any ethernet connection type. To only use IPv4 and disable IPv6 using nmcli

Verify the existing status of IPv6 connection type for eth2

So this is enabled, we will disable IPv6 connection type using ipv6.method directive with nmcli

Now re-verify the IPV6INIT directive from eth2 config file

19. Change “Automatically Connect” Directive

By default any ethernet connection will be allowed to automatically connect, you can modify this using

20. Add or Modify DNS to existing connection

You can use ipv4.dns to add DNS server to an new connection or modify any existing connection using nmcli.
Currently there are no DNS server IP provided for eth1

Next modify connection to add DNS Server IP Address

Verify the eth1 config file

21. Append single/multiple DNS Server to connection

Use + prefix with ipv4.dns to append new DNS IP Addresses to an existing connection using nmcli. In the previous example we added as my DNS server for eth1. Now we will append to the same connection

Verify the eth1 configuration file

22. Remove single/multiple DNS Server from connection

As it is understood, with + we append so with – we remove single/multiple entries of DNS Server from the interface connection using nmcli.

Verify the eth1 configuration file

23. Display selected fields with values of connection

You can list all the configured values of a connection using “nmcli con show <ifname>” but that gives you a long list of details, you can actually also get selected value of the provided directive of an individual connection

To get the IPv4 Address of eth1

You can use -g to print values from specific fields using nmcli

But here as you see we do not get a field to value mapping. You can use -f to specify what fields (column names) should be printed using nmcli. Valid field names differ for specific commands. List available fields by providing an invalid value to the --fields option.

24. Monitor connection and device activity

Using nmcli monitor you can observe NetworkManager activity. Watches for changes in connectivity state, devices or connection profiles. Here in this example we will execute nmcli monitor for eth1 in one terminal, and on the other terminal we will make some modification to eth1 connection

As you see, after the modification, the monitor command gives below output

25. Activate a connection

Just opposite to what we used above, we will use nmcli con up

Verify the list of available connection

26. De-activate a connection

Deactivate a connection from a device without preventing the device from further auto-activation using nmcli con down <ifname>. Multiple connections can be passed to the command.

Verify the list of active connections


If you are connected to your server using this interface then your connection would close once the connection is de-activated

27. Delete connection

lastly in nmcli command examples, you can delete all type of available connection using “nmcli con del <ifname>

Lastly I hope the steps from the article with nmcli command examples (cheatsheet) on Linux was helpful. So, let me know your suggestions and feedback using the comment section.


man page nmcli
man page nmcli-examples

Problem: During installation of CentOS the installer screen goes black. The terminal multiplexer is running in virtual console 1. To switch from the graphical installation environment to tmux, press Ctrl+Alt+F1. To go back to the main installation interface which runs in virtual console 6, press Ctrl+Alt+F6. Available tmux Windows Shortcut Contents Ctrl+b 1 Main installation […]

  1. In /etc/init.d/checkfs.sh is the line if [ -f /forcefsck ] || grep -s -w -i "forcefsck" /proc/cmdline, so providing forcefsck on the kernel command line or generating a /forcefsck file on shutdown should cause an fsck on the next reboot.

    To prevent manual fsck runs, ask fsck to try to automatically fix errors with the -y option by uncommenting and changing no to yes in the following /etc/default/rcS entry, after the edit it should look like:

  1. One option (forcefsck or FSCKFIX) does not imply the other.
  1. according to manpages -c argument for tune2fs counts number of instances of mounts for a partition. Hence, 1 forces to check the fs after every mounting instance. (http://man7.org/linux/man-pages/man8/tune2fs.8.html)

Read more

General Approach

To check what setting your system is using, use ‘sysctl name’ (e.g.: ‘sysctl net.ipv4.tcp_rmem’). To change a setting use ‘sysctl -w’. To make the setting permanent add the setting to the file ‘sysctl.conf’.

More Reading:



Using package-cleanup command which is a part of yum-utils package we can uninstall any number of old kernels automatically. As an example using --oldkernels --count=2 option with package-cleanup command the command will remove all unused kernel while keeping last three most recent kernel versions installed.


list installed kernels

remove kernels no longer needed; listed above


By default CentOS will keep last 5 kernels installed on your system. This behavior is defined by installonly_limit=5 line within /etc/yum.conf file. Update the /etc/yum.conf configuration file appropriately to keep desired number of old kernels on your system after update. The minimum value to be set is 2.

Example of /etc/yum.conf configuration file to keep only last two kernel versions:

read more: linuxconfig.org

ZFS – Downgrade Commands for Centos:

To do the downgrade/re-install dance:

ZFS tuning for SAS3 Storage Tank

ZFS tuning for SAS3 ALL SSD + nVME Storage Tank

Some more good advice:



ZFS – SNMP Extend Commands:



A Comparison of Features in Bonding and Team

Feature Bonding Team
broadcast Tx policy Yes Yes
round-robin Tx policy Yes Yes
active-backup Tx policy Yes Yes
LACP (802.3ad) support Yes (active only) Yes
Hash-based Tx policy Yes Yes
User can set hash function No Yes
Tx load-balancing support (TLB) Yes Yes
LACP hash port select Yes Yes
load-balancing for LACP support No Yes
Ethtool link monitoring Yes Yes
ARP link monitoring Yes Yes
NS/NA (IPv6) link monitoring No Yes
ports up/down delays Yes Yes
port priorities and stickiness (“primary” option enhancement) No Yes
separate per-port link monitoring setup No Yes
multiple link monitoring setup Limited Yes
lockless Tx/Rx path No (rwlock) Yes (RCU)
VLAN support Yes Yes
user-space runtime control Limited Full
Logic in user-space No Yes
Extensibility Hard Easy
Modular design No Yes
Performance overhead Low Very Low
D-Bus interface No Yes
multiple device stacking Yes Yes
zero config using LLDP No (in planning)
NetworkManager support Yes Yes

Read More: RHEL

Config Snippets:

  • CentOS 7
  • No NetworkManager

NEXUS vPC Switch A:

NEXUS vPC Switch B:

CentOS 7 Server – Config: nas-a:

CentOS 7 Server – Config: nas-a:

CentOS 7 Server – Show Commands:

I want to update my sources.list file with the fastest server from the command line in a fresh Ubuntu Server install. I know this is trivially easy with the GUI, but there doesn’t seem to be a simple way to do it from from the command line?

Automated Process

If you want a utility to do this you could implement such a utility as a simple bash script like the following.

 Read More