100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

What is a Router Routing Table?

Learn what a routing table is, how longest-prefix match works, and how routes are learned — with networking interview Q&A.

mediumQ163 of 224 in Computer Networks Est. time: 6 minsLast updated:
Open Code Lab

Expected Interview Answer

A routing table is the data structure a router consults for every packet it forwards, listing known destination networks alongside the next-hop address and outgoing interface to use, so the router can decide where to send a packet based on the longest matching prefix for its destination IP.

Each entry in a routing table typically includes a destination network (e.g., 10.0.0.0/24), a next-hop IP address (or a directly connected interface), an outgoing interface, and metrics like administrative distance and cost that determine which route wins when multiple sources offer a route to the same destination. When a packet arrives, the router performs a longest-prefix match against the table — the most specific matching route wins over a broader, less specific one — and forwards the packet out the associated interface toward that next hop. Routes can be added manually (static routes), learned automatically from a directly connected network, or learned dynamically through routing protocols like OSPF, BGP, or EIGRP, which exchange reachability information between routers. If no matching route exists and there is no default route (0.0.0.0/0), the router drops the packet and typically returns an ICMP destination unreachable message.

  • Enables per-packet forwarding decisions based on destination IP
  • Longest-prefix match ensures the most specific route is preferred
  • Combines static, connected, and dynamically learned routes
  • A default route provides a catch-all path for unmatched destinations

AI Mentor Explanation

A routing table is like a fielding captain’s mental chart of which fielder covers which zone of the ground — when the ball is hit to a specific spot, the captain checks the chart for the most specific zone assignment rather than a vague 'somewhere on the boundary' entry. If the ball lands in a precisely covered zone, that fielder chases it; only if no specific zone matches does the general backup fielder (the default route) chase it down. Updating the chart as fielders rotate positions is exactly how a router updates its table as network paths change.

Step-by-Step Explanation

  1. Step 1

    Populate the table

    Routes come from directly connected networks, manually configured static routes, and dynamic routing protocols.

  2. Step 2

    Packet arrives

    The router examines the destination IP address of each incoming packet.

  3. Step 3

    Longest-prefix match

    The router selects the most specific matching route entry among all candidates.

  4. Step 4

    Forward or drop

    The packet is sent out the matched next-hop/interface, or dropped (with ICMP unreachable) if no route matches.

What Interviewer Expects

  • Explains what a routing table entry contains (destination, next hop, interface)
  • Correctly describes longest-prefix match
  • Distinguishes static, connected, and dynamically learned routes
  • Knows the role of a default route (0.0.0.0/0)

Common Mistakes

  • Thinking the router picks the first matching route rather than the most specific
  • Confusing a routing table with a switch's MAC address table
  • Not knowing what happens when no route matches (drop + ICMP unreachable)
  • Forgetting administrative distance decides between routes from different sources

Best Answer (HR Friendly)

A routing table is a router’s map of the network — for every packet, it looks up the destination address in that map and picks the most specific matching entry to decide which direction to send it. Entries can be added manually, learned from directly connected networks, or discovered automatically by routing protocols, and if nothing matches, the router falls back to a general default route or drops the packet.

Code Example

Viewing and understanding a routing table
# Show the kernel IP routing table on a Linux host
ip route show

# Example output:
# default via 192.168.1.1 dev eth0
# 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.20
# 10.0.5.0/24 via 192.168.1.1 dev eth0

# Test which route a specific destination will use (longest-prefix match)
ip route get 10.0.5.42
# 10.0.5.42 via 192.168.1.1 dev eth0 src 192.168.1.20

Follow-up Questions

  • What is the difference between administrative distance and metric?
  • How does longest-prefix match resolve overlapping routes?
  • What is the difference between a static route and one learned via OSPF or BGP?
  • What happens when a router receives a packet with no matching route and no default?

MCQ Practice

1. When multiple routes could match a packet's destination, which one does a router prefer?

Routers use longest-prefix match, always preferring the most specific matching route over a broader one.

2. What does the default route (0.0.0.0/0) represent?

The default route is used as a fallback path when no other entry in the routing table matches the destination.

3. Which of these is NOT a typical source of routing table entries?

DNS zone transfers relate to name resolution, not routing; routes come from connected interfaces, static config, and routing protocols.

Flash Cards

What does a routing table entry contain?A destination network, next-hop address, outgoing interface, and route metrics.

What is longest-prefix match?The router prefers the most specific matching route among all candidates.

What are the three main route sources?Directly connected networks, static routes, and dynamic routing protocols.

What happens with no matching route and no default?The router drops the packet and typically sends an ICMP destination unreachable.

1 / 4

Continue Learning