4

i would like to find the public IP address of my EC2 instance from within the server itself.I know it is possible using ec2-describe-instances. But i want to do it assuming ec2-api-tools are not installed.

Is there a way to find that out?

Cheezo
  • 223
  • 2
  • 4
  • 8

4 Answers4

15
curl http://169.254.169.254/2009-04-04/meta-data/public-ipv4

Also,

curl http://169.254.169.254/2009-04-04/meta-data/

to get a list of other metadata you can get.

Ben Jencks
  • 1,361
  • 8
  • 13
6

There's a quick way to do it from the console on any server

With curl:

$ curl wgetip.com

With wget:

$ wget wgetip.com
splattne
  • 28,508
  • 20
  • 98
  • 148
0x6A75616E
  • 661
  • 3
  • 10
  • 24
3

As a matter of course, I now assign an Elastic IP to all new permanent (anything longer than a day) EC2 instances. This makes everything so much easier.

Tom O'Connor
  • 27,480
  • 10
  • 73
  • 148
2

Can't you just nslookup it?

Chopper3
  • 101,299
  • 9
  • 108
  • 239