Setting up network using a NetworkManager command line interface (nmcli) in Red Hat 7

Red Hat Enterprise Linux 7: The Complete Guide to setting up network using a NetworkManager command line interface (nmcli).

On your exam you may already have a NetworkManager connection on the server.

A) If you don’t have any NetworkManager connection on your exam:

A.1) Add new NetworkManager connection:

nmcli con add con-name "rhcsa_1" ifname eth0 type ethernet ip4 172.16.99.204/24 gw4 172.16.99.1
nmcli con mod "rhcsa_1" ipv4.dns "8.8.8.8 208.67.222.222"
nmcli con mod "rhcsa_1" ipv4.method manual
nmcli con mod "rhcsa_1" connection.autoconnect yes
nmcli con mod "rhcsa_1" +ipv4.dns 8.8.4.4

A.2) Activate new NetworkManager connection:

nmcli con up "rhcsa_1"

A.3) Verify NetorkManager connection and /etc/resolv.conf file:

nmcli con show "rhcsa_1"
cat /etc/resolv.conf

B) If you already have NetworkManager connection on your exam:

B.1) Add another NetworkManager connection:

nmcli con add con-name "rhcsa_1" ifname eth0 type ethernet ip4 172.16.99.204/24 gw4 172.16.99.1
nmcli con mod "rhcsa_1" ipv4.dns "8.8.8.8 208.67.222.222"
nmcli con mod "rhcsa_1" ipv4.method manual
nmcli con mod "rhcsa_1" connection.autoconnect yes

B.1.2) Activate new NetworkManager connection:

nmcli con up "rhcsa_1"

B.1.3) Disable old NetworkManager connection to Automatically connect during system start-up:

nmcli con mod "System eth0" connection.autoconnect no

B.1.4) Check NetworkManager connections and verify new NetworkManager connection:

nmcli con show
nmcli con show --active
nmcli con show "rhcsa_1"

B.1.5) Optional – remove old unwanted NetworkManager connection:

nmcli con del "System eth0"

B.2) Edit already existing NetworkManager connection:

nmcli con mod "System eth0" ipv4.addresses 172.16.99.204/24
nmcli con mod "System eth0" ipv4.gateway 172.16.99.1
nmcli con mod "System eth0" ipv4.dns "8.8.8.8 208.67.222.222"
nmcli con mod "System eth0" ipv4.method manual
nmcli con mod "System eth0" connection.autoconnect yes

B.2.1) Activate updated NetworkManager connection:

nmcli con up "System eth0"

B.2.2) Verify updated NetworkManager connection:

nmcli con show "System eth0"

NOTE: You can add more IP addresses to your NetworkManager connection:

nmcli con mod "System eth0" +ipv4.addresses 10.100.1.99/24

Configure network using network interface configuration files and NetworkManager:
vi /etc/sysconfig/network-scripts/ifcfg-<connection_name>

Once network interface configuration file will be updated, please run below three commands to pick up changes:
nmcli con reload
nmcli con down <connection_name>
nmcli con up <connection_name>

NOTE: Please do not deactivate NetworkManager connection using “nmcli con down <connection_name>” command if you are connected to server remotely using that connection, because you will not get a chance to activate it back. In such case try:

nmcli con down <con_name> && nmcli con up <con_name>
or
systemctl restart network

Use man nmcli-examples for variety of examples:

man nmcli
man nmcli-examples

To check your IP address, please use “ip a” command:

ip a

To verify your default gateway, please use “ip r” command:

ip r

To verify DNS servers configuration, please use dig command:

dig redhat.com

NOTE: you need to install bind-utils package for dig command.

You can also try to ping some remote server:
ping redhat.com

Useful nmcli commands:

To see a list of network devices and their state:

nmcli dev
or
nmcli dev status

Show detailed information about devices:
nmcli dev show
and
nmcli dev show <device>

To bring down an interface and temporarily disable autoconnect use command:

nmcli dev dis <device>

Connect the device.

nmcli dev con <device>

To disable or enable all managed interfaces use command:

nmcli net off
nmcli net on

To turn off wifi:

nmcli r wifi off

Related Video Tutorials:

Red Hat Enterprise Linux v7 networking

Calculate netmask, network and broadcast address – EASY!

Network Interface naming convention in Red Hat 7

Setting up network without NetworkManager in Redhat 7

Setting up network using NetworkManager and network scripts in Redhat 7

Setting up network using a NetworkManager text user interface (nmtui) in Red Hat 7 – EASY!!!

Setting up network in Red Hat 7 in less than a minute – QUICK & EASY!!!

Setting up network using a NetworkManager command line interface (nmcli) in Red Hat 7

nmcli cheat! Setting up network using nmcli in Red Hat 7 in less than a 30 seconds – QUICK & EASY!!!

Setting up network using a NetworkManager connection editor GUI tool in Red Hat 7 – EASY!!!

Complete Beginners Guide to Linux Network Configuration – GUI & Easy!

NetworkManager connection priority – manage network profile priority in Linux.