TCP/IP has grown in complexity quite a lot when it comes to the routing part. In
the beginning, most people thought it would be enough with destination driven
routing. The last few years, this has become more and more complex
however. Today, Linux can route on basically every single field or bit in the IP
header, and even based on TCP, UDP or ICMP headers as well. This is called
policy based routing, or advanced routing.
This is simply a brief discussion on how the destination driven routing is
performed. When we send a packet from a sending host, the packet is created.
After this, the computer looks at the packet destination address and compares it
to the routing table that it has. If the destination address is local, the
packet is sent directly to that address via its hardware MAC address. If the
packet is on the other side of a gateway, the packet is sent to the MAC address
of the gateway. The gateway will then look at the IP headers and see the
destination address of the packet. The destination address is looked up in the
routing table again, and the packet is sent to the next gateway, et cetera,
until the packet finally reaches the local network of the destination.
As you can see, this routing is very basic and simple. With the advanced routing
and policy based routing, this gets quite a bit more complex. We can route
packets differently based on their source address for example, or their TOS
value, et cetera.