Domain 4 — Module 2 of 5 40%
20 of 27 overall
Domain 4: Implement and Manage Virtual Networking Free ⏱ ~13 min read

VNet Peering & User-Defined Routes

VNets are isolated by design — so how do you connect them? VNet peering lets two VNets talk directly over Microsoft's backbone. User-defined routes give you fine-grained control over where traffic goes. Master both for the exam.

What is VNet Peering?

Simple explanation

VNet peering is like building a private corridor between two separate office buildings so staff can walk directly between them.

By default, two VNets can’t talk to each other — they’re completely isolated. Peering creates a direct, high-speed connection between them using Microsoft’s backbone network. Traffic never touches the public internet. It’s fast, low-latency, and works across regions.

The catch: peering is NOT automatic. You must set it up on BOTH sides. And it’s not transitive — if Building A connects to Building B, and Building B connects to Building C, people in Building A can’t walk to Building C through B (unless you set that up too).

Types of peering

Regional vs Global VNet peering
FeatureRegional PeeringGlobal Peering
VNet locationSame Azure regionDifferent Azure regions
LatencySame as within a VNetSlightly higher (cross-region)
BandwidthNo restrictionsNo restrictions
CostIngress and egress chargesHigher egress charges (cross-region)
Gateway transitSupportedSupported
Use caseMulti-tier apps in same regionDisaster recovery, global apps

Critical peering rules

  1. Peering must be created on BOTH VNets — create a peering link from VNet-A to VNet-B AND from VNet-B to VNet-A
  2. Address spaces cannot overlap — if both VNets use 10.0.0.0/16, peering will fail
  3. Peering is NOT transitive — if A peers with B and B peers with C, A cannot reach C through B
  4. You can’t peer a VNet with itself
  5. You can add peering to an existing VNet without downtime
Exam tip: Peering is NOT transitive

This is heavily tested. If VNet-A peers with VNet-B, and VNet-B peers with VNet-C, resources in VNet-A CANNOT communicate with VNet-C. You’d need to either create a direct peering between A and C, or use a hub-spoke topology with a network virtual appliance (NVA) or Azure Firewall in VNet-B to route traffic.

Think of it like phone calls — just because you have Alex’s number and Alex has Sam’s number doesn’t mean you can call Sam.

Gateway transit

Gateway transit allows a peered VNet to use the other VNet’s VPN or ExpressRoute gateway. This avoids deploying a gateway in every VNet.

How it works:

  • The hub VNet has the VPN/ExpressRoute gateway and enables “Allow gateway transit”
  • The spoke VNets enable “Use remote gateways” in their peering configuration
  • Spoke VNets can then reach on-prem networks through the hub’s gateway
Real-world: TechCorp's hub-spoke design

TechCorp Solutions uses a hub-spoke topology:

  • Hub VNet (10.0.0.0/16): Contains VPN gateway connecting to their on-prem datacentre, Azure Firewall, and shared services
  • Spoke 1 (10.1.0.0/16): Production workloads, peered to hub with “Use remote gateways”
  • Spoke 2 (10.2.0.0/16): Dev/test workloads, peered to hub with “Use remote gateways”

Both spoke VNets can reach on-prem through the hub’s VPN gateway — without needing their own gateways. Alex saved thousands in gateway costs.

User-Defined Routes (UDRs)

By default, Azure automatically routes traffic between subnets, to the internet, and to on-prem (via VPN). But sometimes you need to override this — that’s where UDRs come in.

How it works:

  1. Create a route table
  2. Add custom routes with a destination and next hop
  3. Associate the route table with one or more subnets

Next hop types

Next Hop TypeWhat It Does
Virtual networkRoutes within the VNet (default behaviour)
VNet gatewaySends traffic to a VPN or ExpressRoute gateway
InternetRoutes traffic to the internet
Virtual applianceSends traffic to a specific IP (e.g., Azure Firewall, NVA)
NoneDrops the traffic (black hole)

The most common use case: forcing all internet-bound traffic through a firewall by creating a UDR with destination 0.0.0.0/0 and next hop as the firewall’s IP address.

Exam tip: UDRs override system routes

Azure has built-in system routes that handle default traffic flow. When you create a UDR, it takes precedence over the matching system route. The most specific route wins — a /24 route beats a /16 route for the same destination.

If traffic suddenly stops working after adding a route table, check whether a UDR is redirecting traffic to the wrong next hop or dropping it entirely (next hop type “None”).

Troubleshooting network connectivity

Azure provides tools in Network Watcher to diagnose routing and connectivity issues:

ToolWhat It Does
IP flow verifyChecks if traffic is allowed or denied by NSG rules
Next hopShows which route table entry a packet will use
Connection troubleshootTests end-to-end connectivity between resources
Effective routesShows all routes (system + UDR) applied to a NIC
VPN troubleshootDiagnoses VPN gateway issues
Real-world: Alex debugs a routing issue

After setting up a new UDR to route traffic through Azure Firewall, Alex notices the app tier VMs can no longer reach the database tier. He uses Network Watcher’s “Effective routes” tool on the app tier NIC and discovers the UDR is sending ALL traffic to the firewall — including intra-VNet traffic.

The fix: add a more specific route for the database subnet (10.0.3.0/24) with next hop “Virtual network” to keep intra-VNet traffic direct, while the broader 0.0.0.0/0 route still sends internet traffic through the firewall.

Question

Is VNet peering transitive?

Click or press Enter to reveal answer

Answer

No. If VNet-A peers with VNet-B and VNet-B peers with VNet-C, VNet-A CANNOT communicate with VNet-C. You must create a direct peering between A and C, or route traffic through a network virtual appliance (NVA) or Azure Firewall in VNet-B.

Click to flip back

Question

What is gateway transit in VNet peering?

Click or press Enter to reveal answer

Answer

Gateway transit allows a peered VNet to use another VNet's VPN or ExpressRoute gateway. The hub VNet enables 'Allow gateway transit' and the spoke VNet enables 'Use remote gateways.' This avoids deploying a gateway in every VNet.

Click to flip back

Question

What does a UDR with next hop type 'None' do?

Click or press Enter to reveal answer

Answer

It drops the traffic completely — creating a black hole. Any packets matching this route are silently discarded. This is used to prevent certain traffic from reaching specific destinations.

Click to flip back

Question

Which Network Watcher tool shows you which route table entry a packet will use?

Click or press Enter to reveal answer

Answer

Next hop. It takes a source VM, destination IP, and tells you the next hop type and next hop IP address. This helps you verify whether UDRs are working as expected or if system routes are overriding your custom routes.

Click to flip back

Knowledge check

Knowledge Check

Meridian Financial has three VNets: VNet-A peers with VNet-B, and VNet-B peers with VNet-C. A VM in VNet-A tries to reach a VM in VNet-C but fails. What should Alex do?

Knowledge Check

CloudFirst Labs wants all internet-bound traffic from their application subnet to pass through Azure Firewall (10.0.4.4). How should they configure this?

Knowledge Check

After adding a new route table to a subnet, Alex notices VMs in that subnet can no longer reach other VMs in the same VNet. Which Network Watcher tool should he use first?