TCP/IP routing

A route defines a path for sending packets through the Internet network to an address on another network.

A route does not define the complete path, only the path segment from one host to a gateway that can forward packets to a destination (or from one gateway to another). There are five types of routes:

Item Description
host route Defines a gateway that can forward packets to a specific host on another network.
network route Defines a gateway that can forward packets to any of the hosts on a specific network.
default route Defines a gateway to use when a host or network route to a destination is not otherwise defined.
loopback route Default route for all packets sent to local network addresses. The loopback route IP is always 127.0.0.1.
broadcast route Default route for all broadcast packets. Two broadcast routes are automatically assigned to each subnet on which the network has an IP (one to the subnet address and one to the broadcast address of the subnet).

Routes are defined in the kernel routing table. The route definitions include information on networks reachable from the local host and on gateways that can be used to reach remote networks. When a gateway receives a datagram, it checks the routing tables to find out where next to send the datagram along the path to its destination.

You can add multiple routes for the same destination in the kernel routing table. A routing lookup evaluates all routes that match the request then chooses the route with the lowest distance metric. If multiple matching routes have equal distance, a lookup chooses the most specific route. If both criteria are equal for multiple routes, routing lookups alternate choices of matching routes.