Updated on 2024-11-22 GMT+08:00

Virtual IP Address Overview

What Is a Virtual IP Address?

A virtual IP address is a private IP address that can be independently assigned from and released to a VPC subnet. You can:
  • Bind one or more virtual IP addresses to a cloud server so that you can use either the virtual IP address or private IP address to access the server. If you have multiple services running on a cloud server, you can use different virtual IP addresses to access them.
  • Bind a virtual IP address to multiple cloud servers. You can use a virtual IP address and an HA software (such as Keepalived) to set up a high-availability active/standby cluster. If you want to improve service availability and eliminate single points of failure, you can deploy cloud servers in the active/standby pair or deploy one cloud server and multiple standby cloud servers. In this case, the cloud servers can use the same virtual IP address. If the active cloud server goes down, the standby cloud server becomes the active server and continues to provide services.
Generally, cloud servers use private IP addresses for internal network communication. A virtual IP address has the same network access capabilities as a private IP address. You can use either of them to enable layer 2 and layer 3 communications in a VPC, access a different VPC using a peering connection, enable Internet access through EIPs, and connect the cloud and the on-premises servers using VPN connections and Direct Connect connections. Figure 1 describes how private IP addresses, the virtual IP address, and EIPs work together.
  • Private IP addresses are used for internal network communication.
  • The virtual IP address works with Keepalived to build an HA cluster. ECSs in this cluster can be accessed through one virtual IP address.
  • EIPs are used for Internet communication.
Figure 1 Different types of IP addresses used by ECSs

Application Scenarios

You can use a virtual IP address and Keepalived to set up a high-availability active/standby cluster. If the active cloud server goes down, the standby server becomes the active server and continues to provide services. The following describes the typical application scenarios of virtual IP addresses.

Figure 2 shows a high-availability cluster that is set up using a virtual IP address and Keepalived. They work as follows:

  1. Virtual IP address 192.168.0.177 is bound to ECS-HA1 and ECS-HA2. Keepalived is configured on the two ECSs.
  2. EIP EIP-A is bound to the virtual IP address so that the ECSs can be accessed from the Internet.

In this cluster, ECS-HA1 works as the active ECS and provides services accessible from the Internet using EIP-A. ECS-HA2 works as the standby ECS, with no services deployed on it. If ECS-HA1 goes down, ECS-HA2 takes over services, ensuring service continuity.

For details about how to set up an HA cluster, see Using a Virtual IP Address and Keepalived to Set Up a High-Availability Web Cluster.

Figure 2 A high-availability cluster using a virtual IP address and Keepalived
As shown in Figure 3, a virtual IP address, Keepalived, and LVS are used to set up an HA load balancing cluster. LVS is used for load balancing, and Keepalived is used for high availability. They work as follows:
  1. Virtual IP address 10.10.1.10 is bound to ECS-01 and ECS-02. Keepalived and LVS (DR mode) are configured on ECS-01 and ECS-02 to set up the active/standby LVS servers. In this way, requests from clients can be evenly distributed to different backend servers.
  2. ECS-03 and ECS-04 are configured as backend servers to handle service requests.
  3. The source/destination check option needs to be disabled.

    When you bind a virtual IP address to an ECS, the source/destination check option of the ECS NIC is automatically disabled. If the option is not disabled, disable it.

In this load balancing cluster, ECS-01 works as the active LVS server to distribute requests from clients. If ECS-01 is faulty, ECS-02 takes over and distributes requests from clients, ensuring high availability of the LVS cluster.
Figure 3 A high-availability cluster using a virtual IP address and Keepalived/LVS

For details about how to install and configure Keepalived and LVS services and how to configure backend servers, see the common practices in the industry.

Virtual IP Address Quotas

Table 1 lists the quotas about virtual IP addresses. Some default quotas can be increased.
Table 1 Virtual IP address quotas

Item

Default Quota

Adjustable

Maximum number of virtual IP addresses per region

2

Yes. For details, see Managing Quotas.

Maximum number of EIPs that a virtual IP address can be bound to.

1

No

Maximum number of instances (including ECSs and NICs) that a virtual IP address can be bound to.

10

No

Notes and Constraints

  • If an ECS has multiple network interfaces that are in the same subnet, you are not advised to bind virtual IP addresses to the network interfaces. Using the virtual IP addresses may cause route conflicts on the ECS, which would lead to communication failures.
  • A virtual IP address is assigned from a VPC subnet. They can only be bound to a cloud server in the same subnet as the virtual IP address.
  • Virtual IP addresses and extended network interfaces cannot be used to directly access Huawei Cloud services, such as DNS. You can use VPCEP to access these services. For details, see Buying a VPC Endpoint.