How to Set Up Cloud DNS | Managed Zones, Records, and Domain Delegation

Setting up Cloud DNS means creating a managed zone for your domain, adding the DNS records your services need, and if it is a public domain, pointing your registrar to GCP’s name servers. This page walks through each of those steps in order, explains what is happening at each stage, and shows how to verify that everything is working.

What Cloud DNS actually is

Cloud DNS is GCP’s managed authoritative DNS service. You give it a domain name, create records inside it, and it answers DNS queries for that domain on Google’s global infrastructure. You do not manage DNS server software or worry about availability.

Before you look at commands, three terms are worth understanding clearly:

  • Managed zone: the container that holds all the DNS records for one domain. If you own example.com, you create one zone for it. If you also own myapp.io, that is a separate zone.
  • DNS record: an entry inside a zone that maps a name to something useful. An A record maps www.example.com to an IP address. An MX record tells email servers where to deliver mail for that domain.
  • Delegation: the step where you tell your domain registrar to stop answering DNS queries for your domain and hand that authority to Cloud DNS. You do this by updating the name server addresses in your registrar’s control panel.
Analogy

Think of a managed zone like a filing folder labelled with a domain name. The folder itself is the zone. Inside it, each DNS record is a sticky note: one says “www points to 203.0.113.10”, another says “mail goes to Google’s servers”. Delegation is the step where you tell the post office that GCP is now in charge of sorting all mail addressed to that folder.

Public zones serve records to anyone on the internet. Private zones only resolve inside your GCP VPC. This page covers public zone setup. If you are trying to give internal services readable names inside a VPC, see Private DNS Zones instead.

For a broader explanation of how GCP’s DNS layers fit together, see DNS in GCP.

How Cloud DNS setup works, from start to finish

The full setup flow for a public domain has five stages:

  1. Enable the Cloud DNS API in your GCP project. This only needs to happen once.
  2. Create a public managed zone for your domain. GCP assigns four name server addresses to the zone.
  3. Add your DNS records to the zone: A records for your web server, MX records for email, TXT records for verification, and so on.
  4. Update your domain registrar to use Cloud DNS’s name servers. This is the delegation step. It tells the internet that Cloud DNS is now authoritative for your domain.
  5. Wait for propagation and verify. Changes can take up to 48 hours to spread to all resolvers worldwide, though in practice it is usually much faster.
Warning

The order matters. Add your records to Cloud DNS before you update the registrar. If you delegate first and add records later, there will be a window where queries for your domain return empty responses, so email fails, websites become unreachable, and external services cannot reach you.

When to use this

Cloud DNS is the right choice when you are doing any of the following:

  • Moving a domain’s DNS management into GCP so it lives alongside your infrastructure
  • Setting up records for a load balancer, Cloud Run service, or GCP-hosted website
  • Managing email records (MX, SPF, DKIM) for a domain your organisation owns
  • Adding verification TXT records required by Google Workspace, domain validation, or third-party services
  • Using Terraform to keep your DNS records in version control alongside other infrastructure
  • Setting up SSL certificates that require DNS-based domain ownership verification

If your goal is resolving internal service names inside a VPC (for example, giving a database a human-readable hostname), you do not need a public zone. See Private DNS Zones for that setup.

Step 1: Enable Cloud DNS

Cloud DNS is a GCP API that must be enabled before you can create zones or records. If you have already created any DNS resources in the Console, it is already enabled.

# Enable the Cloud DNS API
gcloud services enable dns.googleapis.com

# Confirm it is enabled
gcloud services list --enabled --filter="name:dns.googleapis.com"

Step 2: Create a public managed zone

A managed zone is the container for all the records belonging to your domain. Create one zone per domain. The —dns-name value must include the trailing dot. This must be a fully qualified domain name.

# Create a public managed zone for example.com
gcloud dns managed-zones create example-com-zone \
  --dns-name=example.com. \
  --description="Public zone for example.com" \
  --visibility=public

# Get the four name servers GCP assigned to this zone
gcloud dns managed-zones describe example-com-zone \
  --format="get(nameServers)"

The output will be four addresses in the format ns-cloud-XX.googledomains.com.. Copy all four. You will need them for the delegation step.

Step 3: Delegate your domain at the registrar

Log in to wherever you bought your domain (GoDaddy, Namecheap, Google Domains, Cloudflare, or any other registrar). Find the nameserver settings for your domain, usually under a label like “DNS”, “Nameservers”, or “Domain settings”. Replace whatever nameservers are listed there with the four Cloud DNS nameservers from the previous step.

Analogy

Delegation is like forwarding your post to a new address. The registrar is the old address. Cloud DNS is the new one. Once you update the forwarding, all mail (DNS queries) goes to Cloud DNS instead. The registrar still owns the domain name, but it no longer handles any of the actual lookups.

A few things to be aware of:

  • You are replacing the registrar’s nameservers entirely, not adding records. DNS record management moves to Cloud DNS once this is done.
  • Do this after you have added your critical DNS records to Cloud DNS. Email records (MX) are particularly important. If they are missing during the switchover, email delivery will fail.
  • Delegation can take up to 48 hours to propagate globally. Plan any domain migrations for a low-traffic period.
Note

Delegation and DNS records are two separate things. Delegation is a registrar-level setting that says “Cloud DNS answers for this domain.” DNS records are the actual entries inside Cloud DNS. Changing records inside Cloud DNS does not affect delegation, and changing delegation does not affect which records exist inside Cloud DNS.

Step 4: Add your DNS records

With the zone created, you can add records. The most common types are A (IPv4 address), CNAME (alias to another name), MX (email routing), and TXT (verification and policy records). Note the trailing dot on all fully qualified domain names. Cloud DNS requires it.

# Create an A record pointing www.example.com to an IP address
gcloud dns record-sets create www.example.com. \
  --zone=example-com-zone \
  --type=A \
  --ttl=300 \
  --rrdatas=203.0.113.10

# Create a CNAME aliasing blog.example.com to a storage bucket
gcloud dns record-sets create blog.example.com. \
  --zone=example-com-zone \
  --type=CNAME \
  --ttl=300 \
  --rrdatas=my-bucket.storage.googleapis.com.

# Create MX records for Google Workspace email
gcloud dns record-sets create example.com. \
  --zone=example-com-zone \
  --type=MX \
  --ttl=3600 \
  --rrdatas="1 aspmx.l.google.com.,5 alt1.aspmx.l.google.com.,5 alt2.aspmx.l.google.com."

# Create a TXT record for SPF email policy
gcloud dns record-sets create example.com. \
  --zone=example-com-zone \
  --type=TXT \
  --ttl=300 \
  --rrdatas='"v=spf1 include:_spf.google.com ~all"'

# List all records in the zone to review what exists
gcloud dns record-sets list --zone=example-com-zone

If you are setting up records to point to a GCP load balancer, the A record will use the load balancer’s external IP. See HTTP Load Balancer Setup for how to reserve and retrieve that IP address.

Tip

Before you switch the registrar’s nameservers, lower your TTL values to 60 or 300 seconds. This means resolvers around the internet will pick up any corrections much faster if something goes wrong during the cutover. Once everything looks stable, raise the TTL back to 3600 or higher.

Step 5: Make batch changes safely with transactions

When you need to update several records at once, for example removing old records and adding new ones as part of a migration, transactions let you stage all the changes together and apply them atomically. If any record in the transaction fails validation, none of the changes are applied.

# Start a transaction
gcloud dns record-sets transaction start --zone=example-com-zone

# Stage the changes: remove an old record and add a new one
gcloud dns record-sets transaction remove "203.0.113.10" \
  --zone=example-com-zone \
  --name=www.example.com. \
  --type=A \
  --ttl=300

gcloud dns record-sets transaction add "203.0.113.20" \
  --zone=example-com-zone \
  --name=www.example.com. \
  --type=A \
  --ttl=300

# Also add a new subdomain in the same transaction
gcloud dns record-sets transaction add "203.0.113.20" \
  --zone=example-com-zone \
  --name=api.example.com. \
  --type=A \
  --ttl=300

# Review what the transaction will do before committing
gcloud dns record-sets transaction describe --zone=example-com-zone

# Apply all changes at once
gcloud dns record-sets transaction execute --zone=example-com-zone

# If you want to cancel instead:
# gcloud dns record-sets transaction abort --zone=example-com-zone

Transactions are particularly useful when updating records that depend on each other, such as removing a CNAME and replacing it with an A record. That cannot be done as two separate operations because the zone would temporarily be invalid between them.

Step 6: Manage Cloud DNS with Terraform

For any environment beyond a quick test, managing DNS records via Terraform is worth the setup cost. Your DNS configuration lives in version control alongside the rest of your infrastructure, changes go through code review, and you can reproduce the entire zone from scratch if needed.

# Create the managed zone
resource "google_dns_managed_zone" "example" {
  name        = "example-com-zone"
  dns_name    = "example.com."
  description = "Public zone for example.com"
  visibility  = "public"
}

# A record for the www subdomain
resource "google_dns_record_set" "www" {
  name         = "www.${google_dns_managed_zone.example.dns_name}"
  managed_zone = google_dns_managed_zone.example.name
  type         = "A"
  ttl          = 300
  rrdatas      = ["203.0.113.10"]
}

# MX records for email
resource "google_dns_record_set" "mx" {
  name         = google_dns_managed_zone.example.dns_name
  managed_zone = google_dns_managed_zone.example.name
  type         = "MX"
  ttl          = 3600
  rrdatas = [
    "1 aspmx.l.google.com.",
    "5 alt1.aspmx.l.google.com.",
  ]
}
Tip

When importing existing Cloud DNS zones into Terraform, be careful with SOA and NS records. Cloud DNS manages these automatically. If Terraform attempts to create them as resources, it will conflict with the ones Cloud DNS already owns. Either import them explicitly or use lifecycle { ignore_changes = […] } to tell Terraform to leave them alone.

See Infrastructure as Code in GCP for a broader look at managing GCP resources through Terraform, including state management and workspace conventions.

Step 7: Verify that everything is working

After adding records and updating delegation, verify at the authoritative level before testing through your local resolver. Your local resolver might have cached old records from before the change.

# Query Cloud DNS directly to confirm the record exists at the authoritative source
# Replace ns-cloud-c1.googledomains.com with one of the nameservers from your zone
dig @ns-cloud-c1.googledomains.com. www.example.com A

# Check that delegation is working by tracing the full resolution path
dig +trace example.com NS

# Test from inside a GCP VM (uses the VPC resolver, confirms routing from GCP's perspective)
gcloud compute ssh test-vm \
  --zone=europe-west1-b \
  --tunnel-through-iap \
  --command="dig www.example.com A"

The dig +trace command shows the full resolution chain from the root servers down to Cloud DNS. If the chain ends at Google’s name servers, delegation is complete. If you hit DNS issues that are harder to diagnose, see Troubleshooting Network Issues for a structured debugging process.

Public zones vs private zones

Cloud DNS supports two zone types. The difference matters because using the wrong one causes problems that are frustrating to debug.

Analogy

A public zone is like a listing in the public phone book. Anyone on the internet can look it up. A private zone is like an internal staff directory posted inside the office. People inside the building can use it, but no one outside can see it exists.

  • Public zones are authoritative for records on the public internet. Anyone can query them. Use these for domains your users or external services need to reach: websites, APIs, email servers, and domain verification records.
  • Private zones are only resolvable from within the VPCs you specify. External resolvers cannot see them. Use these for internal service names, database hostnames, or any name that should not be visible outside your network.
Warning

The most common mistake is creating a public zone for what should be a private name. If you do this, internal hostnames like postgres.internal.example.com become queryable from anywhere on the internet. The services may not be reachable, but the names reveal your internal architecture. Use a private zone for anything that should stay inside the VPC.

See Private DNS Zones for the full setup guide, including DNS peering and on-premises forwarding. For the full picture of how public and private zones interact with the VPC resolver, see DNS in GCP.

Common beginner mistakes

  1. Delegating the domain before adding records to Cloud DNS. Once you change the nameservers at your registrar, all DNS queries for your domain go to Cloud DNS. If your MX records are not there yet, email delivery will fail immediately. Populate all critical records first, then switch the nameservers.
  2. Forgetting trailing dots on fully qualified domain names. Cloud DNS expects FQDNs with a trailing dot: example.com. not example.com. Omitting the trailing dot can cause commands to silently interpret the name as relative and append the zone name to it, producing records with unexpected names.
  3. Confusing registrar settings with DNS record management. The registrar controls which nameservers are authoritative for your domain. Cloud DNS controls the actual records. Once you delegate to Cloud DNS, any DNS record changes you make at your registrar are ignored. Make all record changes in Cloud DNS after delegation.
  4. Testing against a local resolver instead of the authoritative nameserver. After making changes, querying with your local dig or nslookup may return cached results from before the change. Query Cloud DNS’s own name servers directly with dig @ns-cloud-XX.googledomains.com. to see what the authoritative source is actually returning.
  5. Creating a public zone when a private zone was needed. If you want DNS names for internal GCP services that should not be visible on the internet, a public zone is the wrong tool. Use a private zone attached to your VPC. See Private DNS Zones for the correct setup.
  6. Not lowering TTLs before a planned migration. If your records have an hour-long TTL and you update them without lowering the TTL first, resolvers may serve stale records for up to an hour after the change. Lower TTLs to 60 to 300 seconds a day before a migration. Restore them afterward.

Frequently asked questions

How do I point my domain to Cloud DNS?

Create a public managed zone in Cloud DNS for your domain. GCP will assign four name servers to the zone (in the format ns-cloud-XX.googledomains.com.). Copy those four addresses and set them as the nameserver records for your domain at your domain registrar. Once the registrar propagates the change, Cloud DNS becomes the authoritative source for your domain. Add all your DNS records to Cloud DNS before switching the nameservers so you avoid any downtime window.

How long do Cloud DNS changes take to propagate?

Changes made inside Cloud DNS (adding or updating records) reach Google's authoritative name servers within seconds. However, resolvers around the internet may have cached the old record for up to the record's TTL. If your A record has a TTL of 3600 seconds (one hour), it can take up to an hour for all resolvers to pick up the change. Lowering the TTL to 60 to 300 seconds a day before planned changes helps minimise the propagation window.

Do I need to change anything at my registrar?

Only if you are setting up a public zone and want Cloud DNS to be authoritative for your domain. In that case, go to your domain registrar (where you bought the domain) and replace their default nameservers with the four Cloud DNS nameservers assigned to your zone. You are not adding DNS records at the registrar. You are redirecting all DNS authority to Cloud DNS. Once done, manage all records inside Cloud DNS.

What is the difference between a managed zone and a DNS record?

A managed zone is the container for all the DNS records belonging to a specific domain. You create one zone per domain (for example, one zone for example.com). Inside that zone, you create individual DNS records: an A record pointing www.example.com to an IP address, an MX record for email, a TXT record for domain verification, and so on. You must have a managed zone before you can add any records.

Should I use Cloud DNS or private DNS zones for internal services?

Use a public managed zone when you need records that are resolvable on the public internet: websites, APIs, email. Use a private zone when you need DNS names that only resolve inside your GCP VPC, such as internal service names or database hostnames. If you accidentally create a public zone for internal services, those names will be visible on the internet even if the services themselves are not reachable. The two zone types solve different problems.

Last verified: 24 March 2026 Cloud services change frequently. Verify details against official documentation before making infrastructure decisions.