Home / RHEL7 / RHEL – 7 Managing the network with Network Manager

RHEL – 7 Managing the network with Network Manager

In the last article, we have seen that how to review the current network configuration in RHEL 7. Redhat has introduced the profile based network management on Redhat Enterprise Linux 7. Network manager is a daemon that monitors and manages the network settings. Network manager can be managed using nmcli and other graphical tools. These tools will automatically update /etc/sysconfig/network-scripts  in the back-end.  Since commands and graphical tools are updating the network configuration files, human errors are eliminated.

Let’s explore the Network Manager.

1. List the existing network connections details.

[root@server1-UA ~]# nmcli con show
NAME         UUID                                  TYPE            DEVICE
System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  eth0
[root@server1-UA ~]# 
[root@server1-UA ~]#nmcli dev show eth0
GENERAL.DEVICE:                         eth0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         52:54:00:00:01:0B
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     System eth0
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         ip = 172.25.2.251/16, gw = 0.0.0.0
IP4.DNS[1]:                             172.25.2.250
IP6.ADDRESS[1]:                         ip = fe80::5054:ff:fe00:10b/64, gw = ::
[root@server1-UA ~]#

2.Create the new connection named “UA_NEW” which will automatically connect as an Ethernet connection eth0 device using DHCP.

[root@server1-UA ~]#nmcli con add  con-name "UA_NEW" type ethernet ifname eth0
Connection 'UA_NEW' (c511f74e-37f6-4746-ac15-be689210698b) successfully added.
[root@server1-UA ~]# nmcli con show
NAME         UUID                                  TYPE            DEVICE
UA_NEW       c511f74e-37f6-4746-ac15-be689210698b  802-3-ethernet  --
System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  eth0
[root@server1-UA ~]#

3.Bring up the connection “UA_NEW”.

[root@server1-UA ~]#nmcli connection up UA_NEW
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1)
[root@server1-UA ~]# nmcli con show
NAME           UUID                                  TYPE            DEVICE
UA_NEW         c511f74e-37f6-4746-ac15-be689210698b  802-3-ethernet  eth0
System eth0    5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  --
[root@server1-UA ~]#

4. If you would like to configure the static IP for the new connection, you need to specify the IP address and gateway.

[root@server1-UA ~]#nmcli con add  con-name "UA_NEW-STATIC"  ifname eth0 autoconnect no type ethernet ip4 192.168.0.10/24 gw4 192.168.0.254
Connection 'UA_NEW-STATIC' (07279c85-6af2-4588-9313-cfb01ac1adae) successfully added.
[root@server1-UA ~]# nmcli con show
NAME           UUID                                  TYPE            DEVICE
UA_NEW-STATIC  07279c85-6af2-4588-9313-cfb01ac1adae  802-3-ethernet  --
UA_NEW         c511f74e-37f6-4746-ac15-be689210698b  802-3-ethernet  eth0
System eth0    5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  --
[root@server1-UA ~]#

5. Bring up the connection “UA_NEW-STATIC”

[root@server1-UA ~]#nmcli connection show
NAME           UUID                                  TYPE            DEVICE
UA_NEW-STATIC  07279c85-6af2-4588-9313-cfb01ac1adae  802-3-ethernet  eth0
UA_NEW         c511f74e-37f6-4746-ac15-be689210698b  802-3-ethernet  --
System eth0    5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  --
[root@server1-UA ~]#ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP ql                                                                                        en 1000
    link/ether 52:54:00:00:01:0b brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe00:10b/64 scope link
       valid_lft forever preferred_lft forever
[root@server1-UA ~]#

We have successfully configured the static IP for the interface eht0 using nmcli command.

If you would like to switch it back to other profile , just active the connection.

[root@server1-UA ~]#nmcli connection up "System eth0"
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[root@server1-UA ~]#nmcli connection show
NAME           UUID                                  TYPE            DEVICE
UA_NEW-STATIC  07279c85-6af2-4588-9313-cfb01ac1adae  802-3-ethernet  --
UA_NEW         c511f74e-37f6-4746-ac15-be689210698b  802-3-ethernet  --
System eth0    5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  eth0
[root@server1-UA ~]#

6. How to configure the second IP on the existing network connection profile ?

We can add the additional IP on the existing connection  using “+” symbol. Here I am adding IP 192.168.0.20/24 and gateway 192.168.0.254 to the existing network connection “System eth0”.

[root@server1-UA ~]#nmcli con mod "System eth0" +ipv4.addresses "192.168.0.20/24 192.168.0.254"
[root@server1-UA ~]#ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:00:01:0b brd ff:ff:ff:ff:ff:ff
    inet 172.25.2.251/16 brd 172.25.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe00:10b/64 scope link
       valid_lft forever preferred_lft forever
[root@server1-UA ~]#

But it’s not reflecting the in “ip” command output. Let me bring the connection “up” again.(To refresh the connection)

[root@server1-UA ~]#nmcli con up "System eth0"
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
[root@server1-UA ~]#ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:00:01:0b brd ff:ff:ff:ff:ff:ff
    inet 172.25.2.251/16 brd 172.25.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.0.20/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe00:10b/64 scope link tentative
       valid_lft forever preferred_lft forever
[root@server1-UA ~]#

We can see that both the IP’s are up on the network connection “System eth0”.

7. How to add the DNS server details using nmcli command ?

In RHEL 7 , /etc/resolv.conf will be managed by Network manager . So you need to use nmcli/nmtui command to up date the DNS server details ans domain name.

Here is my current /etc.resolv.conf file .

[root@server1-UA ~]#cat /etc/resolv.conf
# Generated by NetworkManager
search example.com
nameserver 172.25.2.251

Let me set the new DNS server IP using nmcli command.

[root@server1-UA ~]#nmcli con mod "System eth0" ipv4.dns 172.25.2.250

Bring up the connection and check the resolv.conf file. You can see the new changes.

[root@server1-UA ~]#nmcli con up "System eth0"
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/12)
[root@server1-UA ~]#
[root@server1-UA ~]#cat /etc/resolv.conf
# Generated by NetworkManager
search example.com
nameserver 172.25.2.250
[root@server1-UA ~]#

Same way , you can update the domain name also.

[root@server1-UA ~]#nmcli con mod "System eth0" ipv4.dns-search example.com
[root@server1-UA ~]#nmcli con reload "System eth0"

Hope this article is informative to you. If you are not comfortable with nmcli command, you can use nmtui which is text user interface. The next article will talk about “nmtui”.

To get the regular updates from UnixArena, Follow on

VMTURBO-CLOUD-CAPACITY

Leave a Reply

Your email address will not be published. Required fields are marked *