Router

On this page 7

A router is a network device that forwards IP packets between separate networks, choosing the next hop for each packet by comparing its destination address with the entries in a routing table. In networking, the router operates at Layer 3 of the OSI model, the network layer, and it is the device that connects one subnet, site or provider to another.

Where a switch delivers frames inside a single local network, a router joins different IP networks and decides the path between them. Routing in this sense ranges from a home gateway with one default route to provider core routers that hold the full Internet table with roughly one million IPv4 prefixes.

How a router forwards a packet

A router handles each packet independently, in a sequence that repeats millions of times per second on large platforms. It removes the incoming Layer 2 header, makes its decision on the IP header alone and then builds a new Layer 2 header for the outgoing link.

  1. Receive the frame and verify its checksum, then extract the IP packet.
  2. Look up the destination address in the forwarding table using longest prefix match.
  3. Decrement the IPv4 TTL or IPv6 hop limit; if it reaches zero, drop the packet and send an ICMP Time Exceeded message.
  4. Recalculate the IPv4 header checksum (IPv6 has none).
  5. Resolve the next hop’s MAC address through ARP or IPv6 neighbor discovery.
  6. Queue the packet on the outgoing interface and transmit it in a new frame.

The longest prefix match rule means that the most specific matching route always wins, regardless of the order of entries. The table shows which route a router selects for several destinations when it holds four routes.

Destination addressMatching routesSelected route
10.1.2.710.0.0.0/8, 10.1.0.0/16, 10.1.2.0/24, 0.0.0.0/010.1.2.0/24
10.1.9.910.0.0.0/8, 10.1.0.0/16, 0.0.0.0/010.1.0.0/16
10.200.1.110.0.0.0/8, 0.0.0.0/010.0.0.0/8
8.8.8.80.0.0.0/0 only0.0.0.0/0 (default route)
Longest prefix match with four routes

Control plane and data plane

A router is internally divided into a control plane, which builds the routing table, and a data plane, which forwards packets using that table. The control plane runs routing protocols such as OSPF and BGP, holds every learned route in the routing information base (RIB) and installs the best ones into the forwarding information base (FIB).

On enterprise and carrier hardware, the FIB lives in specialized ASICs or network processors, so forwarding continues at line rate even while the control-plane CPU recalculates routes. A third part, the management plane, carries SSH, SNMP and configuration traffic and is usually protected separately.

When several sources offer a route to the same prefix, the router first compares administrative distance, a trust value for the source; lower is preferred. Only routes from the same source are then compared by their protocol metric. The values below are common defaults on many platforms, and some vendors use different numbers.

Route sourceAdministrative distanceTypical use
Directly connected0Subnets configured on the router’s own interfaces
Static route1Manually defined paths and default routes
External BGP20Routes learned from another autonomous system
OSPF110Interior routing inside an organization
IS-IS115Interior routing in large provider networks
RIP120Legacy small networks
Internal BGP200Routes shared inside one autonomous system
Typical default administrative distances

The word router covers devices with very different roles, and the boundaries with switches and firewalls are often blurred. The decisive trait of a router is forwarding between IP subnets based on Layer 3 addresses.

DeviceForwarding decisionMain strengthTypical location
RouterIP prefix, Layer 3WAN links, routing protocols, rich policiesNetwork edge, branch, provider core
Layer 2 switchMAC address, Layer 2Many ports at low cost per portAccess layer, inside one subnet
Layer 3 switchIP prefix in hardwareHigh-speed routing between internal VLANsCampus and data center core
FirewallSecurity policy and session stateTraffic inspection and filteringPerimeter between trust zones
Home gatewayDefault route plus NATRouter, switch, Wi-Fi and DHCP in one boxHomes and small offices
Router and neighboring network devices

The consumer device usually called a router is really a combination appliance. It routes between the home network and the provider, translates private addresses with NAT, hands out addresses with DHCP and acts as a switch and Wi-Fi access point. NAT is a separate function: a router does not have to translate addresses in order to route.

Types of routers and how they are sized

Routers are sized by packet forwarding rate, interface types and table capacity, not by link speed alone. Small packets are the hardest load: a 10 Gbit/s link filled with minimum-size 64-byte frames carries about 14.88 million packets per second, because each frame occupies 84 byte times including preamble and interframe gap.

CategoryTypical routes heldTypical protocolsKey requirement
Home and small officeA few connected and one default routeStatic, DHCP client, NATSimplicity and integrated services
Branch and enterprise edgeHundreds to thousandsStatic, OSPF, BGP, IPsec VPNWAN redundancy and security features
Provider edgeFull Internet table plus customer routesBGP, MPLS, IS-ISLarge FIB and per-customer policy
Core routerInternal infrastructure routesIS-IS or OSPF, MPLSHighest throughput and fast convergence
Virtual routerVaries widelySame software features as hardwareFlexible deployment in clouds
Router categories by role

Limitations and common mistakes

A router separates broadcast domains: it does not forward broadcasts such as ARP requests, which is why devices on different subnets cannot discover each other without help. Applications that rely on broadcasts, such as DHCP, need a relay agent configured on the router.

  • Missing return routes: a packet reaches its destination, but the reply has no path back, so the connection fails in one direction only.
  • Routing loops: two routers point to each other for the same prefix; the TTL eventually ends the loop, but traffic is lost.
  • Asymmetric paths through stateful firewalls: outbound and return traffic take different routers and the firewall drops the unexpected return packets.
  • MTU problems: IPv6 routers never fragment packets, so blocked ICMP messages can break path MTU discovery and stall large transfers.

The simple explanation

A router is like a sorting center between postal regions. A letter arrives, the sorter looks only at the destination postcode and sends the letter to the next center that is closer to the target.

The router keeps a list of known destinations and which neighbor to use for each. When several entries fit, it chooses the most specific one. The main idea is that a router connects separate networks and picks the next step for every packet, while switches handle delivery inside one network.

How it is used in practice

A regional retail chain runs a branch router in each of its forty stores. Every router has two Internet connections: a fiber line as the primary path and an LTE link as the backup. The primary default route is a static route with administrative distance 1, and the backup is a floating static route with distance 250, which enters the table only when the fiber interface goes down.

The routers build IPsec tunnels to the headquarters and run OSPF across them, so store networks learn the routes to the payment and inventory servers automatically. When construction work cuts the fiber at one store, the default route moves to LTE within seconds and the tills keep processing card payments. The outage remains invisible to customers, and the network team sees it only as an alert from monitoring.