Finding static IPs associated with AWS Network Load Balancer?
Asked Answered
N

2

7

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.

Nall answered 3/1, 2018 at 16:18 Comment(0)
S
5

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.

Shakhty answered 3/1, 2018 at 16:25 Comment(4)
That shows how to create a Network Load Balancer with static IPs. I'm trying to determine the static IPs associated with an existing Network Load Balancer.Nall
Oh then you just need to take the load balancers cname and query the dns. You can use the dig command or the nslookup.Foresee
Mindaugas is right. I used the dog command to see what IP address was assign to my load balancer.Closeknit
I appended the answer with the lattest suggestion. Please consider accepting the answer if it was helpfull.Foresee
C
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.

Colorist answered 3/1, 2018 at 20:34 Comment(1)
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.Medici

© 2022 - 2024 — McMap. All rights reserved.