This tutorial provides a walkthrough of the end-to-end process for registering a domain, setting up a sample web server, and using Cloud DNS to point the domain URL to the server.The tutorial demonstrates the following steps:
- Register a domain name using Google Domains
- Create a virtual machine instance
- Run a basic Apache web server
- Set up your domain using Cloud DNS
- Update name servers on Google Domains
- Verify your setup
There is a cost associated with registering a domain name. For pricing information, see Pricing and supported domain endings.
Before you begin
Sign in to your Google Account.
If you don't already have one, sign up for a new account.
In the Cloud Console, on the project selector page, select or create a Cloud project.
Make sure that billing is enabled for your Google Cloud project. Learn how to confirm billing is enabled for your project.
- Enable the Compute Engine API.
Step 1: Register a domain name using Google Domains
- To register a domain, go to Google Domains. If you already have a domain, you can skip this step.
- Check for available domain names and choose an available name for your domain.
- To buy the domain, click on the add-to-cart add_shopping_cart icon.
- Choose the privacy and auto-renewal settings, and click Save and continue.
- Complete the registration.
- To see the list of domains that you own, click My domain in the left navigation menu.
For more information, see Get started with Google Domains.
Step 2: Create a virtual machine instance
To create a Linux virtual machine instance in Compute Engine using the Google Cloud Console, follow these instructions:
- In the Cloud Console, go to the VM Instances page.
- Click Create instance.
- In the Boot disk section, click Change to begin configuring your boot disk.
On the Public images tab, choose Debian version 9.
- Click Select.
- In the Firewall section, select Allow HTTP traffic.
- Click Create to create the instance.
Allow a short time for the instance to start. After the instance is ready, it is listed on the VM instances page with a green status icon.
Connect to your instance
- In the Cloud Console, go to the VM instances page.
In the list of virtual machine instances, click SSH in the row of
the instance that you want to connect to.
You now have a terminal window for interacting with your Linux instance.
For details, see the Quickstart using a Linux VM.
Step 3: Run a basic Apache web server
From the SSH window, use the Debian package manager to install the
sudo apt-get update && sudo apt-get install apache2 -y
After installing Apache, the operating system automatically starts the Apache server.
Overwrite the default web page for the Apache web server by using the following command::
echo '<!doctype html><html><body><h1>Hello World!</h1></body></html>'\ | sudo tee /var/www/html/index.html
Test your server
Test that your instance is serving traffic on its external IP.
- Go to the VM Instances page in the Google Cloud Console.
- Copy the external IP for your instance under the External IP column.
- In a browser, navigate to
http://[EXTERNAL_IP]. Do not connect using
https, as the server will return a
You should now see the "Hello World!" page.
For further details, see Running a basic Apache web server.
Step 4: Set up your domain using Cloud DNS
Go to the Create a DNS zone page in the Cloud Console.
Publicfor the Zone type.
my-new-zonefor the Zone name.
Enter a DNS name suffix for the zone using a domain name that you registered. For example,
Under DNSSEC, keep the
Click Create. This creates a zone populated with the NS and SOA records.
To point your registered domain name to the IP address of the hosting server, you must add an
Arecord to your zone.
- On the Zone details page, click Add record set.
Afrom the Resource Record Type menu.
- Under IPv4 Address, enter the external IP address for your instance.
- Click Create.
This creates an
Arecord for your zone.
(Optional) Add a
CNAMErecord to account for a prefix to your domain name, for example,
- Click Add Record Set.
- In the DNS name field, add the prefix
wwwfor the domain.
- Under Resource Record Type, choose
- Under Canonical name, enter the domain name, followed by a period. For
- Click Create.
On your Zone details page, make a note of the
NSrecords. You need these to proceed with Step 5.
Step 5: Update name servers on Google Domains
- To update the name servers for your domain, go to Google Domains.
- Click the domain that you set up in Step 1. Alternatively, you can click the Manage link for that domain.
- On the left navigation menu, click DNS.
- Under Name servers, select Use custom name servers.
NSrecords that you copied from your Zone details page, for example,
ns1.googledomains.com, into the Name server field one at a time.
To add name servers, click add.
Update all the four name servers on your Google Domains DNS page.
Step 6: Verify your setup
To verify that your configuration is working, after the name servers are
updated, navigate to your domain name, for example,
example.com. The domain
should resolve to your IP address and should point to the Compute Engine
VM displaying the "Hello World!" page that you created in Step 3.
You can also run the
dig +trace example.com command on your terminal window to
verify that your setup is correct. Replace
example.com with your
registered domain name.
dig +trace example.com
The end of the output should include the following, where ip-address is your web server's IP address.
example.com. 300 IN A ip-address ;; Received 62 bytes from 220.127.116.11#53(ns-cloud-d2.googledomains.com) in 62 ms
To verify that the changes were successful, the following line in your command output shows that the top-level domain name servers are pointing to the custom name servers that you entered in Google Domains, as opposed to the original name servers provided by Google Domains:
example.com IN NS <your Cloud DNS name servers>
After waiting for DNS propagation to
you can also verify your setup by running the
Server: 127.0.0.1 Address: 127.0.0.1#53 Non-authoritative answer: Name: example.com Address: ip-address
ip-address is your web server's IP address.
Go to the Cloud DNS Zones page in the Cloud Console.
On the Cloud DNS Zones page, click the zone name, for example,
my-new-zone, to get to the Zone details page.
CNAMErecords that you created.
Click Delete records sets.
Delete the zone by clicking the delete icon delete for the zone name
Go to the VM Instances page in the Cloud Console.
Check the instance that you want to delete.
Click the Delete button from the more icon more_vert in the row of the instance.