What is a router used for in networking?
A Layer 3 device that connects different networks and forwards packets by IP address, choosing the next hop from its routing table.
Where a switch connects devices within one network, a router connects separate networks to each other — it's the device that lets your LAN reach the wider Internet. To do that it works with IP addresses rather than MAC addresses, because IP addresses identify which network a destination is on, and the router's job is to pick the best path toward that network. Think of it like a postal sorting centre: it doesn't care about the exact desk, only which city the letter is headed to and which road gets it closer.
* A router reads each packet's destination IP, looks up the best route, and forwards toward the next hop. *
Key characteristics:
- Operates at Layer 3 (Network) of the OSI model
- Connects different networks together, e.g. a LAN to a WAN
- Makes routing decisions — choosing the best next hop toward the destination
- Separates broadcast domains, so a broadcast in one network doesn't flood the others (unlike a switch)
How it works:
- Receives a packet
- Reads the destination IP address
- Looks up the best matching route in its routing table
- Forwards the packet to the next hop along that route
Go deeper:
Host to Host through a Router (Practical Networking) — deepest: the routing table plus per-hop L2 header regeneration, with a worked multi-hop example.
Router (computing) (Wikipedia) — Layer 3 device forwarding packets by destination IP via a routing table.