Resolve DNS names of Network Load Balancer nodes to limit cross-Zone traffic
Network Load Balancer (NLB), part of the Elastic Load Balancing Family, is the flagship Layer 4 load balancer for AWS. It offers elastic capacity, high performance, and integration with many other AWS services (such as Amazon EC2 Auto Scaling). NLB is designed to handle millions of requests per second while maintaining ultra-low latency, improving both availability and scalability. NLBs are used by all types of applications, from low-latency media streaming to high-scale enterprise data services, and in software architectures ranging from traditional virtual machines to containerized environments.
Customers use NLBs to load balance traffic to backend applications per availability zone (AZ). These applications could be running natively on Amazon Elastic Compute Cloud (EC2) instances, Amazon Elastic Container Service (ECS), Amazon Elastic Kubernetes Service (EKS), or Kubernetes clusters on EC2. Or, they might also target IP addresses in your VPC subnets and utilize multiple AZs per Region for high availability (HA).
Customers often have several client business applications running inside the same AZ, and all of them consume backend services behind an NLB. To connect to and consume these backend services, the business application first must resolve the NLB DNS name. The NLB has one IP address for each node in an AZ, with each resolving to a DNS name. This is shown in the following diagram (figure 1).
For example, suppose that the DNS name for your load balancer is
my-example-nlb-4e2d1f8bb2751e6a.elb.eu-central-1.amazonaws.com and has 3 AZs enabled. Resolving this DNS name returns the IP addresses for all NLB nodes in all 3 enabled AZs. This is shown in the following code:
Linux or Mac