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 https://developers.google.com/cloud-dns/pricing 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.
- Go to https://console.developers.google.com/project
- Create a new project and choose a descriptive project name such as “Google DNS”, copy down the project ID because we need it later.
- Click “Enable an API” from the Project Dashboard.
- 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).
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 https://developers.google.com/cloud/sdk/, download and install the SDK before you continue. We only need the Cloud SDK Core Libraries and Tools for Google Cloud DNS. 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.
1 | gcloud components list |
If you don’t see “Cloud DNS Admin Command Line Interface” as “Installed”, run the following command.
1 | gcloud components update dns |
Next, authorize access to the Google APIs with your Google domain admin account.
1 | 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.
1 | 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.
1 | gcloud config set project qualityology |
Let’s create a new Cloud DNS managed zone so we can manage DNS zones and records.
1 | gcloud dns managed-zone create --description="qualityology.com zone" --dns_name="qualityology." qualityology |
- –description=”qualityology.com zone” is a readable description of your DNS zone.
- –dns_name=”qualityology.com.” is your domain name. Make sure you include the trailing dot.
- qualityology is the name of our managed zone.
You will see:
1 | Creating {'dnsName': 'qualityology.com.', 'name': 'qualityology', 'description': |
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.
1 | gcloud dns records --zone=qualityology list |
You will see:
1 | [ |
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 ns-cloud-e1.googledomains.com
- the domain administrator’s contact e-mail is dns-admin@google.com, 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.
1 | 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.
1 | { |
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: https://developers.google.com/cloud-dns/what-is-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:
1 | { |
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:
1 | 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.
1 | mode 120,500 |
Now re-run the the list command you will be able to see up to 500 lines.
1 | 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:
1 | gcloud dns managed-zone get all4os |
1 | "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: https://developers.google.com/cloud-dns/gcloud-dns-command
Comments