Easy step to configure Network Using NMCLI in RHEL7


blog_demo

REDHAT07-09-17

Nmcli is a command-line tool for controlling and getting network status. The main nmcli’s usage is on servers, headless machines or just for power users who prefer the command line for changing the network parameter. In Red Hat Enterprise Linux 7, the default networking service is provided by NetworkManager, which is a dynamic network control and configuration daemon that attempts to keep network devices and connections up and active when they are available. The basic format of a command is as follows:

nmcli [ OPTIONS ] OBJECT { COMMAND | help }

In this blog we will configure network with the help of nmcli tool. First of all, we will install the Network Manager Package and make it enable as following command:

Steps For configure Network Manager:

Step 1:-

#Step 1:- # yum install NetworkManager

Step 2:-

# systemctl status NetworkManager

Step 3:-

# systemctl start NetworkManager

# systemctl enable NetworkManager

Step 4:-

In network configuration is to show the overall status of NetworkManager:

# nmcli general status

Step 5:-

Now to show all connections or to list the currently available network connections run the following command:

# nmcli connection show

Step 6:-

Now to add an Ethernet configuration profile with dynamic IP configuration, a command in the following format can be used:

# nmcli connection add type ethernet con-name grras ifname eth0

Step 7:-

Now if we want to assign static IPv4 configuration then command in the following format can be used:

# nmcli connection modify ipv4.addresses ‘192.168.10.10/24’ ipv4.method manual

IPv6 address and gateway information can be added using the ip6 and gw6 options.

Step 8:-

To bring up the Ethernet connection, issue a command as follows:

# nmcli connection up grras

Step 9:-

Now we learn to modify the network interfaces with the nmcli command. Here we are going To set IPv4 DNS server address

#nmcli connection modify grras ipv4.dns “192.188.8.8”

Step 10:-

Now to bring up the new Ethernet connection, issue a command as follows:

# nmcli connection up grras