DNS in GCP: VPC Resolver, Cloud DNS, and Private Zones Explained

GCP handles DNS in two distinct ways. Every VPC includes a built-in resolver that works automatically for internal VM names and public lookups. Cloud DNS is a separate managed service for when you need to host your own authoritative zones. Understanding the difference between the two will save you a lot of confusion when things do not resolve as expected.

Simple explanation

DNS translates human-readable names into IP addresses. When a VM in GCP tries to reach my-database.internal or api.example.com, DNS figures out the IP address it should connect to.

Inside GCP, DNS works at two levels:

  • The built-in VPC resolver: present in every VPC, handles internal VM names and forwards public queries automatically. You never create it and you rarely need to configure it.
  • Cloud DNS: a managed service you opt into when you want to control DNS records yourself. You use it to host a public domain, create private internal names, or forward queries to an on-premises DNS server.
The key distinction

The VPC resolver is infrastructure you always have. Cloud DNS is a service you use when you need more control. Most beginner confusion comes from treating these as interchangeable — they serve different purposes and you often need both.

Analogy

Think of the VPC resolver as a company receptionist. They know every internal extension by heart and can look up any public phone number on request — no extra setup needed. Cloud DNS is like the managed phone directory system. The receptionist uses it to answer calls, but someone on your team has to actually maintain the directory and keep it up to date.

How DNS works in GCP

When a VM needs to resolve a name, the query follows a path through the VPC resolver:

  1. The VM sends a DNS query to the VPC resolver at 169.254.169.254 (configured automatically via DHCP).
  2. The resolver checks whether the name matches an internal GCP name, for example a Compute Engine VM hostname ending in .internal.
  3. If a private Cloud DNS zone is attached to the VPC, the resolver checks that zone next.
  4. If a DNS forwarding zone is configured, queries for matching domains are sent to a designated on-premises or custom DNS server.
  5. For everything else, the resolver forwards the query to Google’s public DNS infrastructure.

Cloud DNS sits alongside the resolver. It provides the authoritative data for zones you manage. The resolver does the actual lookups; Cloud DNS is where the records live when you create your own zones. For more detail on how VPC networks are structured, the VPC networking page covers the underlying infrastructure.

Note

Not all DNS in GCP requires Cloud DNS. Steps 1 and 2 above happen automatically in every VPC with no Cloud DNS setup at all. You only need Cloud DNS when you want to manage your own zones with custom records.

The built-in VPC DNS resolver

Every GCP VPC has a DNS resolver that VMs use automatically. You do not provision it, configure it, or pay for it separately. VMs are pointed to it via DHCP when they start.

Where to reach it

  • 169.254.169.254: the same link-local address as the metadata server, which also handles DNS queries
  • The .2 address of the subnet CIDR: for example, if your subnet is 10.10.0.0/24, the resolver is also at 10.10.0.2

Both addresses are always valid. Most tooling and documentation uses 169.254.169.254. See the subnets page for how subnet CIDRs are assigned if this is new to you.

What it resolves

  • Internal GCP resource names: VM hostnames, Cloud SQL private hostnames, and similar
  • Private Cloud DNS zones that are attached to the VPC
  • Forwarding zones: queries for specific domains sent to an on-premises or custom DNS server
  • Any public name, forwarded to Google’s public DNS infrastructure

When you do not need to think about it

For most workloads running entirely inside GCP, the VPC resolver handles everything without any configuration. You only need to interact with it directly when debugging resolution failures or configuring custom forwarding behaviour. If you hit a DNS issue, the DNS resolution troubleshooting guide covers how to diagnose what is going wrong.

Internal DNS for Compute Engine VMs

Every Compute Engine VM automatically gets an internal DNS name. These names are predictable and stable. They do not change when the VM is restarted, and they always resolve to the VM’s primary internal IP address.

Name formats

  • INSTANCE_NAME.ZONE.c.PROJECT_ID.internal: zone-specific fully qualified name, for example my-vm.europe-west1-b.c.my-project.internal
  • INSTANCE_NAME.c.PROJECT_ID.internal: resolves across all zones in the project

Why this matters in practice

Use these names instead of IP addresses when services need to communicate with each other. Internal IP addresses can change when a VM is recreated or when you modify its network interface. DNS names do not. If your application has an IP address hardcoded and that VM gets replaced, the connection breaks. If it uses the DNS name, it keeps working.

Good habit

This is especially relevant with private IP addresses. If your VM does not have a public IP, the internal DNS name is the primary stable way to reference it from other services in the same VPC. Treat it like a hostname, not a detail you look up once and paste into config.

# From inside another VM, check that internal DNS resolves correctly
nslookup my-vm.europe-west1-b.c.my-project.internal 169.254.169.254

If that lookup fails, the issue is almost always firewall rules, the VPC configuration, or the VM being in a different VPC without peering. Check the networking troubleshooting guide for a structured approach.

Cloud DNS explained

Cloud DNS is GCP’s managed authoritative DNS service. Authoritative means it is the definitive source of truth for the zones you create in it. When resolvers ask for records in your zone, Cloud DNS answers with what you have configured.

You use Cloud DNS when you need to manage DNS records yourself. That might be hosting a public domain, creating stable internal names for services inside your VPC, or routing DNS queries in a hybrid environment. You do not use it just to make VMs find each other — that is already handled by the VPC resolver.

Cloud DNS is fully managed. There are no DNS servers to provision, no software to update, and it is designed to be globally available with low latency. You interact with it through the GCP Console, the gcloud CLI, or the API. The Cloud DNS setup guide walks through creating zones and adding records step by step.

Public zones vs private zones

Public zones

A public zone is authoritative for a domain on the public internet. If you own example.com, you can host it in Cloud DNS and manage all its records through GCP — A, AAAA, MX, TXT, CNAME, and so on. You then update your domain registrar to point NS records to the Cloud DNS name servers, and Cloud DNS becomes the authority for that domain.

Public zones are the right choice when you want a single place to manage DNS for an internet-facing domain, when you need programmatic control over records as part of a deployment pipeline, or when you want DNSSEC support.

Private zones

A private zone resolves only from within the VPCs you specify. It is not visible on the public internet. You use private zones to create internal service names that are stable and human-readable, for example db.internal.mycompany.com pointing to a Cloud SQL instance, or payments-api.internal pointing to an internal load balancer.

Private zones are also used to override a public domain inside your VPC. If you want a name to resolve differently inside your network than it does on the internet, a private zone with the same name takes precedence. The full setup and use cases are covered on the private DNS zones page.

Easy to miss

A private zone must be explicitly associated with one or more VPCs. It does not automatically apply to all VPCs in a project. If you create a private zone and associate it with VPC A, VMs in VPC B will not see it unless you also associate it with VPC B, or set up VPC peering between the two networks.

DNS record types you will actually use

Cloud DNS supports all standard record types. These are the ones you will encounter most often:

  • A: maps a hostname to an IPv4 address. Most common record type.
  • AAAA: maps a hostname to an IPv6 address.
  • CNAME: an alias that points one hostname to another hostname. Useful for subdomains that should follow the same address as a root record.
  • MX: mail exchanger; directs email for a domain to the right mail servers.
  • TXT: arbitrary text records used for domain ownership verification, SPF email policy, DKIM signing keys, and similar.
  • NS: name server records that delegate a subdomain to a different set of name servers.
  • SOA: start of authority; contains zone metadata. Cloud DNS manages this automatically and you do not edit it directly.

When you create a record in Cloud DNS, you set the record type, the name (for example api.example.com), the value (for example an IP address), and a TTL.

TTL explained simply

TTL, or time to live, is a number in seconds that tells resolvers how long to cache a DNS record before checking again. It is set per record in Cloud DNS.

  • High TTL (3600+ seconds): resolvers cache the record for a long time. DNS query volume is lower, but changes take longer to propagate everywhere.
  • Low TTL (30–300 seconds): resolvers refresh more frequently. Changes propagate faster, but you generate more DNS queries.

The practical rule for migrations

If you know you are going to change a DNS record — for a domain cutover, a service migration, or an IP change — lower the TTL well in advance. The recommended approach:

  1. At least 24 to 48 hours before the change, reduce the TTL to 60 or 300 seconds.
  2. Make the actual record change.
  3. Wait for the change to propagate (which now only takes minutes, not hours).
  4. Once confirmed stable, raise the TTL back to a comfortable value.
Do this before migration day

If you skip step one and your record has a 3600-second TTL, clients that recently cached the old record will continue using it for up to an hour after you make the change. This causes split behaviour where some clients get the new address and others still get the old one. It is a very easy problem to avoid and a very frustrating one to debug mid-migration.

DNSSEC

DNSSEC (DNS Security Extensions) adds cryptographic signatures to records in public zones. When a resolver queries a DNSSEC-enabled zone, it can verify that the response is genuine and has not been tampered with in transit.

Enabling DNSSEC in Cloud DNS is done with a single command, but it requires one additional step at your domain registrar: you must publish a DS record that Cloud DNS generates. Without this step, the trust chain from the DNS root to your zone is broken, and resolvers that enforce DNSSEC validation will treat your domain as failing validation.

# Enable DNSSEC on an existing public zone
gcloud dns managed-zones update my-public-zone \
  --dnssec-state=on

# Get the DS record to add at your registrar
gcloud dns dns-keys describe 0 \
  --zone=my-public-zone \
  --format="get(dsRecord)"
Do not skip this step

Enabling DNSSEC in Cloud DNS without publishing the DS record at your registrar does not just mean DNSSEC is inactive. Resolvers that enforce DNSSEC validation will actively fail to resolve your domain. Your site or service can become unreachable for users on DNSSEC-validating resolvers. Always complete the registrar step before announcing DNSSEC is active.

Private zones

DNSSEC is only available for public zones. Private zones do not support it, and do not need it. The attack DNSSEC defends against (forged DNS responses from the public internet) does not apply to a zone that is only reachable inside your VPC.

When to use Cloud DNS vs the built-in resolver

The right tool depends on what you are trying to do:

  • VMs resolving each other by hostname: the VPC resolver handles this automatically. No Cloud DNS required.
  • Hosting a public internet domain: create a public zone in Cloud DNS and delegate your domain to its name servers.
  • Internal service names inside a VPC: create a private zone in Cloud DNS and attach it to your VPC. This is how you get stable, human-readable names for databases, internal APIs, or service endpoints.
  • Hybrid networking, forwarding queries to on-premises DNS: configure DNS forwarding zones in Cloud DNS so queries for your corporate domain are sent to your on-premises DNS servers. This requires Cloud VPN or Cloud Interconnect for the network path. See the hybrid connectivity overview for context.
  • Overriding a public name inside your VPC: create a private zone with the same domain name. Private zones take precedence over public resolution for VMs in the associated VPC.

Resolver vs Cloud DNS

Here is a quick comparison to clarify when each applies:

VPC resolverCloud DNS — public zoneCloud DNS — private zone
PurposeResolve names for VMs in the VPCHost a domain on the public internetCreate internal names visible only inside VPCs
Who uses itAll VMs automaticallyOwners of public domainsTeams with internal service naming needs
AutomaticYes, always presentNo, you create and manage itNo, you create and manage it
Publicly visibleNoYesNo
You manage recordsNoYesYes
Common use caseInternal VM-to-VM resolutionWebsite or API domainInternal database hostname, private service name

Public DNS vs private DNS at a glance

Public DNS zonePrivate DNS zone
Resolvable fromAnywhere on the internetOnly from associated VPCs
Use caseInternet-facing domainsInternal service names
DNSSEC supportYesNo
Requires VPC associationNoYes

Common mistakes

  1. Confusing the VPC resolver with Cloud DNS. The resolver is always there — you do not create it. Cloud DNS is a separate service you opt into. Many beginners set up Cloud DNS thinking it is required for internal VM resolution. It is not. The resolver already handles that.
  2. Enabling DNSSEC without adding the DS record at the registrar. Turning on DNSSEC in Cloud DNS is only step one. Until you publish the DS record at your registrar, the trust chain is incomplete. Clients that enforce DNSSEC validation will fail to resolve your domain entirely, not just skip validation quietly.
  3. Not lowering TTLs before a DNS migration. If your record has a 3600-second TTL and you update the value, resolvers that cached it recently will serve the old answer for up to an hour. Lower the TTL to 60 to 300 seconds at least a day in advance, then restore it after the change is confirmed.
  4. Assuming DNS changes are instant everywhere. Cloud DNS propagates your changes to its name servers within seconds. But the VPC resolver, ISP resolvers, and client caches all hold records for up to the TTL. “Changed in Cloud DNS” does not mean “changed everywhere immediately.”
  5. Using IPs instead of DNS names for internal services. Internal IP addresses are not guaranteed to stay the same across VM replacements. Using the internal DNS name or a private Cloud DNS name keeps your services loosely coupled. When a VM is replaced, only the DNS record needs updating, not every service that connects to it.
  6. Creating a private zone but forgetting to associate it with the right VPC. A private zone must be explicitly associated with a VPC. If you create it and do not attach it to the VPC where your workloads are running, resolution will fail. This is a very common cause of “I created the record and it still doesn’t resolve” bugs.

Real example scenarios

1. Internal app resolving another VM by hostname

You have two VMs in the same VPC: web-server and app-server. The web server needs to send requests to the app server. Instead of hardcoding 10.10.0.5, you configure the web server to call app-server.us-central1-a.c.my-project.internal. The VPC resolver handles this automatically. If the app server VM is ever replaced, its internal DNS name stays the same and the connection keeps working.

2. Public website hosted in Cloud DNS

You own mycompany.com and want to manage its DNS from GCP. You create a public zone in Cloud DNS for mycompany.com, add A records pointing to your load balancer IP, and update your domain registrar’s NS records to point to the Cloud DNS name servers. From that point on, all DNS for mycompany.com is managed through Cloud DNS. Records can be updated using gcloud or the Console, and changes propagate within seconds.

3. Internal database hostname using a private zone

Your team wants to connect to a Cloud SQL instance using the name db.internal.mycompany.com rather than the automatically assigned IP. You create a private Cloud DNS zone for internal.mycompany.com, associate it with your VPC, and add an A record pointing db to the Cloud SQL private IP. VMs in your VPC can now resolve db.internal.mycompany.com. If the Cloud SQL instance is replaced or migrated, you update one DNS record rather than reconfiguring every application that connects to it.

4. Hybrid environment forwarding a corporate domain to on-premises DNS

Your organisation has an on-premises network connected to GCP via Cloud VPN. The on-premises DNS server handles corp.mycompany.internal. You want GCP VMs to be able to resolve hostnames in that domain. You configure a DNS forwarding zone in Cloud DNS for corp.mycompany.internal, pointing to the on-premises DNS server IP. The VPC resolver then forwards queries for that domain through the VPN to the on-premises server. See the hybrid connectivity overview for how the network layer works.

Frequently asked questions

What is the difference between Cloud DNS and the GCP VPC resolver?

The VPC resolver is a built-in DNS service that every GCP VPC gets automatically. It handles internal VM name resolution and public DNS lookups without any setup. Cloud DNS is a separate managed service for hosting authoritative DNS zones. You do not need Cloud DNS just to resolve VM names inside your VPC.

Do I need Cloud DNS for internal VM name resolution?

No. Compute Engine VMs automatically get internal DNS names in the format INSTANCE_NAME.ZONE.c.PROJECT_ID.internal. These are resolved by the built-in VPC resolver at 169.254.169.254. You only need Cloud DNS if you want to manage your own custom DNS zones, for example hosting a public domain or creating private internal names like db.internal.mycompany.com.

What is the difference between a public and a private DNS zone in Cloud DNS?

A public zone is authoritative for a domain on the public internet. Records in a public zone are resolvable by anyone. A private zone is only resolvable from within the VPCs you specify. Private zones are used for internal service names, database hostnames, or any name that should not be accessible outside your network.

How long do DNS changes take in GCP?

Cloud DNS propagates changes to its name servers within seconds. However, resolvers may have cached the old record for up to its TTL duration. If your record has a TTL of 3600 seconds, it can take up to an hour for all clients to see the new value. Always lower the TTL well before a planned migration.

Does Cloud DNS support DNSSEC?

Yes, for public zones. DNSSEC adds cryptographic signatures so resolvers can verify that a response is genuine and untampered. Enabling DNSSEC in Cloud DNS requires you to also publish a DS record at your domain registrar. Without that step, the trust chain is incomplete and validation will fail. DNSSEC is not supported on private zones because they are already confined to a trusted network context.

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