5

How can someone find a list of the static IPs assigned to an existing AWS Network Load Balancer?

I see nothing in the console that shows the IPs, nor do I see anything in the CLI that would do so.

Todd
  • 2,829
  • 5
  • 34
  • 56

2 Answers2

4

This documentation should be helpful for you:

https://aws.amazon.com/blogs/aws/new-network-load-balancer-effortless-scaling-to-millions-of-requests-per-second/

The elastic IP will be the IP that you want.

If you just want to know the address of an existing load balancer then take the CNAME of it and query the DNS using dig or nslookup.

Mindaugas Bernatavičius
  • 3,757
  • 4
  • 31
  • 58
0

You cannot query that in just one step, since the filters are not complex enough in the aws ec2 describe-addressees command. But you can do it in two steps:

#Query to obtain the instances id in the autoscaling group and 
aws ec2 describe-instances --filters "Name=tag:aws:autoscaling:groupName,Values=#YourAutoScalingGroupName#" --query 'Reservations[*].Instances[*].[InstanceId]' | grep i > instancesId.txt


#Then read the file, iterate line by line and ask for the elastic ip 
while read instanceId           
do           
    aws ec2 describe-addresses --filters "Name=instance-id,Values="${instanceId}               
done < instancesId.txt

Edit:

As Michael says, this solution does find the ip addresses on an autoscaling group. So:

aws elb describe-load-balancers --load-balancer-name "YOUR_BALANCER_NAME" | grep -oP  "\"InstanceId\": \"\K(i-[a-z0-9A-Z]*)"  > instancesId.txt

will search instances on a load balancer.

Necoras
  • 6,743
  • 3
  • 24
  • 45
  • 4
    You have what seems like the beginnings of a promising solution, here, but I believe you are answering the wrong question. The question is how to find the EIPs associated with a Network Load Balancer, not with instances. – Michael - sqlbot Jan 04 '18 at 01:26