Microsoft Docs

Virtual network peering

This article explains how to configure virtual network peering in Azure. Virtual network peering connects two Azure virtual networks privately and securely, allowing them to communicate as if they were one network.

Introduction

Azure Virtual Network (VNet) peering enables you to connect two Azure virtual networks. Once peered, virtual networks can communicate with each other directly, using private IP addresses, without the need for gateways, VPNs, or other traffic-forwarding infrastructure. Traffic between peered VNets is private and stays within the Microsoft backbone network.

Benefits of VNet Peering

Configuration Steps

You can configure VNet peering using the Azure portal, Azure CLI, or Azure PowerShell.

Using Azure Portal

  1. Navigate to your virtual network in the Azure portal.
  2. Under Settings, select Peerings.
  3. Click + Add to create a new peering connection.
  4. Enter a Name for the peering connection.
  5. Select the subscription and virtual network you want to peer with.
  6. Configure Address space if the remote VNet does not have a peered gateway.
  7. Specify peering settings:
    • Allow virtual network access: Enable to allow traffic from the remote VNet to this VNet.
    • Allow forwarded traffic: Enable to allow traffic originating from on-premises or other VNets to transit this VNet to reach the remote VNet.
    • Allow gateway transit: Enable if the remote VNet has a VPN gateway and you want to route traffic through it.
    • Use remote gateways: Enable if the local VNet should use the VPN gateway in the remote VNet.
  8. Click Add to create the peering connection.

Azure CLI Example

az network vnet peering create \ --resource-group \ --name \ --vnet-name \ --remote-vnet \ --allow-vnet-access

Important Considerations

Transitive Routing: VNet peering is not transitive. If VNet A is peered with VNet B, and VNet B is peered with VNet C, VNet A cannot communicate with VNet C through VNet B unless explicit peering is configured between A and C.
IP Address Space Overlap: Ensure that the address spaces of peered virtual networks do not overlap. Overlapping address spaces will cause routing issues.
Gateway Transit: When enabling gateway transit, be mindful of the number of VNets that can use a single gateway. Ensure your gateway SKU supports the required connections.

DNS Resolution

By default, VNet peering uses Azure's default DNS resolution. For custom DNS, you need to ensure that your DNS servers are accessible from both VNets and that the DNS resolution is configured correctly. You can also enable 'Allow virtual network access' for DNS if needed.

Security

While peering provides a secure connection, always implement network security groups (NSGs) and Azure Firewall to control traffic flow between VNets and enforce security policies.

Troubleshooting

If you encounter issues with VNet peering:

For detailed troubleshooting steps, refer to the official Azure documentation.