Let’s Get Certified
Module 04 / 17 · Core networking infrastructure

Trace a packet through peering and routes

Read the effective next hop, account for return traffic and distinguish routing from outbound translation.

Trace a packet through peering and routes

Work through the decision

Two spokes are separately peered to a hub. A team assumes that this makes the spokes mutually reachable through the hub. It also has a route to an inspection appliance on the wrong subnet. How would you test the design?

Check your reasoning

Peering connects its two endpoints and is nontransitive. Identify the source NIC and inspect its effective routes for the destination. For a routed inspection design, associate the intended route table with the workload subnet, permit the required forwarded traffic and verify appliance forwarding. Follow the return decision separately. A route on the appliance subnet alone cannot tell the source which next hop to use.

Watch the source lesson at 25:26

Compare the choices

User-defined route
Use a subnet-associated route table to direct matching destinations to an appropriate next hop. Verify effective routes on a source NIC and inspect return routing.
Gateway transit
Advertise the hub gateway to a peered spoke and configure that spoke to use the remote gateway. Verify the supported topology and effective routes.
Azure Route Server
Use BGP to exchange routes between supported virtual appliances and Azure’s routing infrastructure. The route server participates in the control plane.
Azure NAT Gateway
Associate the NAT gateway with source subnets and public IP capacity to provide explicit outbound translation for supported traffic. Track SNAT use and available ports.

Test the decision

Gateway transit lets a spoke use a hub gateway with complementary peering settings. Azure Route Server exchanges BGP routes with compatible virtual appliances. NAT Gateway supplies outbound SNAT for an associated subnet when applicable. It does not create spoke-to-spoke transit.

Verify the chosen next hop in Azure

Open the source VM’s network interface and its effective routes. Record the destination prefix, route source, state and next hop. In Network Watcher, test the next hop for the same source and destination IP. An appliance next hop still needs forwarding, a suitable security policy and a working reverse path. Repeat from the destination side before changing any route.

Microsoft Learn · Azure route selection

Practice the guide skills

  1. Draw the two peering directions and mark where forwarded traffic, gateway transit and remote gateway use are required. Watch 25:26 · Continue at 25:46
  2. Check both peering states and address spaces before testing a cross-VNet private IP. Watch 24:43 · Continue at 25:31
  3. Create a proposed network group, connectivity configuration and regional deployment scope for three spokes. Watch 26:44 · Continue at 28:10
  4. Compare two matching route prefixes and state the next hop selected for a sample destination. Watch 30:47
  5. Trace the source NIC to its subnet and the subnet’s route table association. Watch 31:22
  6. Identify the default route that would direct eligible internet-bound traffic through the branch and plan the return path. Watch 31:46
  7. Compare the NIC’s effective routes with Network Watcher’s next hop result for one address. Watch 32:58
  8. Sketch the BGP sessions between a network appliance and Route Server and record an expected advertised prefix. Watch 34:26
  9. Decide which workload subnets require a predictable outbound IP and which paths would bypass NAT Gateway. Watch 14:54
  10. Estimate concurrent outbound connections, plan public IP capacity and list each subnet association. Watch 15:00 · Continue at 15:46

Official objectives for this lesson

Lab · Predict the effective next hop

Use Python 3 to compare candidate routes from a workload subnet to a depot. Predict each result before running the script. The example uses ordinary unicast prefixes and supplied route states. Azure also has platform-preferred routes, including service endpoint routes, outside this exercise.

from ipaddress import ip_address, ip_network

# Prefix, source, next hop, available
routes = [
    ("0.0.0.0/0", "system", "Internet", True),
    ("10.40.0.0/16", "BGP", "branch gateway", True),
    ("10.40.0.0/16", "user", "hub appliance", True),
    ("10.40.8.0/24", "BGP", "branch gateway", True),
    ("10.40.8.64/26", "user", "retired appliance", False),
]
preference = {"system": 0, "BGP": 1, "user": 2}

def next_hop(destination, candidates):
    address = ip_address(destination)
    matches = []
    for prefix, source, hop, available in candidates:
        network = ip_network(prefix)
        if available and address in network:
            matches.append((network.prefixlen, preference[source], hop))
    return max(matches)[2] if matches else "no matching route"

for destination in ["10.40.7.7", "10.40.8.90", "203.0.113.8"]:
    print(destination, next_hop(destination, routes))

without_user = [route for route in routes if route[1] != "user"]
print("without user routes:", next_hop("10.40.7.7", without_user))
Check the result
10.40.7.7 hub appliance
10.40.8.90 branch gateway
203.0.113.8 Internet
without user routes: branch gateway

An equal-length user route wins for 10.40.7.7. The longer available /24 wins for 10.40.8.90. The inactive /26 cannot carry traffic. In Azure, compare the effective routes and next hop on the source NIC, then check the return path separately. Change the /24 availability to False and predict the second line.

Related lesson · Select the longest matching route

Knowledge check

Trace a packet through peering and routes quiz

Answer 3 questions. Check each answer for an explanation.

Worked example · Trace a packet through peering and routes