Conteng Evolved

Stuff, mostly software development stuff

Using Google Cloud DNS

Google Cloud DNS service provides an interesting pay as you use pricing model. Announced in March 2014, Google Cloud DNS can only be managed via Google’s gcloud command line tool or REST APIs.

The steps described on the Cloud DNS Getting Started page are quite detailed to get started.

Not a Domain Name Registrar

Since Google Cloud DNS is not a domain name registrar, you will need to register a domain name and point the name server of the domain to the “NS” record of the managed zone created in Google Cloud DNS.

If you have multiple zones, take note that Google’s name servers look similar but may not be the same for each zone.

○ → gcloud dns managed-zone list
[
    {
        "creationTime": "2014-06-21T08:51:36.824Z",
        "description": "xxx.net.",
        "dnsName": "xxx.net.",
        "id": "9014807081031811107",
        "kind": "dns#managedZone",
        "name": "xxxnet",
        "nameServers": [
            "ns-cloud-e1.googledomains.com.",
            "ns-cloud-e2.googledomains.com.",
            "ns-cloud-e3.googledomains.com.",
            "ns-cloud-e4.googledomains.com."
        ]
    },
    {
        "creationTime": "2014-06-21T08:51:38.759Z",
        "description": "xxx.com.",
        "dnsName": "xxx.com.",
        "id": "6449170171006388811",
        "kind": "dns#managedZone",
        "name": "xxxcom",
        "nameServers": [
            "ns-cloud-b1.googledomains.com.",
            "ns-cloud-b2.googledomains.com.",
            "ns-cloud-b3.googledomains.com.",
            "ns-cloud-b4.googledomains.com."
        ]
    }
]

Google Domains

On a related note, Google just announced a domain registration service! At the moment, it is in private beta and requires an invite. I am sure details about this service will be announced during Google I/O 2014.

Common Commands

These are the common commands used when managing DNS zones and records through this service.

# managing zone where each TLD should be in a separate zone
gcloud dns managed-zone list
gcloud dns managed-zone create --dns_name xxx.com. -- description xxx.com. xxxcom -q
gcloud dns managed-zone delete xxxcom

# managing records within a zone
gcloud dns records --zone=xxxcom list
gcloud dns records --zone=xxxcom edit

DNS Records

While there are many types of DNS records, understanding Type A, CNAME and MX records will be sufficient for common web and mail hosting needs.

Type Host Record Points to TTL Description
A xxx.com. 123.123.123.123 21600 Maps xxx.com to 123.123.123.123.
CNAME www.xxx.com. xxx.com. 21600 Maps www.xxx.com to xxx.com.
MX xxx.com aspmx.l.google.com. 21600 This record is used to map domain to message transfer agent (MTA) to send/receive emails.

For example, to configure:

  • xxx.com hosted at IP 123.123.123.
  • www.xxx.com pointing to the same IP address.
  • xxx.com to use Google Apps manage emails.
  • docs.xxx.com and mail.xxx.com to redirect to Google hosted services.

Insert the following JSON data to the “additions” section when editing DNS records:

{
    "kind": "dns#resourceRecordSet",
    "name": "xxx.com.",
    "rrdatas": [
        "123.123.123.123"
    ],
    "ttl": 21600,
    "type": "A"
},
{
    "kind": "dns#resourceRecordSet",
    "name": "www.xxx.com.",
    "rrdatas": [
        "xxx.com."
    ],
    "ttl": 21600,
    "type": "CNAME"
},
{
    "kind": "dns#resourceRecordSet",
    "name": "mail.xxx.com.",
    "rrdatas": [
        "ghs.googlehosted.com."
    ],
    "ttl": 21600,
    "type": "CNAME"
},
{
    "kind": "dns#resourceRecordSet",
    "name": "docs.xxx.com.",
    "rrdatas": [
        "ghs.googlehosted.com."
    ],
    "ttl": 21600,
    "type": "CNAME"
},
{
    "kind": "dns#resourceRecordSet",
    "name": "xxx.com.",
    "rrdatas": [
        "10 aspmx.l.google.com.",
        "20 alt1.aspmx.l.google.com.",
        "20 alt2.aspmx.l.google.com.",
        "30 alt3.aspmx.l.google.com.",
        "30 alt4.aspmx.l.google.com."
    ],
    "ttl": 21600,
    "type": "MX"
}

Comments