Peering and routing
Connect VNets with peering, design hub and spoke, steer traffic with user-defined routes, and troubleshoot where packets go.
In this lesson you'll learn
- How peering works and why it is not transitive
- Gateway transit for hub and spoke designs
- System routes, user-defined routes and longest prefix match
- How to troubleshoot routing with Next hop and effective routes
1. VNet peering
New to peering? Start here
By default, two VNets are isolated, like two separate buildings. Peering builds a private corridor between them. Traffic stays on the Microsoft backbone, never touches the internet, and VMs talk using private IPs as if they were on one network.
- Regional peering connects VNets in the same region. Global peering connects VNets in different regions.
- Peering is created as a pair of links, one from each side. Both must show Connected.
- Address spaces must not overlap. See the subnetting lesson.
- Peerings work across subscriptions and even across Entra tenants.
2. Peering is not transitive
3. Hub and spoke with gateway transit
Large organisations put shared services (VPN gateway, firewall, Bastion) in a central hub VNet. Workload VNets, the spokes, peer only with the hub.
| Peering setting | Set on | Meaning |
|---|---|---|
| Allow gateway transit | Hub side | Lets peers use this VNet's VPN or ExpressRoute gateway |
| Use remote gateways | Spoke side | Sends this VNet's on-premises traffic through the peer's gateway. The spoke must not have its own gateway. |
| Allow forwarded traffic | Side receiving forwarded packets | Accepts traffic that did not originate in the peer, for example traffic passing through an NVA |
Exam focus
Remember the pairing: the hub allows transit and the spoke uses remote gateways. If a question swaps them, it is wrong. After changing peering topology, point-to-site VPN clients must download and reinstall the client package to learn the new routes.
Hybrid connections at a glance
Site-to-site VPN connects an office network to Azure over an encrypted tunnel on the internet. Point-to-site VPN connects individual laptops. ExpressRoute is a private circuit through a provider that never touches the internet. Gateways always live in a subnet named GatewaySubnet.
4. How Azure routes traffic
Every subnet gets system routes automatically: traffic within the VNet stays local, peered VNet ranges go over the peering, and 0.0.0.0/0 goes to the internet. You override them with a route table of user-defined routes (UDRs) associated with a subnet.
| Next hop type | Sends traffic to |
|---|---|
| Virtual appliance | An NVA or Azure Firewall private IP (needs IP forwarding on the NVA's NIC) |
| Virtual network gateway | A VPN gateway |
| Virtual network | Stays inside the VNet |
| Internet | Out to the internet |
| None | Drops the traffic |
Example
SS Kaiser's auditors require every outbound connection to be logged. The team deploys Azure Firewall in the hub. They add a UDR for 0.0.0.0/0 with next hop "Virtual appliance" pointing at the firewall's private IP, and associate that route table with every spoke subnet.
5. Troubleshooting routing
- Network Watcher Next hop: enter a source VM and destination IP to see the next hop type and which route table was used.
- Effective routes on a NIC: shows every route applied, from all sources, after combining them.
- Check the peering status on both sides. It must be Connected, not Initiated.
- If traffic goes through an NVA, confirm IP forwarding is enabled on its NIC.
Exam traps to remember
- Peering is non-transitive, whether regional or global.
- Overlapping address spaces block peering completely.
- A route table is associated with subnets, not with VMs or NICs.
- A UDR to an NVA fails silently if IP forwarding is not enabled on the NVA's NIC.
Test yourself: 3 check questions and exam-style practice questions on this topic are in the AZ-104 Azure Administrator app.
Practise in the app