Dynamic routing

Layer 3 - Routing Layer 2 - VLANs, DTP, VTP, Spanning Tree, and EtherChannel

  • Dynamic routing is in contrast to static routing, because it’s not fixed.

  • Static routing involves manually configuring routes to each destination with the ‘IP ROUTE’ command.

  • Dynamic routing, on the other hand, involves configuring adynamic routing protocol on the router, and then letting the router take care of finding the best routes to destination networks.

  • If you add a new LAN, routers will automatically inform each other about how to get to that new destination network.

  • If one path to a destination becomes unavailable, the routers will automatically start using the next-best path.

Network route

  • A route to a network/subnet, not a route to a single host.

  • Mask length < /32.

  • Showed as 'connected routes' in 'show ip route'.

Host route

  • A route to a specific host

  • Single address with /32 mask.

  • Displayed as 'local routes'.

  • Static route to host : ip route host address 255.255.255.255

Example

Without configuring any static routes or dynamic routing protocol, R1’s routing table shows connected and local routes which were automatically added when IP addresses were configured on its interfaces.

![[dynamic routing.png]]

  • Instead of configuring static routes on each of these routers, we enable a dynamic routing protocol on them.

  • Then, R4 will ‘advertise’ this 192.168.4.0/24 network to its neighbor, R2, saying ‘you can reach this network via me. R2 will add that route to its route table.

  • It will then advertise the same thing to R1, telling R1 that it can reach 192.168.4.0/24 via R2.

  • R1 will add this route to its route table. If you look at that table, you can see that R2 also advertised the 10.0.24.0/30 network, between R2 and R4, to R1.

  • R1 will then in turn advertise to R3, telling R3 that it can reach 192.168.4.0/24 via R1. It will also advertise the 10.0.24.0/30 network that it learned from R2, as well as the 10.0.12.0/30 network between R1 and R2.

If there is an error and R4’s g0/0 interface goes down,

  • The other routers will automatically adapt and remove the route from their route tables.

  • This will prevent R1 from continuously sending traffic to a dead-end.

  • If static routing is used, R1 is unaware that it can no longer reach the 192.168.4.0 network. If it receives packets destined for that network, it will continue forwarding them to R2, unaware that R2 can no longer reach the network.

Benefit of dynamic routing : Router will remove invalid routes.

We should make sure there is a backup route, so instead of totally removing the destination network from the route table, it is replaced with the next-best route.

Another connection is added between R3 and R4. Now R1 has two valid paths to R4’s internal network.

![[dynamic routing 1.png]]

  • R1 still has the route via R2 in its route table, as it says via 10.0.12.2.

  • If R4’s g0/0 interface is disabled, and now in R1’s route table, the route via R2 was now automatically replaced with the route via R3, it says via 10.0.13.2.

  • Before R2 was preferred over the route via R3 because R2-R4 connection is a fastethernet connection, not gigabit ethernet.

  • dynamic routing protocols use a similar concept to STP root cost to determine the best path to a destination.

  • R1 learned about the 192.168.4.0/24 network from both R2 and R3, however it determined that the path via R2 is superior because it ‘costs’ less.

Summary

  • Routers can use dynamic routing protocols to advertise information about their connected routes as well as routes they have learned from other devices.

  • They form ‘adjacencies’ , also know as ‘neighbor relationships’ or ‘neighborships’ with adjacent routers to exchange this information (here R1 will form adjacencies with R2 and R3).

  • If multiple routes to a destination are learned, the router determines which route is superior and adds it to the routing table.

  • It uses the ‘metric’ of the route to decide which is superior, and the lower metric is superior.

Types

IGP (Interior Gateway Protocol) - used to share routes within a single autonomous system (AS), for example within a company.

EGP (Exterior Gateway Protocol) - used to share routes between different autonomous systems, like over the internet.

![[dynamic routing types.png]]

Each box is their own autonomous system, AS.

  • Within each organization, an IGP is used. To exchange routing information between AS’s, an EGP is used.

  • The basic purpose of IGPs and EGPs is the same, to share information about routes to destinations and select the best route to each destination.

  • But the algorithm used to do so is different for each routing protocol.

Algorithm - processes each protocol uses to share route information and choose the best route to each destination.

  • IGP - Distance vector, Link state algorithms

    • Distance vector - RIP, EIGRP

    • Link state - OSPF, IS-IS

  • EGP - Path vector algorithm

    • Path vector - BGP

Distance vector

  • Invented before link state protocols.

  • Early examples - RIP, IGRP (Cisco’s proprietary protocol, later updated to EIGRP).

  • Operate by sending the following information to their directly connected neighbors :

    • their known destination networks.

    • their metric to reach their known destination networks.

  • Distance - the metric, Vector - direction to send the traffic (next-hop router)

  • Distance vector protocols work by sharing their route table, or parts of it, with their neighbors.

  • This method of sharing route info is called routing by rumor.

  • The router doesn’t know about the network beyond its neighbors. It only knows the information that its neighbors tell it. In link state routing protocols, router develops a more complete picture of the network.

![[distance vector routing.png]]

  • R2 doesn’t know anything except that it can reach 192.168.4.0/24 via R4, and that R4’s metric is 1.

  • R2 then tells R1 the same, except it advertises the metric as 2. R1 knows that it can reach 192.168.4.0/24 via R2, and that R2’s metric to reach it is 2.

  • R1 advertises the network to R3, with its own metric to reach the destination network.

R1 doesn’t have a detailed picture of the network.

  • When using a link state routing protocol, every router creates a ‘connectivity map’ of the network to calculate the best routes. This map will be the same on each router.

  • To allow this, each router advertises information about its interfaces, its connected networks, to its neighbors.

  • These advertisements are passed along to other routers, until all routers in the network develop the same map of the network.

  • Then, each router independently uses this map to calculate the best routes to each destination.

  • Uses more resources, more CPU power and memory, on the router, because more information is shared.

  • Tend to be faster in reacting to changes in the network than distance vector protocols.

Metrics

Example

  • A router's route table contains the best route to each destination network it knows about.

  • If a router using a dynamic routing protocol learns two different routes to the same destination, it uses the metric value of the routes to determine which is best.

  • A lower metric is considered better (like the root cost in spanning tree).

  • The route with the lowest metric is considered best and will be entered in to the routing table.

  • Each routing protocol uses a different metric to determine which route is the best.

![[dynamic metric example.png]]

  • Here, R1 learns two paths to 192.168.4.0/24, one via R2 and one via R3, but only the route via R2 is added to the routing table.

  • This fastethernet connection here has a higher metric cost than the other gigabit connections, so this route is less favorable.

  • If R3->R4 was also a gigabit ethernet connection, both routes would have the same cost, so both routes would've been added to the table.

So, if a router learns two or more routes via the same routing protocol to the same destination, with the same metric, both will be added to the routing table. Traffic will be load-balanced over both routes.

This is called Equal Cost MultiPath, or ECMP, load-balancing.

Note :

They must be exactly the same destination, the same network address and same prefix length.

  • In the output of 'show ip route', the metric value is displayed (second in the square bracket in the route).

  • The first value in the square bracket is Administrative Distance (AD). OSPF protocol has an AD of 110.

You can do the same with static routes also.

  • Configure two static routes to 192.168.4.0, one via R2 and one via R3.

  • Both are added to the routing table, and traffic will be load-balanced over both routes.

  • Both routes have a metric of 0 (static routes don't use 'metric' concept).

  • AD value of static routes is 1.

Summary

Purpose : To let the router select the best route to the destination, but some routing protocols might make better decisions than others.

  • RIP : Hop count

    • Each router in the path to the destination counts as one ‘hop’.

    • Total metric is the total number of hops to reach the destination.

    • (downside) Links of all speeds are equal. A 10 megabit and 10 gigabit link are each considered as 1 hop.

  • EIGRP : metric based on Bandwidth & Delay

    • You can configure other factors that can be added to the calculation.

    • Only the bandwidth of the SLOWEST link in the route is used to calculate the metric.

    • But the total delay values of all links in the path are used.

    • (misleading) By default delay is a value assigned to the interface based on its bandwidth.

  • OSPF : Cost

    • The cost of each link is calculated based on the bandwidth.

    • Total bandwidth of the links in the route make up the metric of the route.

    • Better than RIP’s which doesn’t take into account link speed.

  • IS-IS : Cost

    • Cost of each link is not automatically calculated based on bandwidth.

    • All links have a cost of 10 by default. Without any configuration, it functions the same as RIP, being a simple hop count metric.

![[dynamic routing metrics.png]]

From R1 to R4,

RIP :

  • Via R2, the hop count is 2 (one hop to R2, one hop to R4).

  • Via R3, the hop count is also 2 (one hop to R3, one hop to R4), even though the connection from R3 to R4 is a slower fastethernet connection.

  • Both routes will be put into R1’s route table.

  • R1 will load balance traffic using both routes, even though one route is slower.

OSPF :

  • OSPF’s metric cost does take into account bandwidth.

  • So, the slower connection between R3 and R4 will result in a higher metric value, making it less favorable.

  • So, only the route via R2 will be entered into the route table.

  • R1 will send all traffic destined to the 192.168.4.0/24 network via R2.

Administrative Distance

  • In most cases a company will only use a single IGP for their network – usually OSPF, sometimes they use EIGRP if they only use Cisco equipment.

  • In some rare cases they might use two. For example, if two companies connect their networks to share information, two different routing protocols might be in use.

  • Metric, which I just showed you, is used to compare routes learned via the same routing protocol.

  • Different routing protocols use totally different metrics, so they cannot be compared.

  • For example, an OSPF route to 192.168.4.0/24 might have a metric of 30, while an EIGRP route might have a metric of 33280.

  • Which route should the router put in the route table can not be answered by looking at the metrics, because OSPF and EIGRP use totally different metrics.

Administrative distance(AD) is used to determine which routing protocol will be added to the routing table.

  • A lower AD is preferred, and indicates that the routing protocol is considered more trustworthy (more likely to select good routes).

  • RIP’s hop count-based metric system is not very good, so it has a high AD (it says two routes are equal because they have the same hop count, but one route is much worse because of lower bandwidth).

Protocol / TypeAD

Directly connected

0

Static

1

External BGP (eBGP)

20

EIGRP

90

IGRP

100

OSPF

110

IS-IS

115

RIP

120

EIGRP (external)

170

Internal BGP (iBGP)

200

Unusable route

255

  • If the administrative distance is 255, the router does not believe the source of that route and does not install the route in the routing table.

  • The connected and local routes in the routing table have an AD of 0.

  • Of the IGPs, which are RIP, EIGRP, OSPF, and IS-IS, EIGRP is the most preferred.

Before comparing metrics, AD is used to select the best route.

  • You can change the AD of a routing protocol. Say, you want OSPF routes to be preferred over EIGRP routes.

Floating static routes

R1(config)# ip route desintation subnet-mask next-hop distance-metric (AD)

  • You can also change the AD of a static route.

  • By changing (increasing) the AD of a static route, you can make it less preferred than routes learned by a dynamic routing protocol to the same destination.

  • The route will be inactive (won’t be in the routing table), unless the route learned by the dynamic routing protocol is removed (interface failure causes an adjacency with a neighbor to be lost).

Static routes can be made to function as a backup route by making the AD higher, since static routes by default have an AD of 1 (lower than any dynamic routing protocol).

![[floating static routes.png]]

  • Consider PC1 reaches SRV1 through the path learned via OSPF (via R1 & R2).

  • Configure static routes on R1 & R2 to SPR1 & SPR2 with a higher AD than OSPF (>110), so that the path via SPR1 & SPR2 acts as a backup route to OSPF.

  • Now when the route via R1 & R2 is shutdown, the data takes the path configured by static routes.

Quiz

![[dynamic routing quiz.png]]

  • The routes are destined to four different destinations (because they have different prefix lengths).

  • If destination matches multiple entries in the routing table, the router uses the route with the most specific match (longest prefix) [[Static routing#Note]]

When a packet is sent to a router, it checks the routing table to see whether the next-hop address for the destination network is known. If multiple routes to a destination are known, the most specific route is used.

Lab

Loopback interfaces

  • Similar to the SVIs on a Layer 3 switch, these loopback interface are not physical interfaces, but virtual interfaces inside of the router.

  • One use of loopback interfaces is to simulate remote destination networks without actually having to set them up in the lab.

Trace route

  • traceroute destination IP address

  • 'tracert' in Windows, 'traceroute' in Cisco IOS.

  • In a real network you can’t just turn on simulation mode like in packet tracer to see the path traffic takes.

  • It’s like a ping, except every Layer 3 ‘hop’ along the route to the destination sends a message back to the source.

  • This is a very useful tool for troubleshooting and making sure traffic is following the intended path.

Serial interface

  • DCE is a concept in serial connections. One side is DCE, the other side is DTE.

  • DCE side has to set the clock rate.

  • Router(config-if)# clock rate speed in bps

Last updated