0
Q:

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
}
0
curl http://169.254.169.254/latest/meta-data/public-hostname
0

New to Communities?

Join the community