User-Defined Routes and Route Tables
30-second answer
Azure gives every subnet system routes (your VNet, peered VNets, 0.0.0.0/0 to the Internet). A route table holds user-defined routes (UDRs) that override them. You associate the route table with a subnet (one table per subnet, one table can serve many subnets), in the same region and subscription. Each route has an address prefix and a next hop type: Virtual appliance (needs the appliance's private IP), Virtual network gateway, Virtual network, Internet or None (drop). Azure picks the longest prefix match; on the same prefix a user route beats BGP and system routes. An NVA must have IP forwarding enabled on its NIC.
Simulate it » No Azure account neededExam objective: 4.1.4 Configure user-defined routes. (Skills measured as of April 17, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Search for <strong>route tables</strong>.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Search for route tables.
- Type route tables in the search bar and pick Route tables under Services.
- Create rt-spoke1 in the same region and subscription as the spoke.
- Open Settings → Routes and select + Add.
- Send spoke 2's range to the firewall's private IP. Next hop type Virtual appliance needs a next hop address.
- A route table does nothing until it's associated with a subnet. Open Subnets → + Associate.
- Pick vnet-spoke1 / snet-app. One subnet can have one route table; one table can serve many subnets.
- On the VM's NIC, Help → Effective routes proves it: the User route sends 10.2.0.0/16 to 10.0.2.4. Remember IP forwarding on the NVA's NIC and the mirror route in spoke 2.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
User-defined routes to the NVA
A route table on a subnet overrides system routes. Next hop Virtual appliance sends traffic to a firewall or NVA, which needs IP forwarding on its NIC. Longest prefix wins, and a user route beats a system route on the same prefix.
🤔 What happens if…
Read this tour as text
- VNets, subnets and a public IP. A virtual network is your private range in one region, split into subnets. Azure keeps 5 addresses in every subnet. A Standard public IP is static, zone-redundant where the region has zones, and closed to inbound traffic until an NSG opens it.
- Peering is not transitive. VNet peering joins two VNets over the Microsoft backbone. Each side has its own link, address spaces can't overlap, and the hub can share its VPN gateway (gateway transit). Peering never chains: spoke 1 and spoke 2 can't talk through the hub on their own.
- User-defined routes to the NVA. A route table on a subnet overrides system routes. Next hop Virtual appliance sends traffic to a firewall or NVA, which needs IP forwarding on its NIC. Longest prefix wins, and a user route beats a system route on the same prefix.
- NSGs, ASGs and effective rules. An NSG has rules checked by priority (100 to 4096, lowest first). Inbound traffic meets the subnet NSG first, then the NIC NSG, and both must allow. An application security group lets a rule say "to the web servers" instead of listing IPs.
- Azure Bastion. Azure Bastion lives in AzureBastionSubnet (/26 or larger) and opens RDP and SSH to VMs on their private IPs, from the portal over TLS 443 or with the native client on Standard and Premium. One Bastion in the hub serves peered spokes.
- Service endpoint vs private endpoint. A service endpoint sends a subnet's traffic to the service's public IP over the backbone, and the service firewall allows that subnet. A private endpoint gives the service a private IP in your VNet, and a privatelink private DNS zone makes the name resolve to it.
- Azure DNS: public and private zones. A public zone answers the internet once you delegate the domain to Azure's name servers. Alias records point at Azure resources such as a public IP. A private zone answers only VNets with a virtual network link, and can auto-register VM names.
- Standard load balancer and health probes. A load balancer spreads TCP/UDP flows from a frontend (public or internal) to a backend pool by load-balancing rules. A health probe pulls a VM out of rotation when it stops answering. Probes come from 168.63.129.16.
- Troubleshoot with Network Watcher. Network Watcher tools answer one question each. IP flow verify: which NSG rule allows or denies this flow? Next hop: where does this packet go? Connection troubleshoot: can A reach B, and if not, at which hop?
Contoso wants one hub VNet for shared services and two spoke VNets for apps. Build the address plan, give the hub a static public IP and a VPN gateway, peer everything, then find out the hard way that spoke 1 can't talk to spoke 2 until you route it through a firewall in the hub.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Security says every packet leaving a spoke must pass the hub firewall, and today none do.
😊 THE SOLUTION
Add a route table with next hop Virtual appliance and associate it with the spoke subnets.
- Traffic skips the firewall✓ UDR to the firewall IP
- Firewall drops forwarded packets✓ Turn on IP forwarding
- Replies take another path✓ Mirror routes on both sides
Start with a question
Why does the sat nav suddenly send you through the toll gate?
Normally it picks the shortest road. But if the council puts up a sign saying “all lorries must go through the weigh station”, every lorry takes that detour, no matter what the sat nav thinks.
Azure picks routes for every subnet on its own. A route table with user-defined routes is that council sign: “everything leaving this subnet goes through the firewall first”. You write the sign, then you hang it on the subnets it applies to.
Explain it like I’m 10
The technical explanation
System routes
Every subnet starts with routes Azure creates:
| Prefix | Next hop | Why |
|---|---|---|
| The VNet’s address space | Virtual network (VnetLocal) | Talk inside the VNet |
| Each peered VNet’s space | VNet peering | Talk over peerings |
| 0.0.0.0/0 | Internet | Outbound internet |
| 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10 | None | Drop private ranges you don’t own |
| Service tag prefixes | Virtual network service endpoint | Added when you enable a service endpoint |
A VPN or ExpressRoute gateway adds BGP routes for on-premises ranges.
Route tables and UDRs
A route table is a resource with routes in it. Each route has a name, a destination (a CIDR or a service tag such as Storage), a next hop type and, for Virtual appliance, a next hop address.
| Next hop type | Use it to |
|---|---|
| Virtual appliance | Send traffic to a firewall or NVA private IP (often Azure Firewall’s private IP) |
| Virtual network gateway | Send traffic to the VPN gateway (forced tunnelling on-premises) |
| Virtual network | Keep traffic inside the VNet, overriding a broader route |
| Internet | Send traffic straight out, for example to bypass the firewall for one range |
| None | Drop it |
You associate the table with subnets. A subnet has at most one route table; a table can serve many subnets. The table must be in the same region and subscription as the VNet. Propagate gateway routes (on by default) controls whether gateway BGP routes reach those subnets.
How Azure picks a route
- Longest prefix match: 10.2.1.0/24 beats 10.2.0.0/16 beats 0.0.0.0/0.
- Same prefix: User route, then BGP, then System. The losing system route shows as Invalid in effective routes.
Making an NVA work
- Turn on IP forwarding on the NVA’s NIC (NIC → IP configurations) and in the guest OS. Azure Firewall handles this itself.
- Add the return route on the other side, or replies skip the firewall and a stateful firewall drops them.
- On peered spokes, allow forwarded traffic on the peering so packets the hub NVA forwards are accepted.
-
1 Lookup
app1 sends to 10.2.1.4. rt-spoke1 has 10.2.0.0/16 → Virtual appliance 10.0.2.4.
-
2 Hub
The packet crosses the peering to the firewall, which has IP forwarding on.
-
3 Forward
The firewall allows it and sends it over the hub-to-spoke2 peering.
-
4 Return
rt-spoke2 sends 10.1.0.0/16 back through 10.0.2.4, so replies use the same path.
Portal and CLI
Portal: Route tables → + Create (region, name, propagate gateway routes) → Routes → + Add → Subnets → + Associate. Check the result on a VM’s NIC under Help → Effective routes.
az network route-table create -g rg-net-hub -n rt-spoke1
az network route-table route create -g rg-net-hub --route-table-name rt-spoke1 -n to-spoke2 \
--address-prefix 10.2.0.0/16 --next-hop-type VirtualAppliance --next-hop-ip-address 10.0.2.4
az network vnet subnet update -g rg-net-hub --vnet-name vnet-spoke1 -n snet-app --route-table rt-spoke1
az network nic update -g rg-net-hub -n nic-fw --ip-forwarding true
az network nic show-effective-route-table -g rg-net-hub -n nic-app1 -o table
PowerShell uses New-AzRouteTable, Add-AzRouteConfig and Set-AzVirtualNetworkSubnetConfig -RouteTable.
Architect level UDRs and Azure services
Some subnets don’t take UDRs freely. GatewaySubnet supports them but you must not send 0.0.0.0/0 to an NVA there unless you know what you’re doing, and AzureBastionSubnet doesn’t support route tables. Private endpoints ignore UDRs unless you turn on network policies for private endpoints on that subnet. When you use Azure Firewall, the firewall subnet needs its own 0.0.0.0/0 to the Internet.
Real-world business scenario
Woodgrove Bank (fictional)
- The problem
- Auditors found that VMs in the loan app spoke could reach the internet directly, bypassing the bank's firewall, and nobody could prove what left the network.
- What they used
- Azure Firewall in the hub at 10.0.2.4. A route table on every spoke subnet with 0.0.0.0/0 and the other spokes' ranges pointing to next hop Virtual appliance 10.0.2.4, and mirror routes on every spoke.
- Why that choice
- Every outbound and spoke-to-spoke packet now passes one firewall that logs it, and effective routes prove the path for the auditors.
- The result
- The audit finding closed, and the firewall logs caught an outdated library calling home within the first week.
When to use it and when not to
✓ Use it when…
- Forcing internet or spoke-to-spoke traffic through Azure Firewall or another NVA.
- Sending on-premises-bound traffic through the VPN gateway (forced tunnelling).
- Dropping traffic to ranges a subnet should never reach (next hop None).
✕ Think twice when…
- Blocking ports. That's an NSG job, not a routing job.
- Route tables on AzureBastionSubnet, which doesn't support them.
- One-way routes through a stateful firewall without the return route.
↔ Alternatives to consider
- NSGs to allow or deny traffic without changing its path.
- Azure Virtual WAN with routing intent to steer traffic through a secured hub.
- Azure Route Server to exchange routes with NVAs over BGP instead of static UDRs.
Test yourself with exercises
5 original practice questions in the AZ-104 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What's the difference between a system route and a user-defined route?
Model answer
Azure creates system routes automatically so a subnet can reach its VNet, peered VNets and the internet. A user-defined route is one I add in a route table to change that, for example sending all internet traffic to a firewall.
Intermediate Two routes match a packet, 10.0.0.0/8 and 10.2.0.0/16. Which one wins?
Model answer
The longest prefix, so 10.2.0.0/16. Only if two routes have exactly the same prefix does the source matter, and then a user-defined route wins over a BGP route, which wins over a system route.
Experienced developer You added 0.0.0.0/0 to a firewall but some subnets lost their VPN routes. Why?
Model answer
Probably the route table has propagate gateway routes turned off, so routes learned from the VPN gateway over BGP don't reach those subnets. Either turn propagation back on, or add explicit routes for the on-premises ranges with next hop virtual network gateway or the firewall.
Scenario Spoke traffic should pass through a firewall at 10.0.2.4 in the hub. Routes are in place, but packets disappear at the firewall. What do you check?
Model answer
IP forwarding on the firewall VM's NIC in Azure, and forwarding inside its operating system. Then the return path: the other spoke needs a route back through the same firewall, otherwise replies take a different path and the firewall drops them as asymmetric. And allow forwarded traffic on the spoke peerings.
Quick revision
Key points
- Route tables attach to subnets, not NICs. One per subnet, many subnets per table.
- Same region and subscription as the VNet.
- Next hop types - Virtual appliance (with IP), Virtual network gateway, Virtual network, Internet, None.
- Longest prefix wins; on a tie, User > BGP > System.
- NVAs need IP forwarding on the Azure NIC and in the OS.
Important terminology
- System route
- A route Azure creates for you, such as VnetLocal for the VNet's range, VNetPeering for peered ranges and Internet for 0.0.0.0/0.
- Route table
- An Azure resource holding user-defined routes, associated with one or more subnets in the same region and subscription.
- User-defined route (UDR)
- A route you add to a route table to override system routes for an address prefix.
- Next hop type Virtual appliance
- Sends matching traffic to the private IP of a firewall or network virtual appliance.
- IP forwarding
- A NIC setting that lets a VM receive and forward packets not addressed to it. Required on NVAs.
- Propagate gateway routes
- A route table setting. When off, routes learned by a VPN or ExpressRoute gateway over BGP aren't added to the subnet.
Common mistakes
- Creating a route table and never associating it with a subnet.
- Forgetting the return route on the other side, which breaks stateful firewalls.
- Using Virtual appliance without a next hop IP address.
Exam tips
- "Force internet traffic through a firewall" = 0.0.0.0/0 → Virtual appliance + firewall IP, associated with the subnet.
- "Drop traffic to a range" = next hop None.
- "Where does the packet go?" = Next hop or Effective routes on the NIC.
Five quick revision questions
-
1.What do you associate a route table with?Show
One or more subnets.
-
2.Which next hop type needs an IP address?Show
Virtual appliance.
-
3.Which route wins, 10.0.0.0/16 or 10.0.1.0/24, for 10.0.1.5?Show
10.0.1.0/24, the longest prefix.
-
4.What must be enabled on an NVA's NIC?Show
IP forwarding.
-
5.Where do you see all routes that apply to a VM?Show
Effective routes on its network interface.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: NSGs, Application Security Groups and Effective Rules
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.