Specify a private IP address when creating an instance

Updated at:
Copy as MD

Use OpenAPI Explorer to assign a specific private IP address to an Application Load Balancer (ALB) instance. When you create an internet-facing or internal-facing ALB instance, you can specify an IPv4 address from the CIDR block of each vSwitch as the private IP address for the instance.

Usage notes

  • You can assign a private IPv4 address only to an IPv4 or dual-stack ALB instance. You cannot assign a private IPv6 address to a dual-stack ALB instance.

  • When you create an upgraded ALB instance, make sure that each selected vSwitch has enough available IP addresses. An upgraded ALB instance requires three IP addresses from each specified vSwitch: one virtual IP (VIP) address to serve traffic and two local IP addresses to communicate with backend servers. If a vSwitch has an insufficient number of IP addresses, the instance cannot be created and an error is reported. This requirement does not apply to ALB instances that have not been upgraded.

    To ensure that all elastic features of an upgraded ALB instance are available, we recommend that you reserve at least eight IP addresses in each vSwitch that the instance uses.

    • Call the DescribeZones operation to query the zones where ALB is available in a specified region.

    • Call the DescribeVSwitches operation to query existing vSwitches and their CIDR blocks.

Procedure

  1. Log on to OpenAPI Explorer.

  2. On the CreateLoadBalancer page, configure the request parameters to create an ALB instance. In this example, Region is set to China (Hangzhou).

    The following table describes only the key parameters. For more information about other parameters, see CreateLoadBalancer.

    Parameter

    Description

    Example value

    VpcId

    The ID of the VPC in which the ALB instance is deployed.

    You can log on to the VPC console, select the China (Hangzhou) region from the top navigation bar, and then navigate to the VPC page to find and view the ID of the target VPC.

    vpc-bp1wfo2ytjbr9zs3y****

    AddressType

    The IPv4 address type of the ALB instance.

    • Internet: The instance is assigned a public IP address and is accessible from the internet.

    • Intranet: The instance is assigned a private IP address and is accessible only from within the VPC where it is deployed.

    You can set this parameter to Internet or Intranet based on your requirements.

    Intranet

    LoadBalancerName

    The name of the ALB instance.

    ALB-test01

    ZoneMappings

    The mappings between zones and their corresponding vSwitches. If the current region supports two or more zones, select at least two zones to ensure high availability.

    • VSwitchId: The ID of the vSwitch in the zone.

      You can call the DescribeVSwitches operation to query vSwitch IDs.

    • ZoneId: The ID of the zone.

      You can call the DescribeZones operation to query zone IDs.

    • IntranetAddress: The private IPv4 address to assign to the instance in this zone.

      Important

      When you specify a private IP address for an ALB instance, ensure that the address is within the CIDR block of the vSwitch and is not already in use.

    You can log on to the VPC console, select the China (Hangzhou) region, and click the ID of the target VPC on the VPC page. On the Resource Management tab, click the number of vSwitches to view the IDs and CIDR blocks of the vSwitches.

    This example uses Zone G and Zone I. You can configure zones based on the actual number of zones available for your ALB instance.

    Parameters for Zone G:

    • ZoneMappings.1.VSwitchId: vsw-bp1jiciza3mpuyphn****

    • ZoneMappings.1.ZoneId: cn-hangzhou-g

    • ZoneMappings.1.IntranetAddress: 192.168.1.13

    Parameters for Zone I:

    • ZoneMappings.0.VSwitchId: vsw-bp1uwoih7uwew975k****

    • ZoneMappings.0.ZoneId: cn-hangzhou-i

    • ZoneMappings.0.IntranetAddress: 192.168.0.230

    LoadBalancerEdition

    The edition of the Application Load Balancer instance, which determines its available features and billing methods. Valid values:

    • Basic

    • Standard

    • StandardWithWaf: WAF-enabled

    Basic

    AddressAllocatedMode

    The address allocation mode. Valid values:

    • Fixed (default): A static IP address is allocated to the instance in each zone.

    • Dynamic : Dynamic IP mode, which indicates that an IP address is dynamically allocated for each zone.

    Note

    Starting from 00:00:00 on February 25, 2025 (UTC+8), all instances created using the CreateLoadBalancer API operation are upgraded ALB instances, regardless of the AddressAllocatedMode that you specify. These upgraded instances use elastic IP addresses, so this setting has no effect. This change does not affect existing ALB instances.

    Fixed

    LoadBalancerBillingConfig

    The billing configuration of the ALB instance.

    • PayType: The billing method of the instance.

      The only valid value is PostPay, which specifies the pay-as-you-go billing method.

    • BandwidthPackageId: The ID of the Internet Shared Bandwidth instance that is associated with an internet-facing instance.

    • PayType: PostPay

    • BandwidthPackageId: Configure this parameter based on your requirements.

    AddressIpVersion

    The IP version. Valid values:

    • IPv4 (default)

    • DualStack

    You can set this parameter to IPv4 or DualStack based on your requirements. If you set this parameter to DualStack, make sure that IPv6 is enabled for the vSwitch where the ALB instance is deployed. For more information, see Enable IPv6 for a vSwitch.

    IPv4

  3. Click Initiate Call.

    A response similar to the following is returned. A status code of 200 indicates that the instance was created successfully. For other status codes, use the returned message or see ALB error codes to troubleshoot the issue.

    {
      "RequestId": "0A1F39B6-4BDE-5923-A3BE-E98708413D1B",
      "LoadBalancerId": "alb-gokux4i116yiqf****"
    }

    After the call is successful, you can call the GetLoadBalancerAttribute operation to view the configuration details of the created ALB instance. The zone VIPs in the response are the private IP addresses that you specified.

  4. Optional: After the instance is created, you can also log on to the Application Load Balancer console to verify that the instance was created with the private IP addresses 192.168.1.13 and 192.168.0.230.

    1. In the top navigation bar, select the China (Hangzhou) region.

    2. On the Instances page, find the newly created instance and click its ID.

    3. On the Instance Details tab, check that the zone VIPs match the private IP addresses that you specified.

Related topics