Created
December 17, 2015 22:44
-
-
Save dialt0ne/53676f891d6f632c078f to your computer and use it in GitHub Desktop.
Get AmazonProvidedDNS IP address from the EC2 meta-data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAC_ADDR=`curl -s http://169.254.169.254/latest/meta-data/mac` | |
CIDR_FULL=`curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${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` | |
DNS_IP="${CIDR_BASE}.${DNS_OCTET}" | |
echo $DNS_IP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dns server generic ip is
169.254.169.253
(a.k.a no need to compute the ip with range +2)