A router is a Layer device that forwards packets between different networks. While switches connect devices within a network, routers connect separate networks together.
Routers examine the destination IP address in each packet and decide where to send it next. They maintain a routing table that maps network destinations to outgoing interfaces or next-hop addresses.
Every router has at least interfaces, each connected to a different network. When a packet arrives, the router strips the Layer header, examines the Layer destination, makes a forwarding decision, and adds a new Layer header for the next hop.