Do Google Compute instances have a stable public DNS name?

旧巷老猫 提交于 2020-01-01 02:51:08

问题


This is a question in two parts:

  • Do GCE instances have a stable public DNS name? The default DNS name for instance with public IP a.b.c.d seems to be d.c.b.a.bc.googleusercontent.com
  • If yes, what's the best way to obtain this information? Here's the hack I've been using thus far:

    EXTERNAL_IP=$(curl -s http://bot.whatismyipaddress.com/)
    EXTERNAL_DNS=$(dig +short -x ${EXTERNAL_IP})
    

回答1:


reverse lookup is okay to do, for IP address you would probably prefer using gcutil https://developers.google.com/compute/docs/gcutil/tips

EXTERNAL_IP=$(gcutil getinstance --format=csv --zone=[your_zone] [your_instance] | grep external-ip | cut -d "," -f 2)



来源:https://stackoverflow.com/questions/17688956/do-google-compute-instances-have-a-stable-public-dns-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!