A route is the path that data takes when travelling through a network from one host to another. Routing is the process by which the path, or some subset of it, is determined. One of the characteristic features of the Internet, as compared to other network architectures, is that each node that receives a packet will typically determine for itself what the next step in the path should be.
IP routing decisions are generally made based on the destination of network traffic. When an IP packet is sent from a node on the network, it will consult its routing table to determine the next hop device that the traffic should be sent to, in order for it to reach its final destination. The routing table on a typical home machine may look something like this (except formatted properly :):
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface x.y.z * 255.255.255.255 UH 0 0 0 ppp0 192.168.0.0 * 255.255.255.0 U 0 0 0 eth0 127.0.0.0 * 255.0.0.0 U 0 0 0 lo default x.y.z 0.0.0.0 UG 0 0 0 ppp0
So, for example, when it receives a packet on interface eth0 which has a destination of 184.108.40.206, it will consult the table and see that it should send it through the default interface, the host x.y.z, which is on interface ppp0.
The routing table is constructed from a combination of statically defined routes and those learned from dynamic routing protocols.
Statically defined routes may be declared at system boot time, or via a command line interface. They will generally include the following parameters:
- Destination - this may be either a single host, or a network (in which case a network mask is also required).
- Gateway - the device to which traffic with the defined destination should be sent.
Static routes may also include the following parameters:
- Interface - the interface through which the traffic to a destination must be sent. (Most OSs can determine this automatically)
- Metric - the number of 'hops' away that the gateway is from this host. For a gateway that resides on a directly connected network, the metric is '1'.
The default route is a special case of a statically defined route. It is the route of last resort. All traffic that does not match another destination in the routing table is forwarded to the default gateway.
Dynamic routing protocols allow network attached devices to learn about the structure of the network dynamically from peer devices. This reduces the administrative effort required to implement and change routing throughout a network. Some examples of dynamic routing protocols are:
- RIP (Routing Information Protocol)
- OSPF (Open Shortest Path First)
- ISIS (Intermediate system to intermediate system)
- BGP (Border Gateway Protocol)
- IGRP (Interior Gateway Routing Protocol)
ISIS and OSPF are link-state protocols, meaning each node part of the same zone, will know the state of all the link in the mesh. Due to the exponential number of link in a mesh, thoses protocols are for small mesh such as an ISP national backbone.
RIP is usually used to easily announce customer's routes in a backbone.
BGP is used as an external routing protocol to exchange routes with other entities. ISP use BGP extensivly to "trade" their routes. It can also be used to carry customers routes accross a network, in a MPLS backbone for example.