This blog is written because this technology is needed later when keepalived is used to achieve Nginx high availability. 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: ipaddr sample output: From the above details, we can see that the nic name of the server is eno16777
This blog is written because this technology is needed later when keepalived is used to achieve Nginx high availability. 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.