IP Routing

There are three ways for a router to learn routes:

Static Routing – This is the method by which an administrator manually adds routes to the routing table of a router. This is a method for small networks but it is not scalable for larger networks.

Default Routing – This is the method where all routers are configured to send all packets towards a single router. This is a very useful method for small networks or for networks with a single entry and exit point. It is usually used in addition to Static and/or Dynamic routing.

Dynamic Routing – This is the method where protocols and algorithms are used to automatically propagate routing information. This is the most common method and most complex method of routing. Each routing protocol can have chapters or even whole books written about then. Most of them have one or more RFCs dedicated to them. In fact, the whole of the next chapter is dedicated to dynamic routing.

Static Routing

When you manually add routes to the routing table, it is called static routing.

To add a static route, use the following command in the global configuration mode:

As you can see, the command is pretty simple. You need to specify the destination network address, its mask and the address of the next hop towards the destination. You can also specify the exit interface instead of the next hop address. Using the exit interface will cause the router to reply or ARP query and response from the next hop router and is not generally recommended.

Network Diagram For Static Routing

Our Objective is to make reachablily between Host1/Host2(192.168.1.0 Network) to HOST3 (192.168.5.0 Network) with the use of Static Routing.

To configure static routing, you need to look at the path traffic will taken from source to destination and back from destination to source. Each router in the path should know the source and destination network. So assuming our source is in network 192.168.1.0/24 (Host1) and our destination is in 192.168.5.0/24 network (Host3), let us look at the source to destination path, which is Router1->Router2->Router3.

1. Router1 does not know about the destination network. So we need to add a route. The next hop for Router1 towards the destination is Router2’s fa0/0 interface. The route can be added using the following command:

Router1(config)#ip route 192.168.5.0 255.255.255.0 10.1.1.2

Router2 also does not know about the destination network. So we need to add a route telling it that the next hop towards 192.168.5.0/24 is Router3’s fa0/0 interface. The following command can be used to add the route:

Router2(config)#ip route 192.168.5.0 255.255.255.0 10.1.2.2

Router3 knows the destination network since it is directly connected to it. So a route need not be added. Now we will think of returning path.

Following the path back from the destination to source, which is Router3->Router2->Router1:

Router3 does not know the 192.168.1.0/24 network, so a route should be added using the following command:

Router3(config)#ip route 192.168.1.0 255.255.255.0 10.1.2.1

Router2 also does not know the 192.168.1.0/24 network, so a route should be added using the following command:

Router2(config)#ip route 192.168.1.0 255.255.255.0 10.1.1.1

Router1, being directly connected to 192.168.1.0/24, knows about the network already.

To view the routing table and verifying static routing, you can use the show ip route command. The output from all three routers in our example is given below:

Router 1

Router 2

Router 3

Note the following in the output of "show ip route" command -

1.The letter at the start of each line shows how the router was learned. The meaning of each letter is given at the beginning of the output as can be seen form the output from Router1. C stands for directly connected routes. These are the networks to which the router is directly connected. S stands for static routes. As you can see, the routes that you added are shown in lines that start with S.

2.You should verify the network and subnet mask in the output to see if you typed the correct information.

3.The IP address after “via” shows the next hop address for this destination.

4.The outputs show that all the routes that you added above have taken effect and traffic can flow between the 192.168.1.0/24 and 192.168.5.0/24 networks in both directions now. You may have noticed that Router1 still does not know about the network between Router2 and Router3 (10.1.2.0/24) and Router3 does not know about the network between Router1 and Router2 (10.1.1.0/24).

Now you can ping the from HOST1/HOST2 to HOST3 or in reverse order i.e. HOST3 to HOST1/HOST2 ,so we have achived our objective with Static Routing.

Default Routing

Default routing can be considered a special type of static routing. The difference between a normal static route and a default route is that a default route is used to send packets destined to any unknown destination to a single next hop address. To understand how this works, consider Router1 from our example, without any static routes in it. When it receives a packet destined to 192.168.5.0/24 it will drop it since it does not know where the destination network is. If a default route is added in Router1 with next hop address of Router2, all packets destined to any unknown destination, such as 192.168.5.0/24 will be sent to Router2.

Default routes are useful when dealing with a network with a single exit point. It is also useful when a bulk of destination networks have to be routed to a single next-hop device. When adding a default route, you should ensure that the next-hop device can route the packet further, or else the next hop device will drop the packet.

Another point to remember is that when a more specific route to a destination exists in the routing table, the router will use that route and not the default route. The only time the router will use the default route is when a specific route does not exist.

The command to add a default route is same as that of adding a static route, but with the network address and mask set to 0.0.0.0 as shown below:

ip route 0.0.0.0 0.0.0.0 next-hop

In our example network, the only exit point for the 192.168.1.0/24 and 192.168.5.0/24 networks is towards Router2. Hence, we can remove the static routes from Router1 and Router3 and add default routes as shown below:

Remember that since Router2 has multiple exists, you cannot use default routing there. It still needs the static routes.

Take a look at the routing table on Router1 and Router3 after the above changes:

In the above output notice that the static route to 0.0.0.0/0 is now seen in the routing table. Apart from that, the gateway of last resort is now the next-hop as specified in the default route.

A second way of adding a default route would be to specify the exit interface instead of the next-hop address. For example, on Router1, you can use the following command instead of the one used above:

Router1(config)#ip route 0.0.0.0 0.0.0.0 fa0/0

This tells the route to forward all packets, destined to unknown destinations, out fa0/0. While this will accomplish the same thing, the big difference is that a static route with an exit interface specified will take preference over a static route with next-hop specified. This is because the administrative distance of a route with exit interface is lower than the other one.

The administrative distance (AD) is a number used to rate the trustworthiness of the routing information received from a neighbor router. It is used when a router must choose between routes learned using different routing protocols. Each routing protocol has a default AD value. The route learned using the routing protocol with a lower AD number will be placed in the routing table.

An administrative distance is a number between 0 and 255, with the lower number being better. The AD of 0 indicates the most trusted route (the directly connected network). The AD of 255 means that the route will not be trusted.

Here are the default AD values for a different routing protocols: Connected interface – 0
Static route – 1
EIGRP – 90
OSPF – 110
RIP – 120
External EIGRP – 170
Unknown – 255
As Static router

Dynamic Routing

Dynamic routing is when protocols, called routing protocols, are used to build the routing tables across the network. Using a routing protocol is easier than static routing and default routing, but it is more expensive in terms of CPU and bandwidth usage. Every routing protocol defines its own rules for communication between routers and selecting the best route.

Routing protocols are broadly classified in the following two catageries

1.Interior Gateway Protocols (IGP)

2.Exterior Gateway Protocols (EGP)

IGPs are used to exchange routing information within internetworks that fall under a single administrative domain (also called Autonomous Systems). Common examples of IGPs are Routing Information Protocol (RIP), Enhanced Interior Gateway Routing Protocol (EIGRP) and Open Shortest Path First (OSPF).

EGPs on the other hand are used to exchange routing information between different autonomous systems. These are covered in detail in the next chapter. On the other hand, Border Gateway Protocol (BGP) is an example of EGP.

Now we will configure the RIP in our scenario :

Firstly remove all previous command related to static or dynamic routing.

RIP Configuration at Router 1-

RIP Configuration at Router 2-

RIP Configuration at Router 3-

Now as RIP is a Dyanamic Routing Protocol, so each router will automatically learn the routes and you can verifiy the route at each router with the following commands-

Router 1

Router 2

Router 3