Wednesday, August 29, 2018

Configuring networking in RHEL7 using nmcli tool

To configure networking (IP addressing) in Red Hat Enterprise Linux 7 using 'nmcli' tool

To view existing Network profiles:

# nmcli connection show

To add new connection named 'dynamic' using DHCP:

# nmcli connection add con-name dynamic type ethernet ifname eth0

To enable the newly created network profile use:

# nmcli connection up dynamic

To view all IP details after enabling the new network profile:

# nmcli connection show dynamic | grep -i ip

Or

# ip addr show eth0

Now let's see if  you want to create a network profile name 'mynetwork' with Static IP addressing:

# nmcli connection add con-name mynetwork type ethernet ifname eth0 ip4 192.168.0.1/24 gw4 192.168.0.254

To check use:

# nmcli connection show

To enable the newly created 'mynetwork' connection profile:

# nmcli connection up mynetwork

To verify:

# ip addr show eth0

To view detailed output of IP settings of new profile:

# nmcli connection show mynetwork | less

Since we did not add DNS settings in our previous created profile we use:

# nmcli connection modify mynetwork ipv4.dns 192.168.0.250

To verify:

# nmcli connection show mynetwok | grep -i dns

To apply additional DNS try:

# nmcli connection modify mynetwork +ipv4.dns 8.8.8.8

To apply try:

# nmcli connection reload

Or

# nmcli connection down mynetwork ; nmcli connection up mynetwork

Now check:

# cat /etc/resolv.conf


HTH

No comments:

Post a Comment