Wednesday, February 4, 2009

Show me my public ip address!

Well, alas, another small kink in the making of a distributed web app: finding my new EC2's public ip address. I would have thought there was a really easy way to do this from the command line on linux machines and maybe there is and I am completely ignorant. But, be that as it may, I figured the easiest way to solve my problem was to solve it myself. Introducing.....show me my public ip address Hit up this script with whatever kind of http producing program you got and all it will return is some headers followed by your public ip address. I am going to use it.

2 comments:

  1. I know at this point it doesn't really matter, but there is a sweet tool you can get for ec2 instances called 'ec2 metadata:
    http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1825

    Just wget it and run:
    wget http://s3.amazonaws.com/ec2metadata/ec2-metadata
    chmod 755 ec2-metadata
    # Returns the public ip
    ./ec2-metadata -v
    # returns the private ip
    ./ec2-metadata -o

    ;)

    ReplyDelete
  2. sweet. very sweet.

    ReplyDelete