I want to know the IP address that my load balancer uses to forward traffic when I use Elastic Load Balancing (ELB) for my web servers.
Resolution
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
Use the AWS Management Console or the AWS CLI to get your IP addresses that ELB uses.
Note: The IP addresses for Classic Load Balancers and Application Load Balancers change over time. Don't configure your applications to statically point to these IP addresses.
AWS Management Console
To get your IP addresses from the console, complete the following steps:
- Open the Amazon Elastic Compute Cloud (Amazon EC2) console.
- In the navigation pane, under Load Balancing, choose Load Balancers.
- Under Load balancers, note the name of the load balancer that you want to find the IP addresses for.
- In the navigation pane, under Network & Security, choose Network Interfaces.
- Enter the load balancer name that you copied into the search box.
- Find the primary private IP address of each elastic network interface in the Primary private IPv4 IP column.
Note: The filtered results show all elastic network interfaces that are associated with the load balancer.
AWS CLI
-
For Application Load Balancers and Network Load Balancers, run the describe-load-balancers AWS CLI command to find the load-balancer-id:
aws elbv2 describe-load-balancers --names load-balancer-name --query 'LoadBalancers[].LoadBalancerArn' --output text
Example output:
arn:aws:elasticloadbalancing:us-east-1:111122223333:loadbalancer/app/ALB-external/6961xxxxc843
Note: The load-balancer-id is the last field of characters that follows the trailing slash after the load balancer's name in the ARN.
-
Run the describe-network-interfaces AWS CLI command to get the IP address:
aws ec2 describe-network-interfaces --filters Name=description,Values="ELB elb-name" --query 'NetworkInterfaces[*].PrivateIpAddresses[*].PrivateIpAddress' --output text
Note: Replace elb-name with one of the following options:
For Classic Load Balancers, replace with the name of your load balancer.
For Application Load Balancer, replace with app/load-balancer-name/load-balancer-id.
For Network Load Balancers, replace with net/load-balancer-name/load-balancer-id.
Example output:
10.0.1.251 10.0.0.208