What Is a Router?
Learn what a router does, how it forwards packets between IP networks, how default gateways and routing tables work, and how routers differ from switches and bridges.
What Is a Router?
A router is a Layer 3 network device that connects two or more distinct IP networks and forwards packets between them. A router does more than extend one local network: it provides a path from one subnet or network to another.
For example, a router might connect an office LAN to an ISP network, connect two company branches, or connect separate VLAN subnets inside an enterprise. Each router interface normally belongs to a different Layer 3 network.
Routing is the process of selecting a path and forwarding packets toward a destination network. The router's principal forwarding decision is based on the packet's destination IP address.
Routers in the OSI Model
The Open Systems Interconnection (OSI) model divides network communication into layers. A router is primarily associated with Layer 3, the Network layer, where logical addressing and routing take place. See the OSI reference model for a broader overview.
An IP packet contains a source IP address and a destination IP address. A router examines the destination IP address, compares it with entries in its routing table, and selects where to send the packet next.
This differs from Layer 2 forwarding. A switch or bridge examines Ethernet frames and primarily uses destination MAC addresses to forward those frames within a Layer 2 network. A router uses Layer 3 routing information to move packets between IP networks.
Why a Router Is Required
Hosts on the same IP subnet can normally communicate directly over their local Layer 2 network. Hosts on different IP networks cannot reach each other through Layer 2 forwarding alone. They need a Layer 3 forwarding device, such as a router.
Same-subnet communication
When a host determines that a destination is in its own subnet, it sends the traffic directly on the local network. The host uses the destination's Layer 2 address to deliver the frame locally.
Remote-subnet communication
When the destination is outside the host's local subnet, the host sends the frame to its configured default gateway. The default gateway is usually the IP address of a router interface on the host's local LAN.
The frame reaches the router's local interface, and the router then forwards the IP packet toward the remote network. The remote destination IP remains the destination of the packet under normal forwarding conditions, even though the Layer 2 frame used to carry it changes from link to link.
Default Gateway Example
Suppose a host has address 192.168.10.25/24 and default gateway 192.168.10.1. The host belongs to the 192.168.10.0/24 subnet.
- A destination such as
192.168.10.50is local, so the host sends directly on the local LAN. - A destination such as
10.0.0.20is remote, so the host sends the frame to the router at192.168.10.1.
The host uses its IP address, subnet mask or prefix, and the destination IP address to determine whether the destination is local or remote. If the destination is remote, the default gateway provides the first Layer 3 step toward that destination.
How a Router Forwards a Packet
- The source host identifies the destination. It compares the destination IP address with its own subnet information.
- The host chooses local or remote delivery. For a remote destination, it chooses the default gateway.
- The host creates a Layer 2 frame. The frame is addressed to the gateway's MAC address, while the IP packet contains the remote destination IP address.
- The router receives the frame. It removes the incoming Layer 2 encapsulation and examines the destination IP address in the packet.
- The router consults its routing table. It searches for a route matching the destination IP address.
- The router selects a path. The selected route identifies an outgoing interface and, when needed, a next-hop router.
- The router creates a new Layer 2 frame. It encapsulates the IP packet for the next link and transmits it through the selected interface.
- The process repeats. Additional routers can examine the destination IP and forward the packet until it reaches the destination network.
A next hop is the next router or network device to which the packet is sent. An outgoing interface is the router interface selected to transmit the packet toward that next hop or destination network.
Layer 2 encapsulation can change at every routed link. For example, an Ethernet frame on one link is replaced by a new frame on the next Ethernet link. The IP packet is forwarded toward its destination under normal conditions.
Routing Tables
A routing table is the collection of route entries a router uses to determine where to send packets. A route normally identifies a destination network and an outgoing interface, a next hop, or both.
Routes can be learned in several ways, including directly connected interfaces, manually configured static routes, and dynamic routing protocols. The route-selection process matches the packet's destination IP address against destination network prefixes. When multiple routes match, the router generally prefers the most specific matching prefix, known as the longest-prefix match.
| Destination network/prefix | Route type | Next hop | Outgoing interface |
|---|---|---|---|
| 192.168.10.0/24, Host A's network | Directly connected | Not required | G0/0 |
| 10.0.0.0/24, Host B's network | Directly connected | Not required | G0/1 |
| 172.16.20.0/24, Host C's network | Directly connected | Not required | G0/2 |
If no usable matching route exists, and no default route applies, the router cannot normally forward the packet toward its destination. It may discard the packet and potentially send an error notification, depending on the protocol and situation.
Example static route syntax
A static route can be added in Cisco IOS with a command such as:
ip route <destination-network> <subnet-mask> <next-hop-ip-or-exit-interface>This syntax illustrates that a route can specify the destination network and either a next-hop IP address, an exit interface, or both. Static routing is only one way to populate a routing table.
Worked Multi-Network Forwarding Scenario
In this example, one router has three interfaces. Each interface connects to a separate IP network. Host A sends a unicast packet to Host B, while Host C is located on a third network.
| Device | Interface | IP address/prefix | Default gateway or next hop | Network |
|---|---|---|---|---|
| Host A | Ethernet | 192.168.10.10/24 | 192.168.10.1 | 192.168.10.0/24 |
| Router | G0/0 | 192.168.10.1/24 | Not applicable | 192.168.10.0/24 |
| Host B | Ethernet | 10.0.0.20/24 | 10.0.0.1 | 10.0.0.0/24 |
| Router | G0/1 | 10.0.0.1/24 | Not applicable | 10.0.0.0/24 |
| Host C | Ethernet | 172.16.20.30/24 | 172.16.20.1 | 172.16.20.0/24 |
| Router | G0/2 | 172.16.20.1/24 | Not applicable | 172.16.20.0/24 |
Host A compares 10.0.0.20 with its local network, 192.168.10.0/24, and determines that Host B is remote. Host A therefore sends the frame to the MAC address of its default gateway, 192.168.10.1.
The router receives the packet and examines its destination IP address, 10.0.0.20. Its routing table contains a matching route for 10.0.0.0/24, associated with interface G0/1. The router forwards the packet through G0/1 toward Host B's network.
Host C is not sent the unicast packet as part of this normal routed forwarding path. The router selects the interface for Host B's destination network; it does not copy the packet to every connected network.
Router Interfaces and Network Boundaries
Each router interface belongs to a separate Layer 3 network or subnet. This makes the interface a boundary between IP networks and between Layer 2 broadcast domains.
A broadcast domain is the set of devices that receive a Layer 2 broadcast. Routers do not forward Layer 2 broadcasts by default, so a broadcast sent on one router interface normally remains within that interface's connected broadcast domain.
Each router interface also creates a separate collision domain. A collision domain is a network segment in which Ethernet transmissions could collide. Modern switched Ethernet links are usually full duplex, meaning they can transmit and receive simultaneously without Ethernet collisions when both ends support and negotiate, or are configured for, full-duplex operation.
Router, Switch, and Bridge Comparison
| Device | Primary OSI layer | Main forwarding information | Primary purpose | Broadcast-domain behavior |
|---|---|---|---|---|
| Router | Layer 3 | Destination IP address and routing table | Forward packets between IP networks | Separates broadcast domains; broadcasts are not forwarded by default |
| Layer 2 switch | Layer 2 | Destination MAC address and MAC address table | Forward Ethernet frames within a LAN | Ports generally remain in the same broadcast domain unless VLANs or Layer 3 features separate them |
| Bridge | Layer 2 | Destination MAC address | Connect LAN segments and forward frames | Connects Layer 2 segments; it does not provide general Layer 3 inter-network routing |
A switch or bridge can reduce unnecessary Layer 2 forwarding by learning MAC addresses, but it does not replace a router when traffic must cross an IP subnet boundary. A router provides inter-network connectivity and broadcast-domain separation.
Common Real-World Uses
A common home or office design uses a router to connect a local area network (LAN) to an ISP-facing network and ultimately to Internet destinations. The router is the default gateway for local hosts and forwards traffic from the local LAN toward external networks.
Many consumer devices combine routing with other functions such as network address translation (NAT), firewall filtering, wireless access, and switching. These additional functions are common, but the fundamental routing role is forwarding traffic between IP networks.
Routers are also used to connect internal departments, branch offices, VLAN subnets, data-center networks, and wide area network (WAN) links. Internet access is only one application of routing.
Verifying Router Operation in Cisco IOS
These Cisco IOS commands connect the concepts to a real router:
show ip route
show ip interface brief
show interfacesshow ip routedisplays the routing table, including connected, static, and dynamically learned routes.show ip interface briefprovides a quick view of interface addresses and operational status.show interfacesdisplays detailed interface information, including link state and duplex status where applicable.
Troubleshooting Routing Problems
Local devices work, but a remote subnet is unreachable
If a host can reach devices in its own subnet but cannot reach a remote subnet, check the host's IP address, prefix or subnet mask, and default gateway. Then verify that the router interface for the host LAN is operational and that the router has a route to the remote network.
The router receives traffic but does not forward it
Review the route that should match the destination IP address. Check whether the selected outgoing interface is up, whether the connected route is present, and whether the next-hop address is reachable. A missing usable route or default route prevents normal forwarding.
Traffic behaves as though the destination is local
An incorrect subnet mask or prefix length can cause a host to classify a remote destination as local. Incorrect addressing on a host or router interface, or overlapping IP subnets, can produce similar symptoms. Compare every address and prefix with the addressing plan and ensure that each router interface is assigned to the intended distinct subnet.
Exam-Relevant Summary
- A router is primarily an OSI Layer 3 device.
- Routers forward packets between separate IP networks using destination IP addresses and routing information.
- A host uses its default gateway to reach a remote subnet.
- A routing table maps destination networks to outgoing interfaces and/or next hops.
- Each router interface normally belongs to a different subnet and separates broadcast domains.
- Routers do not forward Layer 2 broadcasts by default.
- Switches and bridges primarily forward Layer 2 frames using MAC addresses within a LAN.
- Layer 2 encapsulation changes across routed links, while the IP packet continues toward its destination under normal conditions.
- Internet connectivity is one use of a router; inter-VLAN, branch, departmental, and WAN connectivity are other common uses.
For related topics, review computer network fundamentals, OSPF configuration, and router-on-a-stick inter-VLAN routing.