How Routers Forward Packets: Understanding Routing Tables, Static & Default Routes
This article explains how routers forward packets by consulting routing tables, describes the formation of routing entries, compares static and default routes, and provides practical configuration commands for common networking devices.
1. Router Working Principle
1.1 How a Router Works
Routing is the forwarding process from a source host to a destination host. A router forwards packets to the correct destination and selects the optimal path.
A routing table is a collection of routing entries (IP network + outgoing interface) maintained by the router, which it uses for path selection.
When a host needs to send a packet to a different subnet, it forwards the packet to its gateway router.
(1) Host 1.1 wants to send a packet to host 4.1. Because the destination IP is not in the same subnet, the host sends the packet to its local gateway router A.
(2) Router A receives the packet, checks the destination IP in the packet header, looks up its routing table, finds that the 4.0 network is reachable via interface S0, and forwards the packet out of S0.
(3) Each router repeats this process until the packet reaches router B, which forwards it out of interface E0 to host 4.1. If a router cannot find a matching entry, it either forwards the packet to a default interface or returns an unreachable message.
2. Formation of Routing Tables
Directly connected networks: when an IP address is configured and the interface is up, the router automatically creates a direct route without manual configuration.
Non‑direct networks: require static routes or dynamic routing protocols to add the network to the routing table.
3. Static Routes and Default Routes
3.1 Static Route
Configured manually by an administrator; one‑way and lacks flexibility.
3.2 Default Route
When the routing table has no entry for the destination network, the router forwards the packet to a default interface (the sole exit). A default route is a special kind of static route.
3.3 Packet Encapsulation Process
Switches use a MAC address cache; if no entry exists, they flood or broadcast. Routers use a routing table; if no entry exists, they drop the packet.
During encapsulation, the IP address remains unchanged while the MAC address changes at each hop.
Example: Host A (source IP 192.168.1.2, source MAC 11‑11) sends to Host B (dest IP 192.168.2.2, dest MAC 22‑22). ARP broadcast resolves the gateway MAC, the first encapsulation occurs, the router checks the routing table, forwards out the appropriate interface, ARP resolves the next hop MAC, and the process repeats until the destination receives the packet.
4. Configuring Static and Default Routes
View routing table: dis ip routing-table Default route command (any network): ip route-static 0.0.0.0 0.0.0.0 192.168.12.1 Static route command: ip route-static 192.168.10.0 255.255.255.0 192.168.12.1 Static route blackhole (special use case): ip route-static 10.1.0.0 NULL 0 Summary
Routers forward packets by consulting routing tables.
Routing tables are built via static entries or dynamic learning.
A default route is a special static route used when no specific entry matches.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
