Skip to content

Instantly share code, notes, and snippets.

@infomaven
Last active November 8, 2015 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infomaven/ec1342ed4c3f1c88aa7c to your computer and use it in GitHub Desktop.
Save infomaven/ec1342ed4c3f1c88aa7c to your computer and use it in GitHub Desktop.
While you can get the public and private IP address of your Amazon EC2 instance via the AWS Console, it may be extremely useful to query it from anywhere you can make an HTTP request, such a shell script. The operation is really simple, just make a GET request to the following URL from within your EC2 instance:
Local IP:
curl http://169.254.169.254/latest/meta-data/local-ipv4
Public IP:
curl http://169.254.169.254/latest/meta-data/public-ipv4
I often use this feature to pre-configure services and update configuration files, as in EC2 you get a new IP Address each time you reboot
&&&&&&&&&
Also see this article >
http://rafaelsteil.com/tag/ec2/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment