Skip to content

Instantly share code, notes, and snippets.

@drboyer
Last active August 29, 2015 14:25
Show Gist options
  • Save drboyer/c8f68a959ac7ceb6ab44 to your computer and use it in GitHub Desktop.
Save drboyer/c8f68a959ac7ceb6ab44 to your computer and use it in GitHub Desktop.
A script to query the AWS EC2 Metadata Service to display an instance's public and private IP Addresses
#!/bin/bash
privatestr="Private (local) IP:\t"
privatestr+=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)
echo -e $privatestr
publicstr="Public IP:\t\t"
publicstr+=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)
echo -e $publicstr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment