How to add a virtual IP address (VIP) to centos 7 in Linux O & M

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.