Guide to configuring custom DNS and Azure Private DNS Zones within VNets, linking networks, enabling auto registration and forwarding, and applying security and best practices for hybrid name resolution
In this lesson you’ll learn how to configure DNS inside Azure Virtual Networks (VNets) using your own DNS servers and Azure Private DNS Zones. This setup is common in enterprise and hybrid environments where you need custom name resolution, consistency with on‑premises DNS, or host name auto‑registration.At a high level, the architecture looks like this: two Azure VNets (VNet1 and VNet2), each running VMs and a local DNS server (10.1.0.4 in VNet1 and 10.2.0.4 in VNet2). An on‑premises DNS can forward queries into Azure. Each VM uses the local custom DNS server. That DNS server resolves local names and forwards queries it cannot resolve either to other DNS servers over peering/S2S or to Azure’s platform resolver at 168.63.129.16 for Azure service names.
Best practices
Configure DNS servers for recursive resolution and add forwarders where needed (to Azure DNS or on‑prem/third‑party resolvers).
Allow DNS traffic (UDP/TCP port 53) through relevant NSGs, firewalls, and VNet/NVA routes.
Keep DNS servers internal to trusted networks — do not expose authoritative DNS servers directly to the public internet.
Do not expose your authoritative DNS servers directly to the public internet. Restrict DNS access to trusted networks to reduce risk.
Using your own DNS servers in Azure gives you centralized control and compatibility with existing infrastructure, but requires correct configuration of forwarding, recursion, and security to avoid resolution failures. When configured correctly, you get seamless name resolution across on‑premises, multiple VNets, and Azure services.Next, we walk through a practical example using the Azure Portal and two VMs (one in East US and one in West US), plus an Azure Private DNS Zone that both VNets can use.Prerequisites
Two VNets in separate regions (East US, West US), each with a subnet and a Linux VM.
Appropriate NSG rules allowing DNS traffic between VMs and DNS servers.
An Azure subscription with permissions to create VNets, VMs, and Private DNS Zones.
You can create a basic environment with the following PowerShell snippet. It defines variables, creates a resource group, two VNets and subnets, and a public IP for VM1. (Extend this snippet as needed to create NICs and VM resources.)
Purpose: provide a common internal namespace (e.g., corecloudint.com or kodekloudint.com) that VMs across VNets can resolve.
Note: Private DNS Zones are global resources; the resource group location only stores metadata.
Create the zone in the Azure Portal (or via CLI/PowerShell) and review + create:
Linking VNets to the Private DNS Zone (Virtual Network Link)
Creating the Private DNS Zone is not sufficient by itself for VMs to resolve names. You must create Virtual Network Links to associate a VNet with the Private DNS Zone.
When you add a Virtual Network Link you can enable auto‑registration. With auto‑registration, Azure automatically creates A records for VM hostnames in the Private DNS Zone when VMs are created in that VNet.
When adding a virtual network link, select the target VNet and enable auto‑registration if you want VM A records registered automatically:
After creating a virtual network link and enabling auto‑registration, records appear in the Private DNS Zone automatically. You can also add records manually for custom entries (for example, add an A record “web” → 192.168.10.10).Viewing record sets in the Private DNS Zone:
Testing name resolution from VMs
From a VM in an East US VNet that is linked to the private zone and has auto‑registration enabled, run nslookup to confirm the zone resolves:
Example: connect to the East US VM and resolve the web record:
Fix: create a Virtual Network Link for the West US VNet and enable auto‑registration. After the link exists, the West US VNet can resolve records in the Private DNS Zone.The portal will show the zone record sets (including any auto‑registered VM A records):
After linking both VNets, nslookup from the West US VM shows the East US VM’s FQDN resolved:
Name resolution and network connectivity are separate concerns. Resolving an IP address does not imply the VNets are connected.
To enable cross‑VNet traffic you must configure VNet peering, site‑to‑site VPN, or ExpressRoute as required.
DNS planning checklist (quick reference)
Item
Recommendation
Zone type
Use Azure Private DNS Zones for internal name resolution across VNets
VNet linking
Create Virtual Network Links; enable auto‑registration for VM A records
Custom DNS servers
Use when you need on‑prem integration or specialized resolution behaviour
Security
Allow DNS ports (UDP/TCP 53) internally; block public access to authoritative servers
Forwarding
Configure forwarders to Azure resolver (168.63.129.16) or on‑prem as needed
Next steps and additional guidance
If you require cross‑VNet connectivity, configure VNet peering or VPN/ExpressRoute.
If using custom DNS servers, ensure they have proper records or forwarding rules, can perform recursive queries, and are secured from public access.
Consider a hub‑spoke DNS topology: centralize DNS (and other shared services) in a hub VNet and link spokes to the hub’s Private DNS Zone(s).
Use a hub‑spoke architecture to centralize DNS: host DNS in a hub VNet and link spokes to the Private DNS Zone(s). This reduces the number of virtual network links and centralizes name management.
This guide walked through the architecture, best practices, and a portal‑driven example of using Azure Private DNS Zones and Virtual Network Links to provide consistent, secure name resolution across multiple VNets.