Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get AmazonProvidedDNS IP address from the EC2 meta-data
MAC_ADDR=`curl -s`
CIDR_FULL=`curl -s${MAC_ADDR}/vpc-ipv4-cidr-block`
CIDR_BASE=`echo ${CIDR_FULL} | cut -d/ -f1 | cut -d\. -f1-3`
LAST_OCTET=`echo ${CIDR_FULL} | cut -d/ -f1 | cut -d\. -f4`
DNS_OCTET=`expr ${LAST_OCTET} + 2`
echo $DNS_IP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.