Skip to main content
Configuring peering between two Azure virtual networks (VNets) enables private, low-latency communication between resources across VNets without exposing traffic to the public internet. This guide explains the key peering options, shows a short lab that demonstrates name resolution plus private connectivity between two Linux VMs in separate VNets/regions, and provides sample commands you can reuse.

Key peering settings

When creating a VNet peering, you typically choose from these options: Peering is configured per VNet—if you want bidirectional traffic, create the peering from both sides and enable the appropriate options.
Peering is non-transitive by default. To support forwarded traffic or gateway transit, ensure the correct options are enabled on both sides of the peering and that your routing/NVA policies permit transit.
The image shows a virtual network peering configuration interface, with options for setting peering connections and access permissions, alongside labeled sections like "Virtual Network Access," "Forwarded Traffic," "Gateway/Route Server Access," and "Peering Direction."
In the Azure portal the peering UI surfaces these toggles explicitly so you only grant what your topology requires.

Lab overview

This lab demonstrates private DNS name resolution and peering-based connectivity between VNets in different regions:
  • Two Linux VMs are deployed in separate VNets and regions (East US and West US).
  • A Private DNS zone is created and linked to both VNets so VMs are auto-registered with A records and resolve by private name.
  • Initially DNS resolution succeeds but traffic between VNets is blocked. After creating peering (configured on both VNets), connectivity via private IPs is validated (ping / SSH).

Create NICs, VMs, and a Private DNS zone (PowerShell snippet)

The following PowerShell excerpt shows the key steps to create NICs, VM configurations, deploy VMs, and create/link a Private DNS zone. Variables such as $resourceGroup, $locationWUS, $locationEUS, $subnetObj1, $subnetObj2, $pip1, $pip2, and credentials are assumed to be defined earlier in your script.
After deployment you should see both VMs in the portal.
The image shows the Azure portal interface displaying a list of virtual machines within the "Compute infrastructure" section. There are two running Linux virtual machines listed, each with distinct locations and public IP addresses.
To add peering you can also browse to Virtual networks in the portal and choose one of the VNets where you want to add a peering.
The image shows the Microsoft Azure portal displaying a list of virtual networks with details like name, resource group, location, and subscription. It includes options to create, manage, refresh, and filter virtual networks.

Check Private DNS registration

When the Private DNS zone is linked to both VNets with auto-registration enabled, each VM is automatically created as an A record in the zone.
The image shows an Azure portal interface displaying DNS zone settings for "az700peering.com," including record sets with details like type, TTL, and values.
From your workstation, SSH into one VM using its public IP and validate DNS resolution from within that VM. Example session (simplified):
DNS resolution via a Private DNS zone does not guarantee connectivity. Private name resolution can succeed while traffic is blocked until you establish the VNet peering and enable Virtual Network Access on both sides.

Configure VNet peering in the Azure portal

  1. Open one of the virtual networks (for example, the East US VNet).
  2. Select Peering and click Add peering.
  3. On the Add peering page, select the remote virtual network and set the peering options:
    • Allow virtual network access (basic connectivity),
    • Allow forwarded traffic (hub-and-spoke / NVA scenarios),
    • Use remote gateway (gateway transit) if you want to reuse the gateway in the remote VNet.
  4. Repeat on the remote VNet to establish bidirectional peering if required.
The image is a screenshot of the Microsoft Azure portal, displaying the overview section of a virtual network named "vnet-az700-peering-eus". It includes details such as resource group, location, and various capabilities like DDoS protection and Azure Firewall.
The form shows a local vs remote summary and exposes toggles for the three main options described above.
The image shows a Microsoft Azure portal interface for adding virtual network peering. It includes options for selecting resource manager settings and configuring remote virtual network peering settings.
Create the peering from both VNets if you require bidirectional traffic. When the peering state shows “Connected”, you can re-run connectivity tests.

Test connectivity after peering

After enabling peering (with Virtual Network Access allowed on both sides), ping/SSH across private addresses should succeed. Example ping output after peering was enabled:
Note: Depending on your environment there may be some packet loss or latency. The important change is that you now receive replies (where previously you saw 100% packet loss). SSH over the peered private network:

Conclusion and best practices

  • VNet peering provides private connectivity between VNets using Azure’s backbone and should be configured on both sides for full bidirectional flows.
  • Enable forwarded traffic and gateway transit only when your architecture requires inspection, centralized routing, or gateway reuse.
  • Always verify both name resolution (Private DNS) and actual traffic flow (ping/SSH) when validating a peering setup.
  • Review network security group (NSG) and firewall rules if connectivity is blocked despite peering being in place.
Quick reminder: SSH into a VM using its public IP from your local host when needed:

Watch Video