A router is a networking device that filters and forwards traffic at OSI layer three, the network layer.
To make their forwarding decisions, routers maintain an internal database of routes and exit interfaces. This database is called the routing table or the forwarding table. To function as a router, a device needs at least two active interfaces, each of which faces a different subnet or a different network.
Most commonly, routers are special purpose devices with hardware optimized to support their function. However, routing functionality can also be provided in various form factors. PCs with dual NIC cards can serve as simple routers. Likewise, layer three switches support routing processes in addition to normal switching components. In addition, many consumer products sold as routers are really multifunction appliances including WiFi access points, Ethernet switch ports, and simple firewalls in addition to supplying sufficient routing functionality to join a local network to an ISP connection.
Unlike switches, true routers require configuration before they can function. Before forwarding packets, routers must discover which networks are located in the direction of each active interface. Three such methods of network discovery include:
Distance-vector and link-state are two general types of dynamic routing protocol.
An older term for router was gateway. The word gateway continues to be used synonymously with router in a variety of contexts. One such usage is the notion of a default gateway. The default gateway is the designated destination for all packets for whose target destination's network location is unknown. Most commonly, the default gateway setting on a host points to the nearest interface of the nearest router. This router should then be able to find a route to the destination by consulting its routing tables. The first router may likewise hand off the packet in the direction of its default route, and so on, until eventually the packet reaches a device with a sufficiently detailed routing table to specify the correct forwarding pathway.
Another use of the term gateway in relation to routing is in the classification of routing protocols by their scope of use. Two major divisions of routing protocol scope are:
Interior gateway protocols are used within the boundaries of a single autonomous system (AS). Examples include RIP, OSPF, and EIGRP. Exterior gateway protocols are used to pass traffic between autonomous systems. BGP is the most widely adopted exterior gateway protocol.
Routers are fundamental to the design and function of the global Internet. Routers have the ability to pass traffic back and forth between different networks, which in essence provides the very definition of an internetwork - a network that connects other networks.