Simple Networking

Routes and Routing Explained

24.12.2015

How to add a route

By default, any router or firewall is aware only of those networks and subnets that are directly connected to it. This applies likewise to Cisco equipment and any other vendors. If a device has 2 interfaces with IP addresses from different networks assigned, it is capable of forwarding packets between two connected hosts, routing the traffic. That is, of course, if the hosts have that device configured as their default gateway.

Cisco Routes and Routing Explained

The above example is oversimplified and is almost never used in real life. Let’s consider a more complex and realistic scenario: we have two locations in a company, with each office having its own LAN that is connected to a router. Between the two offices there is some kind of a point-to-point link.
In this case, by default, each router will only be aware of its LAN and of the link between the offices, but will not know where to forward the packets destined for the other office’s LAN. If you issue a ping command, each router will be able to access the outside IP address of the other router, but will not be able to reach any address inside the remote LAN.

Cisco Routes and Routing Explained

In order to make communication between hosts A and B possible, we need to configure both office routers with routes to the remote network.
Here is the configuration syntax for that:
ip route x.x.x.x x.x.x.x y.y.y.y
x.x.x.x x.x.x.x – is the network address and subnet mask of the remote network
y.y.y.y – is the Gateway. This is the address of the closest interface of the neighbor router, through which the remote network is available.

This is how the configuration for our sample network will look like:
For Router 1 (the one on the left)
R-DELTACONFIG-1(config)#
ip route 192.168.20.0 255.255.255.0 10.0.0.2

For Router 2 (the one on the right)
R-DELTACONFIG-2(config)#
ip route 192.168.10.0 255.255.255.0 10.0.0.1

Important!
If you add the route on only one router (left), then a packet from host A to host B will traverse the network in one direction, but will be discarded upon trying to return – since there is no route back to the originating subnet. Each network device that forwards packets needs to know routes for both the source and the destination of a packet, no matter how many such devices a network has.

deltaconfig cisco outsourcing

Route summarization, default gateways and route priorities

You can configure routes not only for entire networks, but narrow them down to something more specific, like a single host. For example, a route from the above example only to host B will look like this:
ip route 192.168.20.2 255.255.255.255 10.0.0.2
You can also combine several routes to different subnets that are available through the same gateway – summarize.
For example, you can combine routes to four subnets that are reachable through the same gateway into one route for a broader network by changing the subnet mask.

The following routes
ip route 192.168.20.0 255.255.255.0 10.0.0.2
ip route 192.168.21.0 255.255.255.0 10.0.0.2
ip route 192.168.22.0 255.255.255.0 10.0.0.2
ip route 192.168.23.0 255.255.255.0 10.0.0.2

can be summarized into one route with the following mask:
ip route 10.168.20.0 255.255.252.0 10.0.0.2
We will not go into the topics of IP addressing, masks and the depths of how to calculate them here. It is such a broad subject for discussion, that entire book chapters are used to cover them, not just articles. I am hoping that the reader is already somewhat familiar with those concepts, at least in theory.

Important!
A narrower route to a specific network will always take priority over a summarized route, no matter the size of the subnets used.

A special instance of summarized routes is the default gateway. This is the route to network 0.0.0.0 with the mask 0.0.0.0 through a specified gateway address.
ip route 0.0.0.0 0.0.0.0 х.х.х.х
where х.х.х.х – is the IP address of the default gateway
Such configuration line tells the router to forward all packets that do not have specific routes associated with destination networks to the default gateway. In most cases, such routes are used when connecting the router to the Internet. The default gateway will be the closest IP address of the ISP equipment (usually provided by the ISP).

For better understanding, let’s consider a third example that is closest to a real-life scenario. Our two offices from the above example have not only the WAN link between them, but also links to the Internet. 1.1.1.1 и 2.2.2.2 are the IP addresses provided by the ISP that are to be used as default gateways.

Cisco Routes and Routing Explained

Configuration lines:
For Router 1 (the one on the left)
R-DELTACONFIG-1(config)#
ip route 192.168.20.0 255.255.255.0 10.0.0.2
ip route 0.0.0.0 0.0.0.0 1.1.1.1

For Router 2 (the one on the right)

R-DELTACONFIG-2(config)#
ip route 192.168.10.0 255.255.255.0 10.0.0.1
ip route 0.0.0.0 0.0.0.0 2.2.2.2

These routes will tell each of the two routers to forward packets destined for the remote office subnet to the neighboring router, while all routes with unknown networks (Internet) should be forwarded to the ISP default gateway.

Important!
Once again, the order of the routes inside the configuration does not matter. The priority is always given to the narrowest and most specific route. If there is no route available for a specific subnet in the routing table, only then the router will send the packets to the default gateway.

This article was written by Alexey Yurchenko

Back to Table of contents

avatar
×

How can I help you?