Host Your DNS With Google Cloud DNS

Can Google host my DNS? Yes. We can set domain DNS zones using the Google Cloud DNS service. Google Cloud DNS is a high performance, resilient, and global DNS service, which allows you to easily publish and manage DNS records.

It is FREE? Google Cloud DNS provide max billable limit: 50,000 requests/day, so is almost free for a small website.

For a website with huge amount of traffic, see

for pricing.

1. Create a new Cloud Project.

Google Cloud DNS is part of the Google Cloud Platform. First you need to create a new Cloud Project.

  1. Go to
  2. Create a new project and choose a descriptive project name such as "Google DNS", copy down the project ID because we need it later.
    Google Project
  3. Click "Enable an API" from the Project Dashboard.
    Google Project Enable Api
  4. Enable "Google Cloud DNS API" (Required). Disable the other default enabled APIs (such as Google Cloud Storage) as they are not required for this project (optional).
    Google Cloud Dns Api

2. Install the Google Cloud SDK

Google Cloud SDK contains tools and libraries that enable you to create and manage resources on Google Cloud DNS.

Go to, download and install the SDK before you continue.

We only need the Cloud SDK Core Libraries and Tools for Google Cloud DNS.

Google Cloud Sdk

Once the Cloud SDK is installed, make sure it includes the required DNS component. Open the Google Cloud SDK shell and execute the following command.

gcloud components list

Cloud Dns Admin Command Line

If you don't see "Cloud DNS Admin Command Line Interface" as "Installed", run the following command.

gcloud components update dns

Next, authorize access to the Google APIs with your Google domain admin account.

gcloud auth login

You will be asked to give permissions to "Google Cloud SDK" to perform operations on your behalf, and the list of permissions is sufficient to use any of the tools included in the SDK. The command will prompt you to enter the project ID. Enter the value from the Developers Console when you created the project.

Once you see You are now authenticated with the Google Cloud SDK! you can close the browser and continue.

To see if your account has been successfully added run the following command.

gcloud auth list

3. Create a Managed DNS Zone

You will need to set the project ID first. Change the value to the one that you created in the Developers Console.

gcloud config set project  qualityology

Let’s create a new Cloud DNS managed zone so we can manage DNS zones and records.

gcloud dns managed-zone create --description=" zone" --dns_name="qualityology." qualityology
  • –description=" zone" is a readable description of your DNS zone.
  • –dns_name="" is your domain name. Make sure you include the trailing dot.
  • qualityology is the name of our managed zone.

You will see:

Creating {'dnsName': '', 'name': 'qualityology', 'description': ' zone'} in google-dns Do you want to continue (Y/n)? Y { "creationTime": "2014-07-24T07:15:31.276Z", "description": " zone", "dnsName": "", "id": "5988761527897559933", "kind": "dns#managedZone", "name": "qualityology", "nameServers": [ "", "", "", "" ] }

4. Modify an existing DNS Record

In default, Google has added NS and SOA for us, to see the default detail, run the follow command.

gcloud dns records --zone=qualityology list

You will see:

[ { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ "", "", "", "" ], "ttl": 21600, "type": "NS" }, { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ " 0 21600 3600 1209600 300" ], "ttl": 21600, "type": "SOA" } ]

The NS record specifies four authoritative name server that you will need when you update your domain's name servers to use Google Cloud DNS

The SOA record specifies the base DNS information about the domain:

  • the primary name server is
  • the domain administrator's contact e-mail is, in SOA, it replace @ into a dot.
  • the initial serial number (which has to be incremented with every DNS update) is 0
  • the refresh time that secondary DNS servers wait before querying the primary DNS server's SOA record to check for changes is 21600 seconds
  • retry interval that a secondary server waits before retrying a failed zone transfer is 3600 seconds
  • the expire time that a secondary server will keep trying to complete a zone transfer is 1209600 seconds
  • the default minimum time to live is 300 seconds (used for negative caching, meaning that all the queries that don’t have a valid response are cached for this amount of seconds)

Now lets edit the DNS record.

gcloud dns records --zone=qualityology edit

Your default editor appears with an example of a change with both the additions and deletions sections displayed in JSON notation. You can edit it by entering your additions, deletions or both.
Additions is for new record, deletions is for deleting old record. If you want to change a record, make sure you delete the old record, otherwise it will shows error. After you done your editing, save and close your editor and all changes will be updated to the cloud DNS.

{ "additions": [ { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ " 1 21600 3600 1209600 300" ], "ttl": 21600, "type": "SOA" } ], "deletions": [ { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ " 0 21600 3600 1209600 300" ], "ttl": 21600, "type": "SOA" } ] }

The gcloud tool automatically incremented the serial counter of the SOA record, so the SOA records always shows in both additions and deletions.

Google Cloud DNS supported record types:

You can add all records in one batch. Here is the example of a adding records to Google Cloud DNS:

{ "additions": [ { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ "" ], "ttl": 86400, "type": "A" }, { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ "2605:6f00:877::3b9e:9265" ], "ttl": 86400, "type": "AAAA" }, { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ "10", "20", "20", "30", "30" ], "ttl": 3600, "type": "MX" }, { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ "", "", "", "" ], "ttl": 21600, "type": "NS" }, { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ " 1 21600 3600 1209600 300" ], "ttl": 21600, "type": "SOA" }, { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ "\"v=spf1 ~all\"" ], "ttl": 21600, "type": "SPF" }, { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ "\"v=spf1 ~all\"" ], "ttl": 21600, "type": "TXT" }, { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ "\"v=DKIM1; k=rsa; p=all4os\"" ], "ttl": 86400, "type": "TXT" }, { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ "" ], "ttl": 86400, "type": "A" }, { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ "2605:6f00:877::3b9e:9265" ], "ttl": 86400, "type": "AAAA" } ] "deletions": [ { "kind": "dns#resourceRecordSet", "name": "", "rrdatas": [ " 0 21600 3600 1209600 300" ], "ttl": 21600, "type": "SOA" } ] }

Note: we always use the same command to add or remove DNS record. However, your record will not show in your editor when you re-run the command again.

To list the records from your zone:

gcloud dns records --zone="all4os" list

You probably notice that the Shell only show part of the dns records and we are unable to scroll the window to see more information. Google Cloud SDK Shell for Windows in default limits 40 lines in a screen and the it is not scrollable. We need to change to mode to make the shell be able show more lines. If your display isn't large enough to show all lines, you can still have a shell box that can have much more virtual lines, so that you can scroll up to view the results of a long operation.

mode 120,500

Now re-run the the list command you will be able to see up to 500 lines.

gcloud dns records --zone="all4os" list

5. Update domain name servers

After you edited the DNS record, you are almost done. The last thing you need to do is point your domain's DNS to Google Cloud DNS.

To determine the Cloud DNS name server associated with the zone, use the following command:

gcloud dns managed-zone get all4os
"nameServers": [ "", "", "", "" ] }

Change your domain registrar's name servers for your domain, replace the name servers in the registrar’s NS records with the four name servers we looked up in the previous step (without the trailing dot).

You're all set. It can take up to 24-48 hours for the new nameservers to become fully active.

Other useful Google Cloud DNS commands:


  1. Hi,
    when I use this command can not work

    #gcloud components update dns
    You have specified individual components to update. If you are trying
    to install new components, use:
    $ gcloud components install dns

    Do you want to run install instead (y/N)? y

    ERROR: (gcloud.components.update) "dns" are not valid component name(s).

    1. What do you see when you use "gcloud components list"? If it is not installed, you will need to install it. Use "gcloud components install dns"

Leave a Reply

Your email address will not be published. Required fields are marked *