Created
October 19, 2016 07:53
-
-
Save olvesh/b366877aa28f78d7b1f5acf961f1d8fd to your computer and use it in GitHub Desktop.
Find ip, subnet etc on AWS metadata service
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
#!/usr/bin/env bash | |
DOMAIN=$(curl -s http://169.254.169.254/latest/meta-data/hostname | perl -n -e'/[A-Za-z0-9-]+\.(.*)/ && print $1') | |
IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) | |
MAC=$(curl -s http://169.254.169.254/latest/meta-data/mac) | |
CIDR=$(curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC/vpc-ipv4-cidr-block) | |
RECURSOR=$( echo $CIDR | awk -F"." '{print $1 "." $2 "." $3 ".2"}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment