Set a domain using Cloud DNS

This tutorial provides a walkthrough of the process for registering a domain, setting up a sample web server, and using Deject DNS to point the domain URL to the server.

Objectives

The tutorial demonstrates the following steps:
  1. Register a domain proper name using Google Domains or Deject Domains
  2. Create a virtual machine (VM) instance
  3. Run a basic Apache web server
  4. Fix upward your domain using Cloud DNS
  5. Update name servers
  6. Verify your setup

Costs

In that location is a cost associated with registering a domain name. For Google Domains pricing, run into Pricing and supported domain endings. For Cloud Domains pricing, see Cloud Domains pricing.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Deject, create an account to evaluate how our products perform in real-world scenarios. New customers too become $300 in complimentary credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the projection selector page, select or create a Google Cloud project.

    Become to project selector

  3. Make sure that billing is enabled for your Cloud projection. Acquire how to check if billing is enabled on a project.

  4. In the Google Cloud panel, on the project selector page, select or create a Google Cloud projection.

    Go to project selector

  5. Make sure that billing is enabled for your Cloud project. Learn how to check if billing is enabled on a projection.

  6. Enable the Compute Engine API.

    Enable the API

Step ane: Register a domain name

To use Google Domains to register a domain, follow these steps:

  1. To annals a domain, go to Google Domains. If yous already have a domain, y'all tin skip this step.
  2. Check for available domain names and choose an available proper noun for your domain.
  3. To buy the domain, click Add to cart.
  4. Choose the privacy and car-renewal settings, and and so click Save and go on.
  5. Complete the registration.
  6. To see the list of domains that you ain, in the left navigation menu, click My domain.

For more information, see Get started with Google Domains.

To employ Deject Domains to register a domain, see Registering a domain.

Footstep 2: Create a virtual machine instance

To create a Linux virtual machine (VM) instance in Compute Engine, follow these instructions:

  1. In the Cloud console, go to the Create an case page.

    Go to Create an example

  2. In the Kicking disk section, click Change to brainstorm configuring your boot disk.
  3. On the Public images tab, choose Debian version 9.
  4. Click Select.
  5. In the Firewall section, select Permit HTTP traffic.
  6. To create the VM, click Create.

Allow a curt time for the instance to offset. After the instance is ready, information technology is listed on the VM instances folio with a green status icon.

Connect to your instance

  1. In the Cloud console, become to the VM instances folio.

    Go to VM instances

  2. In the list of virtual machine instances, click SSH in the row of the case that you want to connect to.

    SSH button next to instance name.

You now have a terminal window for interacting with your Linux instance.

For details, encounter the Quickstart using a Linux VM.

Stride three: Run a basic Apache web server

Install Apache

  1. From the SSH window, use the Debian package director to install the apache2 bundle.

                                sudo apt-go update && sudo apt-get install apache2 -y                                                      

    Afterwards installing Apache, the operating system automatically starts the Apache server.

  2. Overwrite the default web page for the Apache web server by using the following control:

                                echo '<!doctype html><html><body><h1>Hello World!</h1></torso></html>'\ | sudo tee /var/world wide web/html/alphabetize.html                                                      

Test your server

Examination that your instance is serving traffic on its external IP address.

  1. In the Deject panel, become to the VM instances page.

    Become to VM instances

  2. In the External IP cavalcade, copy the external IP address for your instance.
  3. In a browser, navigate to http://[EXTERNAL_IP]. Do not use https to connect because the server volition return a Connection Refused error.

Y'all should at present run into the Hello World! page.

For further details, come across Running a bones Apache web server.

Step 4: Ready your domain using Cloud DNS

If yous are migrating from an existing provider, you can import your existing zones to Cloud DNS. For instructions, run across Export your DNS configuration from your existing provider. Otherwise, follow these steps to create a new public zone.

  1. In the Deject console, go to the Create a DNS zone folio.

    Go to Create a DNS zone

  2. For the Zone type, select Public.

  3. For the Zone name, enter my-new-zone.

  4. For the DNS name, enter a DNS name suffix for the zone by using a domain proper noun that yous registered (for instance, example.com).

  5. For DNSSEC, ensure that the Off setting is selected.

  6. Click Create to create a zone populated with the NS and SOA records.

  7. To point your registered domain proper noun to the IP accost of the hosting server, you lot must add an A record to your zone:

    1. On the Zone details page, click Add tape prepare.
    2. Select A from the Resource Record Type menu.
    3. For IPv4 Accost, enter the external IP accost for your case.
    4. Click Create to create the A record for your zone.
  8. Optional: Add a CNAME tape to business relationship for a prefix to your domain name (for example, www.):

    1. Click Add Record Set.
    2. In the DNS Name field, add the prefix www for the domain.
    3. For Resources Record Blazon, choose CNAME.
    4. For Canonical name, enter the domain name, followed by a period (for example, instance.com.).
    5. Click Create.
  9. On the Zone details page, click Registrar Setup on the acme right to access the NS records. Make a note of the NS records because you need these records to go along with Step five.

Pace five: Update name servers

To update name servers in Google Domains, follow these steps:

  1. To update the proper name servers for your domain, go to Google Domains.
  2. Click the domain that you gear up upwards in Step 1. Alternatively, yous tin can click the Manage link for that domain.
  3. On the left navigation bill of fare, click DNS.
  4. For Name servers, select Use custom name servers.
  5. In the Name server field, enter the NS records that yous copied from the Zone details page (for example, ns1.googledomains.com) i at a fourth dimension.
  6. To add together name servers, click Add.
  7. Update all iv name servers on your Google Domains DNS page.
  8. Click Relieve.

Step half-dozen: Verify your setup

To verify that your configuration is working, after the name servers are updated, navigate to your domain name (for instance, example.com). The domain should resolve to your IP address and should point to the Compute Engine VM displaying the How-do-you-do World! page that you created in Step 3.

To verify that your setup is right, y'all can also run the dig +trace example.com command on your last window. Supervene upon case.com with your registered domain name.

dig +trace example.com                      

The terminate of the output should include the post-obit. IP_ADDRESS is your web server's IP address.

example.com.    300 IN  A                        IP_ADDRESS                        ;; Received 62 bytes from 216.239.34.109#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 superlative-level domain name servers are pointing to the custom name servers that you entered in Google Domains, every bit 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 complete, you can also run the nslookup command to verify your setup:

nslookup instance.com                      

The output should include the following. IP_ADDRESS is your spider web server'south IP address.

Server:     127.0.0.one Address:    127.0.0.1#53  Non-authoritative answer: Name:   example.com Accost:                        IP_ADDRESS                      

Make clean upwardly

  1. In the Cloud console, become to the Cloud DNS zones page.

    Go to Cloud DNS zones

  2. Click a zone name (for example, my-new-zone) to become to the Zone details page.

  3. Select the A and CNAME records that y'all created.

  4. Click Delete record sets.

  5. To delete the zone, click Delete zone for the zone name my-new-zone.

  6. Become to the VM instances page.

    Go to VM instances

  7. Select the instance that yous want to delete.

  8. On the More bill of fare in the row of the instance, click Delete.

What's next

  • To add, delete or update records, see Manage records.
  • To create, update, list, and delete managed zones, come across Manage zones.
  • To observe solutions for common problems that you might encounter when using Cloud DNS, come across Troubleshoot.
  • To reference the API, meet Cloud DNS REST API.
  • To determine costs, run across Cloud DNS Pricing.
  • To get an overview of Deject DNS, see Deject DNS overview.