Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 34 of 47
❮Prev Next❯

User-Defined Routes and Route Tables

Module 4: Networking ⏱ 10 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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 needed

    Exam 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.

    Azure portal: Send spoke traffic through the hub firewall with a route table Create a route table, add a route and associate it with a subnet.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Search for <strong>route tables</strong>.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Search for route tables.
    2. Type route tables in the search bar and pick Route tables under Services.
    3. Create rt-spoke1 in the same region and subscription as the spoke.
    4. Open Settings → Routes and select + Add.
    5. Send spoke 2's range to the firewall's private IP. Next hop type Virtual appliance needs a next hop address.
    6. A route table does nothing until it's associated with a subnet. Open Subnets → + Associate.
    7. Pick vnet-spoke1 / snet-app. One subnet can have one route table; one table can serve many subnets.
    8. 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.

    😟 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
    🛠️ Solved with: User-defined routes

    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:

    PrefixNext hopWhy
    The VNet’s address spaceVirtual network (VnetLocal)Talk inside the VNet
    Each peered VNet’s spaceVNet peeringTalk over peerings
    0.0.0.0/0InternetOutbound internet
    10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10NoneDrop private ranges you don’t own
    Service tag prefixesVirtual network service endpointAdded 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 typeUse it to
    Virtual applianceSend traffic to a firewall or NVA private IP (often Azure Firewall’s private IP)
    Virtual network gatewaySend traffic to the VPN gateway (forced tunnelling on-premises)
    Virtual networkKeep traffic inside the VNet, overriding a broader route
    InternetSend traffic straight out, for example to bypass the firewall for one range
    NoneDrop 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

    1. Longest prefix match: 10.2.1.0/24 beats 10.2.0.0/16 beats 0.0.0.0/0.
    2. 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. 1 Lookup

      app1 sends to 10.2.1.4. rt-spoke1 has 10.2.0.0/16 → Virtual appliance 10.0.2.4.

    2. 2 Hub

      The packet crosses the peering to the firewall, which has IP forwarding on.

    3. 3 Forward

      The firewall allows it and sends it over the hub-to-spoke2 peering.

    4. 4 Return

      rt-spoke2 sends 10.1.0.0/16 back through 10.0.2.4, so replies use the same path.

    Spoke 1 to spoke 2 through the hub firewall

    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

    Banking

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    You must ensure that all internet-bound traffic from Subnet1 passes through a firewall appliance that has the private IP address 10.0.2.4. What should you create and associate with Subnet1?

    Question 2

    Question 2 of 5

    A subnet has the following effective routes: 10.0.0.0/8 next hop None, 10.2.0.0/16 next hop Virtual appliance 10.0.2.4, and 0.0.0.0/0 next hop Internet. Where is a packet to 10.2.5.9 sent?

    Question 3

    Question 3 of 5

    You create a route table that contains a route to a network virtual appliance (NVA). Traffic from the subnet reaches the NVA, but the NVA does not forward it. What should you configure?

    Question 4

    Question 4 of 5 · Select 2

    Which two statements about route tables are true? Each correct answer presents a complete solution.

    Question 5

    Question 5 of 5

    Subnet1 must not be able to send any traffic to the address range 172.16.50.0/24. You must use routing to meet the requirement. Which next hop type should you use in the user-defined route?

    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. 1.What do you associate a route table with?Show

      One or more subnets.

    2. 2.Which next hop type needs an IP address?Show

      Virtual appliance.

    3. 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. 4.What must be enabled on an NVA's NIC?Show

      IP forwarding.

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.