Guide to configuring Azure Virtual Network peering, options and deployment via PowerShell, using Private DNS, validating connectivity, and troubleshooting NSGs, gateway transit and overlapping address spaces.
Configuring peering between two Azure Virtual Networks (VNets) enables private, low-latency, high-bandwidth connectivity between VNets without routing traffic across the public internet. This guide explains the peering options you should consider, shows the PowerShell deployment script used in this example (creates two VNets in different regions, two VMs, and a Private DNS zone with VNet links), and demonstrates how to enable peering in the Azure portal and validate connectivity.Why use VNet peering?
Private connectivity between VNets in the same or different regions
Low latency and high throughput (backed by Azure’s Microsoft backbone)
Simple to configure and low operational overhead compared to VPN or ExpressRoute for VNet-to-VNet traffic
Peering key options
Option
Purpose
When to enable
Virtual network access
Allows resources in one VNet to reach resources in the peered VNet (VM-to-VM)
Most basic peering scenarios
Forwarded traffic
Permits traffic routed through a VNet (for example via firewall/NVA) to continue into a peered VNet
Allows a VNet to use the remote VNet’s VPN Gateway or Route Server
When multiple VNets share a single gateway to on-premises networks
Bidirectionality (peer both sides)
Peering must be configured on both VNets for full two-way access
Always confirm both sides are configured; unilateral peering can cause one-way failures
Always verify peering settings on both sides (local and remote). Only enable the options required by your topology (for example, forwarded traffic or gateway transit) to minimize attack surface and complexity.
Ensure VNets do not have overlapping IP address spaces — peering will fail (or routes will be invalid) if address spaces overlap. Also remember that peering must be created/configured on both VNets for bidirectional traffic unless using automation to provision both sides.
PowerShell deployment script (example)
Below is the PowerShell script used for this demonstration. It creates two VNets in different regions, deploys one VM in each VNet, and creates a Private DNS zone with virtual network links so the VMs register DNS records automatically.
After the deployment completes, you should see two virtual machines in the Azure portal (deployed to different regions with public IPs):
Pick one VNet to start the peering configuration — you can begin from either VNet. Peering must be created on both sides for full functionality. The Virtual Networks list shows the VNets and their regions:
Check the VNet DNS configuration before peering. In this example the VNet is using the default Azure-provided DNS. If your environment requires it, configure custom DNS servers at the VNet level.
Because the VMs were registered in a Private DNS zone, you can confirm the A records exist for each VM:
Validate name resolution and connectivity from one VM to the other before peering is configured (this verifies DNS registration but also demonstrates that network connectivity is blocked until peering is enabled):
Copy
# SSH to the West US VM public IP (example)ssh kodekloud@20.253.255.34# On the VM, check name resolution for the East US VMnslookup vm-az700-peering-eus-01.az700peering.com# Try to ping the private IP (will fail before peering)ping vm-az700-peering-eus-01.az700peering.com# Result: 100% packet loss before peering is configured
You will typically observe successful DNS resolution (Private DNS zone provides the private IP), but network-level connectivity fails until peering is established because the VNets remain isolated.Add peering in the Azure portal
Open the source VNet in the Azure portal.
Select Peerings → Add peering.
Configure the local and remote options:
Remote virtual network: select the remote VNet.
Allow virtual network access: enable for basic connectivity.
Allow forwarded traffic: enable if you need traffic forwarded from an NVA or firewall.
Allow gateway transit / Use remote gateways: enable only if you intend to share a VPN Gateway or Route Server.
The portal’s Add peering page exposes these options:
Repeat the peering configuration on the remote VNet (or use automation/templates to create the corresponding peering). When both sides are configured successfully, the peering status in the portal will show Connected for both VNets and you’ll receive notifications about the successful creation.Validate connectivity after peering
After enabling peering on both sides, test name resolution and network connectivity (ping/SSH) from one VM to the other over the private IP addresses.Example successful ping after peering:
Copy
# From East US VM to West US VM private DNS nameping vm-az700-peering-wus-01.az700peering.com# Sample responding output:64 bytes from 10.40.1.4: icmp_seq=91 ttl=64 time=73.0 ms64 bytes from 10.40.1.4: icmp_seq=92 ttl=64 time=72.6 ms...# Ping statistics:113 packets transmitted, 33 received, 70.7965% packet loss, time 113949msrtt min/avg/max/mdev = 71.888/72.476/73.552/0.347 ms
SSH directly over private IP or private DNS name:
Copy
# SSH from East US VM to West US VM using reachable private IP (example)ssh kodekloud@10.40.1.4# On successful connect, you will see the remote VM prompt:kodekloud@vm-az700-peering-wus-01:~$
If connectivity still fails after peering:
Re-check that both peerings are Connected in the portal.
Ensure NSG rules on subnets/VMs allow ICMP/SSH traffic.
Confirm there are no overlapping IP address spaces between VNets.
Verify forwarded traffic/gateway transit settings if traffic is being routed via an NVA or shared gateway.
Summary & checklist
Configure required peering options according to your topology: virtual network access, forwarded traffic, gateway access.
Always create/configure peering on both VNets for bidirectional traffic unless automated.
Use Private DNS zones with virtual network links to provide name resolution for VMs across peered VNets.
Test DNS (nslookup) and network connectivity (ping, SSH) after peering to validate setup.
Verify NSG rules, address space uniqueness, and any gateway or NVA forwarding requirements.