Specify a private IP for an NLB instance
Alibaba Cloud OpenAPI Portal allows you to manage IP addresses and specify private IP addresses for a Network Load Balancer (NLB) instance. When you create an Internet-facing or internal-facing NLB instance, you can use Alibaba Cloud OpenAPI Portal to specify an IPv4 address in the CIDR block of each vSwitch to which the NLB instance belongs as the private IP address.
Usage notes
-
You can specify private IPv4 addresses for IPv4 or dual-stack NLB instances. You cannot specify private IPv6 addresses for dual-stack NLB instances.
-
Before you create an NLB instance, make sure that you have reserved enough available IP addresses in the vSwitch of each selected availability zone. When you create an instance, the system consumes three IP addresses from each specified vSwitch: two local IP addresses for communicating with backend servers and performing health checks, and one virtual IP address (VIP) that provides services to clients. The VIP does not change after the instance is created. If a vSwitch has insufficient IP addresses, instance creation fails.
NoteTo ensure the scalability of an NLB instance, we recommend that you reserve at least eight IP addresses in each vSwitch of the NLB instance.
-
You can call the DescribeZones operation to query the most recent zone list.
-
You can call the DescribeVSwitches operation to query vSwitches and CIDR blocks.
-
Procedure
-
Log on to OpenAPI Portal.
-
On the CreateLoadBalancer API page, configure the request parameters to create an instance. This example uses China (Hangzhou) for the Region parameter.
The following table describes only the parameters that are relevant to this topic. For more information about how to specify the other parameters, see CreateLoadBalancer.
Parameter
Description
Example
LoadBalancerType
The type of the load balancer. Set the value to network, which indicates a Network Load Balancer (NLB) instance.
network
LoadBalancerName
The name of the NLB instance.
NLB-test01
AddressType
The type of IPv4 address of the NLB instance.
-
Internet: The load balancer has a public IP address. The DNS name is resolved to the public IP address, so the instance can be accessed from the Internet.
-
Intranet: The load balancer has only a private IP address. The DNS name is resolved to the private IP address, so the instance can be accessed only from within its Virtual Private Cloud (VPC).
You can set this parameter to Internet or Intranet based on your requirements.
Intranet
AddressIpVersion
The protocol version. Valid values:
-
ipv4 (default): IPv4
-
DualStack: dual stack
This example uses ipv4.
ipv4
VpcId
The ID of the VPC in which the NLB instance is deployed.
You can log on to the VPC console. In the top navigation bar, select the China (Hangzhou) region. On the VPC page, find the target VPC and view its ID.
vpc-bp18jb3fqfklxde2z****
ZoneMappings
The mappings between zones and vSwitches. You must specify at least two zones.
-
VSwitchId: The ID of the vSwitch in the zone.
-
ZoneId: The ID of the zone.
You can call the DescribeZones operation to query zone IDs.
-
PrivateIPv4Address: The private IP address.
ImportantWhen you specify a private IP address for the NLB instance, make sure that the IP address belongs to the destination CIDR block of the vSwitch and is not in use.
-
AllocationId: The ID of the Elastic IP Address (EIP) that is associated with the Internet-facing instance.
You can log on to the VPC console. In the top navigation bar, select the China (Hangzhou) region. On the VPC page, click the ID of the target VPC. On the Resource Management tab, click the number next to vSwitches to view their corresponding IDs and CIDR blocks.
In this example, Zone J and Zone K are specified. You can specify zones based on the number of available zones.
Configuration of Zone J:
-
ZoneMappings.1.VSwitchId: vsw-bp1gw3z8urk2a7n8j****
-
ZoneMappings.1.ZoneId: cn-hangzhou-j
-
ZoneMappings.1.PrivateIPv4Address: 10.0.3.243
Configuration of Zone K:
-
ZoneMappings.0.VSwitchId: vsw-bp1af7hb3d7j6lv5f****
-
ZoneMappings.0.ZoneId: cn-hangzhou-k
-
ZoneMappings.0.PrivateIPv4Address: 10.0.2.25
-
-
Click Initiate Call.
The following response is returned. An HTTP status code of 200 indicates that the instance was created.
{ "RequestId": "22260859-BB7C-5102-8046-8*********", "HttpStatusCode": 200, "LoadbalancerId": "nlb-f1j2qxsnip8wzo****", "OrderId": 22208577321****, "Success": true }After the call is successful, you can call the GetLoadBalancerAttribute operation to view the details of the created NLB instance. You can verify that the VIP of the instance in each zone matches the private IP address that you specified.
-
Optional:After the call is successful, you can log on to the NLB console to view the parameters of the NLB instance whose private IP addresses are
10.0.3.243and10.0.2.25.-
In the top navigation bar, select the China (Hangzhou) region.
-
On the Instances page, find the newly created instance and click its ID.
-
On the Instance Details tab, you can view the VIP of the instance in each zone and confirm that it matches the private IP address that you specified.
-
References
-
For more information about how to create an NLB instance in the NLB console, see Create and manage an NLB instance.
-
For more information about how to specify private IP addresses for an Application Load Balancer (ALB) instance, see Use OpenAPI Explorer to create an ALB instance and assign private IP addresses.
-
For more information about how to specify private IP addresses for a Classic Load Balancer (CLB) instance, see Specify a private IP address when you use OpenAPI Explorer to create a CLB instance in a VPC.