Private DNS EC2 BASH
export PUBLIC_DNS=`curl http://169.254.169.254/latest/meta-data/public-hostname 2>/dev/null`
export PUBLIC_IP=`curl http://169.254.169.254/latest/meta-data/public-ipv4 2>/dev/null`
function get-pub() {
if [ $# -ne 1 ]; then
echo "Invalid number of arguments"
return 1
else
case $1 in
dns)
echo $PUBLIC_DNS
;;
ip)
echo $PUBLIC_IP
;;
*)
echo $"Usage: get-pub {dns|ip}"
return 2
esac;
fi
return 0
}
4.43
7
curl http://169.254.169.254/latest/meta-data/public-hostname
Thank you!
7
0
Are there any code examples left?
New code examples in category Shell/Bash