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.
- Receive the frame and verify its checksum, then extract the IP packet.
- Look up the destination address in the forwarding table using longest prefix match.
- Decrement the IPv4 TTL or IPv6 hop limit; if it reaches zero, drop the packet and send an ICMP Time Exceeded message.
- Recalculate the IPv4 header checksum (IPv6 has none).
- Resolve the next hop’s MAC address through ARP or IPv6 neighbor discovery.
- 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 address | Matching routes | Selected route |
|---|---|---|
| 10.1.2.7 | 10.0.0.0/8, 10.1.0.0/16, 10.1.2.0/24, 0.0.0.0/0 | 10.1.2.0/24 |
| 10.1.9.9 | 10.0.0.0/8, 10.1.0.0/16, 0.0.0.0/0 | 10.1.0.0/16 |
| 10.200.1.1 | 10.0.0.0/8, 0.0.0.0/0 | 10.0.0.0/8 |
| 8.8.8.8 | 0.0.0.0/0 only | 0.0.0.0/0 (default route) |
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 source | Administrative distance | Typical use |
|---|---|---|
| Directly connected | 0 | Subnets configured on the router’s own interfaces |
| Static route | 1 | Manually defined paths and default routes |
| External BGP | 20 | Routes learned from another autonomous system |
| OSPF | 110 | Interior routing inside an organization |
| IS-IS | 115 | Interior routing in large provider networks |
| RIP | 120 | Legacy small networks |
| Internal BGP | 200 | Routes shared inside one autonomous system |
Router compared with related devices
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.
| Device | Forwarding decision | Main strength | Typical location |
|---|---|---|---|
| Router | IP prefix, Layer 3 | WAN links, routing protocols, rich policies | Network edge, branch, provider core |
| Layer 2 switch | MAC address, Layer 2 | Many ports at low cost per port | Access layer, inside one subnet |
| Layer 3 switch | IP prefix in hardware | High-speed routing between internal VLANs | Campus and data center core |
| Firewall | Security policy and session state | Traffic inspection and filtering | Perimeter between trust zones |
| Home gateway | Default route plus NAT | Router, switch, Wi-Fi and DHCP in one box | Homes and small offices |
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.
| Category | Typical routes held | Typical protocols | Key requirement |
|---|---|---|---|
| Home and small office | A few connected and one default route | Static, DHCP client, NAT | Simplicity and integrated services |
| Branch and enterprise edge | Hundreds to thousands | Static, OSPF, BGP, IPsec VPN | WAN redundancy and security features |
| Provider edge | Full Internet table plus customer routes | BGP, MPLS, IS-IS | Large FIB and per-customer policy |
| Core router | Internal infrastructure routes | IS-IS or OSPF, MPLS | Highest throughput and fast convergence |
| Virtual router | Varies widely | Same software features as hardware | Flexible deployment in clouds |
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.