This is a question in two parts:
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})
This page provides an overview of Compute Engine instances. An instance is a virtual machine (VM) hosted on Google's infrastructure. You can create an instance or create a group of managed instances by using the Google Cloud console, the Google Cloud CLI, or the Compute Engine API.
GCP has internal FQDN for Compute Engine VMs for communicating between instances in the same VPC network, that can be used to send packets to an instance by specifying the fully-qualified DNS name (FQDN) of the target instance. The VPC network automatically resolves the name to the internal IP address of the instance.
For IPv4: 8.8.8.8 and/or 8.8.4.4 . For IPv6: 2001:4860:4860::8888 and/or 2001:4860:4860::8844 . For IPv6-only: you can use Google Public DNS64 instead of the IPv6 addresses in the previous point.
The metadata server is also the name server resolver for DNS queries issued by the VM.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With