Understanding Linux Routing Tables

Sep 11, 2024

Module 19: Creating a Routing Table on a Linux Computer

Introduction

  • Presented by Jeff Messier, Professor of Electrical and Computer Engineering
  • Focus on creating Linux routing tables by hand
  • Importance of understanding routing in network management

Previous Modules Recap

  • General concept of routing tables discussed
  • Explained IP addresses, hierarchy (Network ID + Host ID)
  • Simple routing example based on Network ID

Purpose of this Module

  • Hands-on exercise of configuring routing tables in Linux
  • Useful for small network administration
  • Provides a foundation for more complex routing algorithms in future lectures

Components of a Linux IP Routing Table

  1. Own IP Address: Must know the IP address of the device itself
  2. Directly Connected Machines: Addresses of machines on the same network
  3. Default Next-hop Router Address: A fallback for unrecognized packet addresses
  4. Routing Table Structure:
    • Destination: IP address to compare with
    • Next Hop: Address to send the packet if matched
    • Flags: Operating system flags (H for host, G for gateway)
    • Network Interface: Link used to send the packet

Network Diagram Notation

  • LANs can be represented by bars instead of switches for simplicity
  • Computers represented by H (hosts) and R (routers)
  • IP addresses assigned based on physical connections and CIDR notation

Example: Building Routing Tables

Network Setup

  • Various hosts (H) and routers (R) connected in a specific configuration
  • Each device has its own IP address, network interface (ETH0, ETH1, etc.)

Routing Table Entries

  • Step-by-step packet flow: Trace imaginary packets through the network
  • Routing table design: Each routing table entry corresponds to the next hop for that packet

Packet Flow Example 1: H30 to G

  1. Packet generated for H30 arrives at G.
  2. G checks its routing table:
    • Matches the destination (network ID) and sends to Router 1.
  3. Router 1 forwards to Router 2 based on its routing table.
  4. Router 2 delivers the packet to H30 directly.

Packet Flow Example 2: H30 to Web Server

  1. H30 sends a packet to University of Calgary's web server.
  2. H30 checks its routing table for a local transmission entry, fails to match.
  3. H30 uses the default entry to send the packet to G.
  4. G routes the packet to R1, and then R1 checks its routing table, ultimately sending it to G for internet access.

Key Points on Routing Table Entries

  • Each entry is only responsible for the next hop; does not include the entire path.
  • Default entries serve as a last resort for unmatched packets.
  • Local transmission entries are essential for direct communication with devices on the same subnet.
  • Understanding bitwise AND operations is crucial for matching destination fields in routing tables.

Conclusion

  • Methodical approach to understanding network routing.
  • Each example demonstrates creating routing tables based on the traced paths.
  • Emphasizes the importance of knowing routing table configurations in network management.