Saturday, February 14, 2009

How Router makes a routing decision :-)

"CLICK ON IMAGE TO ENLARGE"
So...today we gonna discuss in brief about how router makes a routing decision for the same destination subnets while running two different routing protocols togather. This article is very much dedicated to CCNA, CCNP people. The reason is ....hmmm....they never been taught about the right way. Reason could be like we need not to get into that much depth about advance routing decisions at initial and professional level. Anyways....I learned this when I started preparing for my CCIE around an year back.
So next time if someone ask ...hey if I have two routers running EIGRP and OSPF both, which routing protocol will indeed used to exchange routes and to send data ? Typical answer would be - EIGRP...cause it's AD is 90 where as OSPF AD is 110...so EIGRP will be the winner :)
Nooooo...but may be Yes too :) , just ask them for configuration first
Let me explain step by step approach of router while making routing decisions in such situation:
1.) Check for the longest prefix match....just look into the Diagram...in short EIGRP 1 process is enabled on R1's interfaces f0/0 & s0/0 & On R2 the EIGRP 1 process is enabled on interfaces f0/0 & s0/0 too. Also I have configured OSPF 1 routing process on R1's f0/0 & so/1, R2's f0/0 & s0/1, R3's s0/0 & s0/1.
Now most people will say that the traffic originated from R1's ethernet subnet will exit through R1's interface s0/0 because it's running EIGRP and as we know AD of EIGRP is 90 so it will take preference over OSPF AD 110. But in actual it's moreover dependent on your routing protocol configuration. So lets hop on to configuration :-)
R1(config)#do sh run be router
router eigrp 1
network 3.3.3.1 0.0.0.0
network 10.0.0.1 0.0.0.0
auto-summary
!
router ospf 1
log-adjacency-changes
network 1.1.1.1 0.0.0.0 area 0
network 10.0.0.1 0.0.0.0 area 0
!
R2#sh run be router
router eigrp 1
network 3.3.3.2 0.0.0.0
network 20.0.0.1 0.0.0.0
auto-summary
!
router ospf 1
log-adjacency-changes
network 2.2.2.2 0.0.0.0 area 0
network 20.0.0.1 0.0.0.0 area 0
!
R3#sh run be router
router ospf 1
log-adjacency-changes
network 1.1.1.2 0.0.0.0 area 0
network 2.2.2.1 0.0.0.0 area 0
!
Now let's take a look at the routing table
R1(config)#do sh ip route
Gateway of last resort is not set
1.0.0.0/30 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Serial0/1
2.0.0.0/30 is subnetted, 1 subnets
O 2.2.2.0 [110/128] via 1.1.1.2, 00:01:21, Serial0/1
3.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 3.3.3.0/30 is directly connected, Serial0/0
D 3.0.0.0/8 is a summary, 00:04:19, Null0
20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O 20.0.0.0/24 [110/138] via 1.1.1.2, 00:01:21, Serial0/1
D 20.0.0.0/8 [90/2195456] via 3.3.3.2, 00:04:19, Serial0/0
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.0.0/24 is directly connected, FastEthernet0/0
D 10.0.0.0/8 is a summary, 00:04:19, Null0
Oops...We are learning R2's 20.0.0.x network through both routing protocols :-(
So whats next....
But if we take a closer look we can see the difference. Through EIGRP we are learning 20.0.0.0 network with /8 prefix length. While on the other hand through OSPF we are learning the same destination network with /24 prefix length. So if you remember EIGRP by default summarize advertised networks to their default class mask while there is no default summarization behavior in OSPF so it advertises the network with proper mask.
But we still have both entries from both protocols in routing table so which one will take precedence ?
Answer: The routing protocol which is providing more accurate route to routing table then other one..which in our case is OSPF with /24 prefix length :-)
So lets test it out....I am going to run a ping test after enabling Debug ip packet command to see which interface icmp packets will choose to reach destination
here we go...
R1(config)#do ping 20.0.0.1 source 10.0.0.1
*Mar 1 00:07:19.647: IP: tableid=0, s=10.0.0.1 (local), d=20.0.0.1 (Serial0/1), routed via FIB*Mar 1 00:07:19.647: IP: s=10.0.0.1 (local), d=20.0.0.1 (Serial0/1), len 100, sending
*Mar 1 00:07:20.467: IP: tableid=0, s=20.0.0.1 (Serial0/0), d=10.0.0.1 (FastEthernet0/0), routed via RIB
*Mar 1 00:07:20.467: IP: s=20.0.0.1 (Serial0/0), d=10.0.0.1, len 100, rcvd 4
*Mar 1 00:07:20.471: IP: tableid=0, s=10.0.0.1 (local), d=20.0.0.1 (Serial0/1), routed via FIB
*Mar 1 00:07:20.471: IP: s=10.0.0.1 (local), d=20.0.0.1 (Serial0/1), len 100, sending
*Mar 1 00:07:20.611: IP: tableid=0, s=20.0.0.1 (Serial0/0), d=10.0.0.1 (FastEthernet0/0), routed via RIB
*Mar 1 00:07:20.611: IP: s=20.0.0.1 (Serial0/0), d=10.0.0.1, len 100, rcvd 4
*Mar 1 00:07:20.615: IP: tableid=0, s=10.0.0.1 (local), d=20.0.0.1 (Serial0/1), routed via FIB!!!
So now you can see that icmp packets are choosing R1's interface s0/1 as exit interface to reach the destination.
But lets say I want EIGRP to Win this race....hmmm...actually there are many ways to achieve this...let me show you my preferred way for this situation.

Lets turn auto-summarization off in EIGRP,because as soon as we will do that, EIGRP will also advertise the 20.0.0.0 network with /24 prefix length. Also remember that in such situation where both routing protocols will have same prefix length for a given destination; AD will take precedence and only routes with lower AD will end up into the routing table. If AD is also same <> than next preference will be lower metric and in last if all matches than traffic will be load balanced equally.
So lets turn off the auto-summarization on both R1 & R2
R1#sh run be router
router eigrp 1
network 3.3.3.1 0.0.0.0
network 10.0.0.1 0.0.0.0
no auto-summary
!
R2(config)#do sh run be router
router eigrp 1
network 3.3.3.2 0.0.0.0
network 20.0.0.1 0.0.0.0
no auto-summary
!
Now lets again take a look at routing table and see no ospf routes are there in routing table:
R1#sh ip route
1.0.0.0/30 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Serial0/1
2.0.0.0/30 is subnetted, 1 subnets
O 2.2.2.0 [110/128] via 1.1.1.2, 00:01:06, Serial0/1
3.0.0.0/30 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Serial0/0
20.0.0.0/24 is subnetted, 1 subnets
D 20.0.0.0 [90/2195456] via 3.3.3.2, 00:01:06, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, FastEthernet0/0
:)
Deepak Arora
CCIE#2xxxx....Oops that number is still missing :)

No comments: