How to Configure Virtual IP Address (VIP) on CentOS

As its name suggests, Virtual IP address (VIP) is an IP address that doesn’t have an actual physical network interface. Incoming packets are sent to the VIP, but all packets travel through the real network interfaces.

Virtual IP address is commonly used for database high availability. Applications use it for database connections instead of the normal host IP address. When the active database fail, the VIP will be shifted to the newly promoted host.

Run this command to show the current network configuration and see the configured network interface of the server:

ip addr show
ipaddr is …41

From the above output, we can see that the network interface isย ens192

The configuration file for theย  ens192 network interface can be found in:
/etc/sysconfig/network-scripts.

In order to create a virtual network interface, we need to copy first the master configuration file.

cd /etc/sysconfig/network-scripts/

cp ifcfg-ens192 ifcfg-ens192:1

Edit its content to set an appropriate network interface name and IP address – DEVICENAMEIPADDR in the virtual network configuration file.

/etc/sysconfig/network-scripts/cat ifcfg-ens192

/etc/sysconfig/network-scripts/cat ifcfg-ens192:1

Once you have edited the virtual network interface file, restart the network service.

Check your network settings again and youโ€™ll see the configured virtual network interface:

reference: https://www.codeproject.com/Tips/1272324/How-to-Configure-Virtual-IP-Address-VIP-on-CentOS