Routing protocols may be broadly distinguished by their realm of operation in terms of network scope. Interior gateway protocols are used for routing within autonomous systems, while exterior gateway protocols route traffic between them. The former group is exemplified by the Routing Information Protocol (RIP) and Open Shortest Path First (OSPF), while the Exterior Gateway Protocol (EGP) and the Border Gateway Protocol (BGP) are examples of the exterior type. BGP is the dominant route distribution protocol used on the Internet.
The IP forwarding algorithm is a specific implementation of routing for IP networks. In order to achieve a successful transfer of data, the algorithm uses a routing table to select a next-hop router as the next destination for a datagram. The IP address of the selected router is known as the next-hop address.2
The IP forwarding algorithm states:3
When multiple route table entries match, the entry with the longest subnet mask is chosen as it is the most specific one.6 If there are multiple routes with the same subnet mask, the route with the lowest metric is used. If there are multiple default routes, the metric is also used to determine which to use. If there are multiple routes with the same subnet mask and metric, the system may use equal-cost multi-path routing as a forwarding strategy.
When no route is available, an ICMP error message is sent to the originator of the packet,7 to inform that host that the packet could not be delivered. To avoid unnecessary retransmission to avoid network congestion, the sending host should either stop transmitting or choose another address or route.
The following presents a typical routing table in a Unix-like operating system:
The host has several network interfaces. eth0 is the interface name of the network interface card representing an Ethernet port. ppp0 is a PPPoE interface, which is configured as the default route in this example.
A default route is recognized by the destination 0.0.0.0 and the flag G. A network router is identified by the network mask 255.255.255.255 and the flag H.
Comer, Douglas E. (2000). Internetworking with TCP/IP (4th ed.). Upper Saddle River, NJ: Prentice Hall. ↩
"IP Routing and Subnets". Retrieved 2022-08-02. https://www.eventhelix.com/networking/ip-routing/ ↩
"Guide to IP Layer Network Administration with Linux - chapter 4.2. Routing to Locally Connected Networks". Retrieved 2022-08-02. http://linux-ip.net/html/routing-local.html ↩
Many implementations list these directly-connected networks as routing table entries, in which case, this condition is handled by the general route table lookup. ↩