Skip to content

The Next Hop

Time: 45 min

Needs: two OL9 Routers, two OL9 PCs, two Ethernet switches

GNS3 project: w04-next-hop

Info

Times listed are approximate and provided as timing guidelines only. Take as much time as you need to complete the activity.

Question

Where should a host deliver a packet whose destination it cannot directly reach?


Build it

  LAN1 192.168.100.0/24      transit 10.0.0.0/30      LAN2 192.168.200.0/24

  PC1 ─── SW1 ─── R1 ═══════════════════════════ R2 ─── SW2 ─── PC2
  .10             .1  10.0.0.1         10.0.0.2  .1             .10
  • Cable R1:eth1 to R2:eth1, so that you know which addresses to assign to which interfaces later
  • Log on to each node and assign the addresses as shown on the diagram. Ensure PC1 and PC2 have default routes configured (see previous activity for a reminder)
  • You could make R1 and R2 each other's default routes, but this approach does not scale if you later decide to attach more networks.
  • Instead (the following assumes eth1 is connection name associated with the addresses 10.0.0.1 (R1) and 10.0.0.2 (R2). Assign the addresses first before proceeding):

On R1:

nmcli con mod eth1 +ipv4.routes "192.168.200.0/24 10.0.0.2"
nmcli con up eth1

echo "net.ipv4.ip_forward = 1" | tee -a /etc/sysctl.d/99-ipv4-forwarding.conf

sysctl --system

On R2:

nmcli con mod eth1 +ipv4.routes "192.168.100.0/24 10.0.0.1"
nmcli con up eth1

echo "net.ipv4.ip_forward = 1" | tee -a /etc/sysctl.d/99-ipv4-forwarding.conf

sysctl --system

Verify that PC1 can ping PC2

What just happened

  • nmcli con mod eth1 +ipv4.routes add a route to the routing table. Notice the + sign; you don't want to replace any existing routes, so you append instead.
  • A route is in the form destination next_hop where:
    • destination is an subnet ID
    • next hop is the address of the next router on the path to destination (not necessarily the last router)
    • R2's address used as next hop is on the same link as R1's interface on which the route is configured, and vice versa.
  • Using NetworkManager ensures routing configuration survives reboots
  • We also make IP Forwarding persistent by saving the setting to a file

Do this — What changes at each hop

Collect the addresses first

# on each of PC1, R1, R2, PC2
ip addr show
ip link show
Node Interface IP MAC
PC1 eth0 192.168.100.10
R1 eth0 192.168.100.1
R1 eth1 10.0.0.1
R2 eth1 10.0.0.2
R2 eth0 192.168.200.1
PC2 eth0 192.168.200.10
  • Start captures on PC1 - SW1, R1 - R2, and PC2 - SW2 cables
  • Ping PC2 from PC1. Fill the following table using information from the echo request, on each of the three links:
Src MAC Dst MAC Src IP Dst IP TTL Checksum changed
PC1 ↔ SW1
R1 ↔ R2
PC2 ↔ SW2

What just happened

  • The two IP addresses are identical on all three links. Source 192.168.100.10, destination 192.168.200.10, from end to end.
  • Both MAC addresses are different on every link. Each hop discards the old frame and puts the payload into a new frames and sends it to the next hop.
  • TTL grows smaller at each hop. Routers have the obligation to decrement it and drop the packet if it reaches 0. This guarantees that no packet can live forever on the internet.
  • The checksum must be recomputed at each hop because the TTL changes. Depending on which other options are used, other parts of the header may be modified as well, so the checksum will always be recomputed.

Do this — use options

Ensure the captures from the previous section are still running.

# on PC1
ping -c1 192.168.200.10
ping -c1 -R 192.168.200.10

Capture it. Find the IHL field in the IP header of both the request and the reply.

Ordinary ping With -R
IHL value
Header length in bytes
Addresses listed in the option —

What just happened

  • We used the Record Route option, which asks the network to describe its own path.
  • Using options grows the header. The IHL fields tracks the size
  • Up to 15 32-bit words can be used for options, which works out to 40 bytes
  • With that, Record Route has enough space to record not more than 9 addresses (not nearly enough for today's internet)!
  • Options have seen poor adoption, and routers generally ignore them.

Record

Maximum IPv4 header size, and why
Bytes available for options
Maximum # of addresses Record Route can hold

If it went wrong

Symptom Cause Fix
PC1->PC2 ping fails with Network Unreachable PC1 has no default gateway nmcli con mod eth0 ipv4.gateway 192.168.100.1
PC1 -> PC2 ping fails with Destination net unreachable R1 has no route to LAN2 nmcli con mod eth0 +ipv4.routes "192.168.200.0/24 10.0.0.2"
PC1 -> PC2 ping times out IP forwarding not enabled or no return route check IP forwarding and the routing tables on both routers