Monday, January 5

How to assign static IP address in RHEL/CentOS 7.X

                       


If you want to set up a static IP address on a network interface in RHEL/CentOS 7, see the below steps to setup static IP in ur Server.

Step1: To verify the status of Network Manager service

   [root@bsrtech ~]# systemctl status NetworkManager.service

                                                       


output of nmcli shows "connected" for a particular interface, it means that the interface is managed by Network Manager.

Step2: To check which network interface is managed by Network Manager

   [root@bsrtech ~]# nmcli dev status

                                                 
                                                  

Step3 : Assign Static IP Address 

Go to the "/etc/sysconfig/network-scripts" directory, then open configuration file "ifcfg-enp0s3" (in CentOS "ifcfg-ens192").Create it if not found.

 [root@bsrtech ~]# cd /etc/sysconfig/network-scripts/

                                


 [root@bsrtech ~]# vim ifcfg-enp0s3

                                                             
                                             

  In the above file 
   
    "BOOTPROTO=static" means assign ip through manually.
    "ONBOOT=yes" means system to bring up the interface during boot. 

Step4: Save the changes and restart the network services using below command

   [root@bsrtech ~]# systemctl restart network.service

 Chech the IP address is assigned or not 

   [root@bsrtech ~]# ip a  

           (or) 
   [root@bsrtech ~]# ifconfig 

                                                         
                                               


       If you want to assign static IP with Network Manager, see below steps

Before using nmtui, first set "NM_CONTROLLED=yes" in /etc/sysconfig/network-scripts/ifcfg-enp0s3.

Step1: Install nmtui package using rpm or yum

  [root@bsrtech ~]# yum install NetworkManager-tui

Step2: Edit the configuration file using nmtui command

  [root@bsrtech ~]# nmtui edit enp0s3

                                                                 


Step3: Now restart the network service and see the Static IP

[root@bsrtech ~]# systemctl restart network.service

 Chech the IP address is assigned or not 

   [root@bsrtech ~]# ifconfig
  

Related post:
Assign virtual IPs to a single network interface in RHEL/CentOS 7.X

No comments:

Post a Comment

:: Linux - Legends ::