Public IP Address of Private AWS Instances?

Do you want to find out the public IP address of your private instances (those in a private VPC subnet) but don’t know how? An easy way to do this would be to just do a “whatsmyip” equivalent on the private instance such as this:

wget http://ipecho.net/plain -O - -q ; echo

However, there’s an even easier way to figure this out, especially if AWS is your bread and butter. Every private instance communicates to the outside world via a NAT instance or a NAT gateway (yes, this is your ‘duh’ moment). So, all that you need is your NAT gateway’s or NAT instance’s Elastic IP address and you’re done.

In my case, I was trying to allow an ELB on one AWS account to see traffic from private instances on another AWS account. So, I just added an entry to the ELB’s security group to listen from the NAT gateway’s Elastic IP of the other AWS account and I was done.

This entry was posted in Amazon Web Services, Linux, Tech. and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s