Amazon EC2 取得自己的外部 IP

Amazon EC2 開機會自動取得自己 10.x.x.x 的 IP, 要抓取實體 IP / Hostname 等, 要用下述方法抓:

  • 取得 IP: wget -q -O /tmp/public-ip http://169.254.169.254/latest/meta-data/public-ipv4
  • 取得 Hostname: wget -q -O /tmp/public-hostname http://169.254.169.254/latest/meta-data/public-hostname
  • 註: 169.254.169.254 是特殊 IP, 非 EC2 無法用此方法抓取.

閱讀全文〈Amazon EC2 取得自己的外部 IP〉