Monday, January 5

How to configure virtual IPs to a single network interface in RHEL/CentOS 7.X


If you want to set up a virtual IP addresses on a single network interface in RHEL/CentOS 7, 
easily add multiple IP addresses to a single network interface in RHEL/CentOS 7 without the need for additional NICs.

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

   [root@bsrtech ~]# nmcli dev status
Step2 : Assign Virtual IPs to a single LAN card.

               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/

Before edit,copy the configuration file in /tmp directory for backup. 

 [root@bsrtech network-scripts]# cp  ifcfg-enp0s3    /tmp/ifcfg-enp0s3   
           [root@bsrtech network-scripts]# vim ifcfg-enp0s3

 In this configuration file, look for the line for "IPADDR0". Copy this line and paste it at the bottom of the configuration, incrementing the ID from "IPADDR0" to "IPADDR" and entering an unused IP address in the subnet. Repeat this process for as many IPs as your requirement.

          # Virtual IP addresses.

 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 Virtual IPs are assigned or not 

   [root@bsrtech ~]# ip a   
   [root@bsrtech ~]# ip addr 

No comments:

Post a Comment

:: Linux - Legends ::