google-cloud-platformnetwork-programminggoogle-compute-enginegoogle-cloud-networking

How can I access the internal DNS name of a GCE instance?


I want to access a Google Compute Engine instance by a permanent name. I found that there is supposed to be an internal DNS name for this like:

updateservice.us-central1-a.c.myproject.internal

however If I try to ping this instance from cloud shell I only receive:

ping: updateservice.us-central1-a.c.myproject.internal: Name or service not known 

why is this? and how can I access updateservice via DNS name?


Solution

  • We cannot use Cloud Shell to access or ping internal DNS name for the reason that it is on a separate network. You can check this by running this command “ip -4 addr”.

    Internal DNS can only resolved from VMs that are in the same network. You can check this link for more information.

    For further understanding on how Private DNS works you can also follow this link on how to create Private DNS.


    UPDATE 2022 - 12 - 07

    It will depend on you on how you will access your domain name.

    First if you are going to access it via internal connection that is the time that you need to use Private DNS. The connection will be from one VM instance to another in the same VPC network.

    Using Cloud DNS and configuring Private DNS it will give you the option to have your own domain name. You can watch this link on how you can create a Private DNS and understand the internal connection between VM instances.

    But based from this link there is already an internal DNS created for your vm instance but please dont be confused, the concept is the same with Private DNS. The only difference is Internal DNS is already created once a VM instance is created but it has a default domain name.

    Unlike Private DNS configured under Cloud DNS, you have the option to have your own domain name. If you are using a linux server you can run this command “hostname -A” to get the default domain name of your VM instance.

    What I discuss above is for internal access. Now the other way is external access, meaning you will access your VM instance outside your network. This will enter Public DNS. Before you create Public DNS you will need a domain name from a domain provider.

    Once you already have a domain name from a domain provider, you can create Cloud DNS then configure Public DNS. Once it is created you need to add “A Record”. This is just one step from your GCP network in order to have access using your domain name from external access.