What is a Router?
A router is a device that relays data between two or more different networks. The process of connecting and forwarding communications between networks is called routing. Initially, routers were referred to as multi-protocol routers because they connected computers using various communication protocols. As the internet expanded and matured, IP routing became widely adopted, and communication service providers began reconstructing their backbone networks using IP-based routers. Today, routers are an essential component of the internet, which comprises countless interconnected network segments.
In the OSI reference model, routers operate at Layer 3 (Network Layer) and play a critical role in determining the communication paths for IP packets.
Routers decide on the optimal communication path by referencing their internal routing tables. A routing table contains a list of destination routes that assist the router in determining where to forward incoming packets. If the destination address of a packet matches a route within the table, the router forwards the packet to the next corresponding destination. This process is carried out by multiple routers in a "relay-like" manner, enabling packets to reach hosts on different network segments.
If the packet's destination address does not match any route in the routing table, the router discards the packet and sends a destination unreachable notification to the sender via an ICMP packet. When multiple matching routes exist in the table, the router forwards the packet along the route deemed most optimal.
There are two primary methods to add destination routes to a routing table: