Connected, Static & Dynamic Routes
Let’s explain the types of routes that can be found in a router’s routing table.
Connected routes
Subnets directly connected to a router’s interface are added to the router’s routing table. Interface has to have an IP address configured and both interface status codes must be in the up and up state. A router will be able to route all packets destined for all hosts in subnets directly connected to its active interfaces.
Consider the following example. The router has two active interfaces, Fa0/0 and Fa0/1. Each interface has been configured with an IP address and is currently in the up-up state, so the router adds these subnets to its routing table.
As you can see from the output above, the router has two directly connected routes to the subnets 10.0.0.0/8 and 192.168.0.0/24. The character C in the routing table indicates that a route is a directly connected route.NOTE
You can see only connected routes in a router’s routing table by typing the show ip route connected command.
Static routes
By adding static routes, a router can learn a route to a remote network that is not directly connected to one of its interfaces. Static routes are configured manually by typing the global configuration mode command ip route DESTINATION_NETWORK SUBNET_MASK NEXT_HOP_IP_ADDRESS. This type of configuration is usually used in smaller networks because of scalability reasons (you have to configure each route on each router).
A simple example will help you understand the concept of static routes.
Router A is directly connected to router B. Router B is directly connected to the subnet 10.0.1.0/24. Since that subnet is not directly connected to Router A, the router doesn’t know how to route packets destined for that subnet. However. you can configure that route manually on router A.
First, consider the router A’s routing table before we add the static route:
Now, we’ll use the static route command to configure router A to reach the subnet 10.0.0.0/24. The router now has the route to reach the subnet.
The character S in the routing table indicates that a route is a statically configured route.
Another version of the ip route command exists. You don’t have to specify the next-hop IP address. You can rather specify the exit interface of the local router. In the example above we could have typed the ip route DEST_NETWORK NEXT_HOP_INTERFACE command to instruct router A to send all traffic destined for the subnet out the right interface. In our case, the command would be ip route 10.0.0.0 255.255.255.0 Fa0/0.
Dynamic routes
A router can learn dynamic routes if a routing protocol is enabled. A routing protocol is used by routers to exchange routing information with each other. Every router in the network can then use the information to build its routing table. A routing protocol can dynamically choose a different route if a link goes down, so this type of routing is fault-tolerant. Also, unlike with static routing, there is no need to manually configure every route on every router, which greatly reduces the administrative overhead. You only need to define which routes will be advertised on a router that connects directly to the corresponding subnets – routing protocols take care of the rest.
The disadvantage of dynamic routing is that it increases memory and CPU usage on a router because every router has to process received routing information and calculate its routing table.
To better understand the advantages that dynamic routing protocols bring, consider the following example:
Both routers are running a routing protocol, namely EIGRP. There is no static routes on Router A, so R1 doesn’t know how to reach the subnet 10.0.0.0/24 that is directly connected to Router B. Router B then advertises the subnet to Router A using EIGRP. Now Router A has the route to reach the subnet. This can be verified by typing the show ip route command:
You can see that Router A has learned the subnet from EIGRP. The letter D in front of the route indicates that the route has been learned through EIGRP. If the subnet 10.0.0.0/24 fails, Router B can immediately inform Router A that the subnet is no longer reachable.
Administrative Distance & Metric
Administrative distance
A network can use more than one routing protocol, and routers on the network can learn about a route from multiple sources. Routers need to find a way to select a better path when there are multiple paths available. An administrative distance number is used by routers to find out which route is better (lower number is better). For example, if the same route is learned from RIP and EIGRP, a Cisco router will choose the EIGRP route and stores it in the routing table. This is because EIGRP routes have (by default) the administrative distance of 90, while the RIP route has a higher administrative distance of 120.
You can display the administrative distance of all routes on your router by typing the show ip route command:
In the case above, the router has only a single route in its routing table learned from dynamic routing protocols – the EIGRP route.
The following table lists the administrative distance default values:
Metric
If a router learns two different paths for the same network from the same routing protocol, it has to decide which route is better and will be placed in the routing table. Metric is the measure used to decide which route is better (lower number is better). Each routing protocol uses its own metric. For example, RIP uses hop counts as a metric, while OSPF uses cost.
The following example explains the way RIP calculates its metric and why it chooses one path over another.
RIP has been configured on all routers. Router 1 has two paths to reach the subnet 10.0.0.0/24. One path goes through Router 2, while the other path goes through Router 3 and then Router 4. Because RIP uses the hop count as its metric, the path through Router 1 will be used to reach the 10.0.0.0/24 subnet. This is because that subnet is only one router away on the path. The other path will have a higher metric of 2 because the subnet is two routers away.NOTE
The example above can be used to illustrate the disadvantage of using RIP as a routing protocol. Imagine if the first path through R2 was the 56k modem link, while the other path (R3-R4) is a high-speed WAN link. Router R1 would still choose the path through R2 as the best route because RIP uses only the hop count as its metric.
The following table lists the parameters that various routing protocols use to calculate the metric: