You are currently viewing Create An Internal Network Load Balancer With Static Private IP Address

Create An Internal Network Load Balancer With Static Private IP Address

Create An Internal Network Load Balancer With Static Private IP Address

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed how to create an internet-facing network load balancer with static public (elastic) ip address.

https://cloudaffaire.com/how-to-create-an-internet-facing-network-load-balancer-with-static-public-elastic-ip-address/

In this blog post, we will discuss how to create an internal network load balancer with static private ip address and ip address as target.

Create An Internal Network Load Balancer With Static Private IP Address:

By default, AWS assigns a private IPv4 address to each load balancer node from the subnet for its Availability Zone. Alternatively, If you create an internal load balancer, you can assign a private IP address from the IPv4 range of each subnet instead of letting AWS assign one.

Internal load balancer ip assignment:

  • one private address assigned by AWS to each load balancer node from the subnet for its Availability Zone.

OR

  • one private address assigned by Customer to each load balancer node from the subnet for its Availability Zone.

Request Routing and IP Addresses:

If you specify targets using an instance ID, traffic is routed to instances using the primary private IP address specified in the primary network interface for the instance. The load balancer rewrites the destination IP address from the data packet before forwarding it to the target instance.

If you specify targets using IP addresses, you can route traffic to an instance using any private IP address from one or more network interfaces. This enables multiple applications on an instance to use the same port. Note that each network interface can have its own security group. The load balancer rewrites the destination IP address before forwarding it to the target.

Source IP Preservation:

If you specify targets using an instance ID, the source IP addresses of the clients are preserved and provided to your applications.

If you specify targets by IP address, the source IP addresses are the private IP addresses of the load balancer nodes. If you need the IP addresses of the clients, enable Proxy Protocol and get the client IP addresses from the Proxy Protocol header.

In this demo, we are going to create an internal network load balancer with private ip address and ip address as target.

Create An Internal Network Load Balancer With Static Private IP Address:

Step 1: Create a custom VPC for your Network Load Balancer.

Step 2: Create three EC2 instances, two as NLB target and one to access the internal load balancer.

Step 3: Create an internal Network Load Balancer with static private ip.

Create An Internal Network Load Balancer With Static Private IP Address

Step 4: Cleanup.

Hope you have enjoyed this article, In the next blog post, we will discuss Classic Load Balancer.

All the public cloud providers are changing the console user interface rapidly and due to this some of the screenshots used in our previous AWS blogs are no longer relevant. Hence, we have decided that from now onwards most of the demo will be done programmatically. Let us know your feedback on this in the comment section.

To get more details on AWS ELB, please refer below AWS documentation

https://docs.aws.amazon.com/elasticloadbalancing/index.html

 

This Post Has One Comment

  1. Avatar
    William Wong

    Thanks for the article
    kindly explains why step3 there is no subnets parameter in the create-load-balancer call.
    is there a default value for subnets? if yes, what is it?

    ## Observe, we have assigned private ip 10.0.2.20 and 10.0.3.20 to NLB nodes
    AWS_NLB_ARN=$(aws elbv2 create-load-balancer \
    –name my-network-load-balancer \
    –subnet-mappings SubnetId=$AWS_SUBNET_PRIVATE_ONE_ID,PrivateIPv4Address=10.0.2.20 \
    SubnetId=$AWS_SUBNET_PRIVATE_TWO_ID,PrivateIPv4Address=10.0.3.20 \
    –type network \
    –scheme internal \
    –query ‘LoadBalancers[0].LoadBalancerArn’ \
    –output text)

Leave a Reply