A router knows about the networks to which it is directly connected. However, it’s up to you to enable a router to find out about networks to which a direct connection does not exist. As I mentioned earlier, a router primarily finds out about remote networks in one of two ways – via a static routing table entry, or through the use of a dynamic routing protocol like RIP or IGRP. Again, this is best illustrated by an example. In the figure below, our network includes four networks and three routers.
Figure: Routing tables showing directly connected networks only.
For this example, I’m again going to assume that all of our connections are via Ethernet ports. Remember that all 3 routers known about their directly connected networks. Given the current configuration, Router A can route packets between network 10.0.1.0/24 and network 10.0.2.0/24. Router B can route packets between networks 10.0.2.0/24 and 10.0.3.0/24. Finally, Router C can route packets between 10.0.3.0/24 and 10.0.4.0/24.
From the routing tables shown in the previous figure, it should be clear that each router is unaware of the two networks to which it has no direct connections. For example, Router A doesn’t know how to reach either network 10.0.3.0/24 or 10.0.4.0/24.
First off, let’s be clear on one thing – when a router doesn’t know how to get to a destination network, it will drop any packets destined for that network and send an ICMP destination unreachable message to the host. For example, if Router A receives packets destined for network 10.0.3.0/24, it will drop them as things currently stand. The router won’t guess or make any assumptions on its own, which is good news (later in the chapter we’ll discuss how this can be changed through the use of default routes). This also means that it’s up to you to make the whole network route – it actually isn’t that big a deal in this case, as you’ll see shortly.
For now, I’m going to assume that we’re setting up static routing on our simple network. If you think about things, we really need to accomplish three main goals:
- Configure Router A with a way to get to networks 10.0.3.0/24 and 10.0.4.0/24.
- Configure Router B with a way to get to networks 10.0.1.0/24 and 10.0.4.0/24.
- Configure Router C with a way to get to networks 10.0.1.0/24 and 10.0.2.0/24.
Let’s start with Router A. We need to tell Router A how to get to networks 10.0.3.0/24 and 10.0.4.0/24. This will involve adding static entries to Router A’s routing table. The key thing to remember is that routers will always communicate directly with a host on a connected network, or pass a packet on to the next “hop”, which is another router. There is no magic flying across networks or avoiding routers in the path between a source and destination host. Keep in mind everything the router does will happen one hop at a time.
Take another look at the previous figure. The key to configuring routing is to figure out what the next hop address is. First, we are trying to determine where Router A should send packets destined for network 10.0.3.0. Obviously it cannot communicate with network 10.0.3.0/24 directly, since it doesn’t have an interface connected to this network. As such, Router A will need to forward packets destined for network 10.0.3.0/24 to Router B – in this case, interface 10.0.2.2. The address 10.0.2.2 is our next hop address on the journey to network 10.0.3.0/24. Once packets arrive at 10.0.2.2, Router B will be able to forward them to network 10.0.3.0/24 – a directly connected network. Similarly, we need to tell Router A how to get to network 10.0.4.0/24. Since it is in the same direction, we will also add a static route that sends packets destined for network 10.0.4.0 to the next hop – which is also 10.0.2.2. Since network 10.0.4.0/24 isn’t directly connected to Router B, it will also need a route defined to this network.
Routing table entries will also need to be added to Router B and Router C. In this case, the entries below need to be added, as also shown in the figure below.
- Router B needs a static route defined to network 10.0.1.0/24. The next hop address to reach this network would be 10.0.2.1. A route will also need to be defined to network 10.0.4.0/24, with a next hop address of 10.0.3.2.
- Router C needs static routes defined to networks 10.0.1.0/24 and 10.0.2.0/24. In both cases, the next hop address will be 10.0.3.1.
Figure Network with complete routing table entries.
Notice that by adding just two static routing entries on each router, we end up with a fully routed network. Obviously, if there were more networks involved, additional routing table entries would be required. To get a feel for exactly what is happening on this network, let’s assume that Host A (from the previous figure) wishes to communicate with Host D. I’m not going to point out every single detail of the communications process this time, but all the same things that happened in our original example do happen again here.
- In this example, Host A wishes to communicate with Host C. Host A will create an IP packet with a source address of 10.0.1.99 and a destination address of 10.0.4.101. Since Host C is remote, the packet will be framed, with the destination MAC address being that of Router A’s E0 interface.
- Once the frame reaches Router A, it will calculate the CRC, strip off the framing, and pass the packet up to the Network Layer. In consulting its routing table, Router A will find that the next hop address to reach network 10.0.4.0 is 10.0.2.2. Router A will decrement the IP packet’s TTL by 1, and will reframe the packet. In this case, the source MAC address will be MAC address of Router A interface E1 and the destination MAC address will be that of Router B interface E0. The MAC address of Router B interface E0 will be found with an ARP request.
- Once the frame reaches Router B, a similar process occurs. The CRC will be calculated, the framing will be stripped off, and the packet will be passed to the Network Layer. In consulting its routing table, Router B will find that the next hop address to reach network 10.0.4.0 is 10.0.3.2. Router B will again decrement the IP packet’s TTL by 1, and will reframe the packet. In this case, the source MAC address will be MAC address of Router B interface E1, and the destination MAC address will be that of Router C interface E0.
- The frame is now forwarded to Router C interface E0. Router C will calculate the CRC, strip off the framing, and pass the packet up to the Network Layer. Here it will consult its routing table, and will see that network 10.0.4.0 is directly connected on interface E1. Router C will also decrement the TTL by 1, and then reframe the packet. This time, the source MAC address will be Router C’s E1 interface, and the destination MAC address will be that of Host D, which will have been found by an ARP request. The frame is then forwarded to Host D.
- Upon receipt at Host D, the frame is processed, and ultimately the data it contains makes its way to the appropriate application. The reply from Host D to Host A undergoes the same process, in reverse.
In a nutshell, simple routing is no more complex than this example. If we had wanted to, we could have configured all three routers with a dynamic routing protocol, and this would have allowed them to exchange routing table information without our intervention. While this may immediately sound like a great idea, there are some downsides, as we’ll look at a little later in the chapter. For now, it’s most important that you understand the purpose of a routing table, how basic routing decisions are made, what happens when IP packets cross a router, and the constant re-framing that occurs on a packet’s journey.