How to add a virtual IP address (VIP) to centos 7 in Linux O & M
The role of virtual ip in high availability will be discussed later. Today, let's look at how to configure a virtual IP address for the server, that is, to allocate multiple IP addresses.
① First check the IP address of the existing Nic and run the following command with the root privilege:
Ip addr
Sample output:
From the above details, we can see that the server's Nic name is eno16777736, And the IP address is 192.168.22.227.
The NIC configuration file is stored in the/etc/sysconfig/network-scripts/directory. The details for each NIC are stored in different names, such as ifcfg-eno16777736.
② Open this configuration file and add another IP Address
Edit file/etc/sysconfig/network-scripts/ifcfg-eno16777736:
Vi/etc/sysconfig/network-scripts/ifcfg-eno16777736
Add additional IP addresses as follows.
In this way, an IP address is added: IPADDR1 = "192.168.22.231". Of course, you can also add more IP addresses .?
IPADDR2 = "192.168.22.20 ″...
Finally, save and exit the file. Shortcut Key: shift + z
Restart the network service to make the change take effect.
Systemctl restart network
③ Check whether an IP address is added.
Enter the following command:
Ip addr
Sample output:
As you can see, a single Nic already has two IP addresses.