HowTo Assign Static IP Address RHEL 7 Without Editing Config File

In this post we are going to see about HowTo Assign Static IP Address RHEL 7 without editing config file. See this Network profiles you can understand better about creating connections.

Actually in RHEL 7 Or Centos 7 you can create N number of profiles which are like set of IP configuration, anyone one of the profile can be activated.

HowTo Assign Static IP Address RHEL 7

As like RHEL 5 or RHEL 6 no need of editing configuration file to assign static IP address, using nmtui, nmcli or even GUI tools you can simply assign static IP address.

In order to create connection profile you must be privileged user or sudo user

network connections rhel 7

network connections rhel 7

as shown in above screenshot ens192 is the connection name and ens192 is the device name, let’s create new connection profile

Method #1 nmcli

# nmcli connection add type ethernet con-name home ifname ens192
Connection 'home' (432ebf4e-2765-47d7-86a5-1ede59cd7555) successfully added.

# nmcli connection modify home ipv4.addresses 192.168.2.6/24 ipv4.gateway 192.168.2.1 ipv4.dns 192.168.2.10 +ipv4.dns 4.4.4.4
create connection and assign static IP

create connection and assign static IP

  • con-name (connection name) – any name you can provide
  • ifname (Interface device name) – you have to choose NIC device name

using above command nmcli, it will automatically generates the configuration file for you

# cat /etc/sysconfig/network-scripts/ifcfg-home
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=home
UUID=432ebf4e-2765-47d7-86a5-1ede59cd7555
DEVICE=ens192
ONBOOT=no
IPADDR=192.168.2.6
PREFIX=24
GATEWAY=192.168.2.1
DNS1=192.168.2.10
DNS2=4.4.4.4

change back the BOOTPROTO from dhcp to none so that IP is static

# nmcli connection modify home ipv4.method manual

That’s it about method #1 assign static ip address rhel 7

Method #2 using nmtui utility

If you would like to use nmtui utility you have to install NetworkManager rpm

[root@rhel7 ~]# rpm -qa |grep NetworkManager
NetworkManager-glib-1.10.2-16.el7_5.x86_64
NetworkManager-wifi-1.10.2-16.el7_5.x86_64
NetworkManager-tui-1.10.2-16.el7_5.x86_64
NetworkManager-1.10.2-16.el7_5.x86_64

Open nmtui utility simply typing nmtui command on command line

# nmtui
nmtui window

nmtui

select Edit a connection hit enter

add new connection nmtui

add new connection nmtui

Select Add by hitting tab button hit enter

new ethernet connection

new ethernet connection

type connection Ethernet click on create

edit connection nmtui

edit connection nmtui

Fill the details Profile Name, Device,  IPV4 Configuration = Manual, IP Address, Gateway, DNS, Search Domain name and Click OK

# nmcli connection show
NAME UUID TYPE DEVICE
ens192 52ba8d69-edbb-421c-ac42-58e69f56ab30 ethernet ens192
virbr0 3a2dd842-914e-4420-82a8-8890fb89f2bf bridge virbr0
New_Connection 7908a85e-9918-4020-830e-bf01b08a8f36 ethernet --
home 432ebf4e-2765-47d7-86a5-1ede59cd7555 ethernet --

That’s it new connection got create if you want to bring connection up use below command

# nmcli connection up New_Connection

Assign Static IP Address RHEL 7 using above two methods

Related Articles

nmcli command line guide

nmcli part-2

Thanks for your wonderful Support and Encouragement

blank

ARK

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published.