Google Cloud domain name for instance (like EC2) - amazon-web-services

On creating an EC2 instance on AWS, you can access it via IP address or a domain name provided by Amazon out of the box:
Is there a similar thing available for Google Cloud out of the box? I'm on a network that blocks IP addresses, and wildcard DNS like xip.io, so I was curious to know about it. Also, is there a specific term this is called which I'm missing?

When you create a GCP Compute Engine instance (EC2 equivalent) you can declare that you want it to have a public IP address. This is an IP that you can use over the Internet to access your instance. GCP gives you two types of IP ... static (stable) or ephemeral. A static IP is yours until you explicitly release it. There is no charge for this as long as your compute engine is running. An ephemeral IP is one which is allocated to you dynamically and may change following a restart of your compute engine instance.
GCP does not (currently ... things could always change) create a DNS entry that will resolve to your IP address over the Internet. It does create a DNS entry that can be used inside your GCP VPC network to allow one compute engine to call another within the GCP environment.
If you want to reach your Compute Engine via a DNS name it is your responsibility to create a DNS "A" record in your own DNS server. If you don't have a DNS server that you can use, then you can obtain a domain name for a few dollars and then create an instance of a GCP Cloud DNS Server and add an "A" record for your compute engine to that server.
See also:
Cloud DNS
Internal DNS

Yes, you can forumate internal dns for instance using [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal
See the following link for further information: https://cloud.google.com/compute/docs/internal-dns

Please ensure the ports are open.
You can visit the documentation as below for your reference, hope this helps.
https://cloud.google.com/vpc/docs/firewalls

Related

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?
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.

How can I get a DNS name for a GCE instance

I have a Google Compute Engine instance which is uniquely identified:
name: updateservice
zone: us-central1-a
project: myproject
is there a way to access the instance via DNS name? Otherwise I need to whitelist it's IP everytime in Cloud SQL since it changes on reboot.
Compute Engine instances have a private DNS name within the VPC, but do not have a public DNS name. You must configure a DNS resource record for the instance at your DNS server if you want a public DNS name.
Otherwise I need to whitelist it's IP everytime in Cloud SQL since it
changes on reboot.
There are two solutions for Cloud SQL:
Assign a static IP address to the Compute Engine instance. link
Deploy the Cloud SQL Auth Proxy on the Compute Engine instance . link
Method #2 is the recommended method because IP addresses do not need to be whitelisted and authentication is encrypted.
If you SSH to the VM and run the command hostname -A it will show you the VM's internal DNS.
From the on-premise network, you can reach/ping the VM's internal DNS by setting up Cloud VPN.

public instance CNAME for GCP compute instance

Azure provides a way to access a VM using *.cloudapp.net, is there something similar in GCP? If yes, where/how can I see the exact CNAME for accessing the instnace?
I read it that its *.googleapi.com, but not able to find it anywhere on GCP portal
Note this SO question comments says it should be of format computername.c.googleprojectid.googleapis.com, is that not correct?
Google Cloud Compute Engine virtual machines (instances) are accessed by IP address outside Google Cloud or by internal DNS name inside Google Cloud. If you want a public DNS name, you must configure the public DNS name in your DNS server for your domain name.
Google Cloud does create an internal DNS name for your instance. However, this DNS name is private and only resolves in the same VPC as the instance.
You could use Cloud DNS, while setting the name-servers at the registrar to Cloud DNS.
See Updating your domain's name servers.
This means, you'd have to provide your own domain-name and at least one external IP - even with external DNS. The location of the zone-file to edit merely depends upon which name-servers the domain registration has set.

VM instances does not use the google cloud dns forwarder to resolve

i have setup my infra on GCP and created a VPC and firewall rules to allow outgoing 53 from inside my network to the outside.
i also setup a private dns zone in google cloud and added a dns forwarder ip (e.g. 192.168.1.1) to it. i also added the network that my vm is in to the dns zone allowed list .
now when i launch my VM and try to dig to test.mydomain.com it does not work, but when i put the ip mentioned above that i used as the dns forwarder in the /etc/resolve.conf the dig works ..
what am i missing here ?
By default, the resolution of internal DNS names is handled by the Instance metadata server (169.254.169.254)
If you change the name server configuration for your Instance, you might not be able to use internal DNS names. Any replacement of the name server software must support the Local Subnet Routes feature of RFC 3442.

Does GCP assign sub domain name to vm instance?

I am new for GCP. I try to create vm instance but i cannot find domain name which AWS provide for ec2. Just want to check whether GCP provides temp/sub-domain for its instance or not. Thanks
GCP does not provide sub-domain rather use internal domain [HOSTNAME].c.[PROJECT_ID].internal within the GCP environment. You can address instances over the internal VPC network while using [HOSTNAME].c.[PROJECT_ID].internal