Add domain or sub-domain to google Compute

In this post you will learn how to add a domain and/or a sub-domain to Google Cloud DNS. This works in 2021 and will in 2022.

4480

Long before I switched to VPS, I was a rookie thinking that C panel is the only thing in the whole world capable of doing what I want and need from a hosting environment.
Yes, I was wrong. 80% of its capabilities I never, never ever used. It’s literally just for playing and introducing yourself to the hosting environment, which is great and necessary in the very beginning.

Lets get right to the core:
To add a domain to you VM instance (and website), go to
Network Services > Cloud DNS

2. ..then click on +Create Zone
You will be asked to fill 3 fields.

In the Zone name Just type something like ” mysites domain zone”
DNS name is your domain: yoursite.com
Click “Create”.

Then, add an A record to point your domain to your server’s IP, and
add a CNAME record to point your www.yoursite.com to yoursite.com

To add any sub-domains, just add an A record, write your sub-domain name and point it to your server’s IP.

Do not forget to reserve your domain/server IP, to make it static. The thing is that Google holds the right to change your server’s IP if the system finds it necessary, which probably ain’t gonna happen, but to be sure it is better to reserve the IP.

To do that you have to navigate to VPC network > External IP addresses. From there change (under ‘Type‘) Ephemeral to Static. That’s it.

Cheers

6 COMMENTS

  1. Hi Thanks for the article.

    I did the same thing and able to access my website.I created a sub domain via A record and pointed to same reserved static IP. and also created another virtual directory in IIS.
    But when I browse sub domain it is not pointing to my sub domain virtual directory instead opening default website.

    could you please let me know how to point my sub domain to sub domain virtual directory

    • Hi,
      I would be glad to help you of course, but you need to give me little bit more details.
      I need to know are you using anything like Serverpilot or similar? Is it a wordpress app? is it on nginx or LAMP..? etc

  2. I created a sub domain via A record and pointed to same reserved static IP. But my subdomain is redirect on my domain. I need your help.

    • I don’t know unless you share more info, like: are you running WordPress (how did you install it) and the rest of your DNS zone configuration.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

CAPTCHA