Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Routing prefer more specific route

 

Hi all,

 

I have a question on how the routier will choose the most longest match/ specific route.

Some books say router will alway choose the longest match first.

Next, it say if it has multiple longest matches from different protocols, it will choose the lowest AD

                   if it has multiple longest matches from same protocols, it will choose the lowest metric

 

I try to use GNS3 to simulated that change. But it seemed not to work well. In this test, i use 4 routers.

All routers are running both EIGRP and OSPF protocols.

Router A have a route to Router B nd Router C.

Router B and C have an route each to Router D,

 

A     > B     > D

       > C

 

In early stage, all subnets advertise by EIGRP and OSPF are /24. The router will choose EIGRP because it has lowest AD.

But if i changes the OSPF subnets advertise by Router A to be more specific, EIGRP seemed to always be the one more prefer that OSPF.

 

My Config

router eigrp 1
 network 10.0.0.2 255.255.255.0
 network 192.168.0.0 255.255.255.0
 no auto-summary
!
router ospf 1
 log-adjacency-changes
 network 10.0.0.2 0.0.0.15 area 0
 network 192.168.1.2 0.0.0.15 area 0

R1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 1 subnets
D       172.16.0.0 [90/332800] via 10.0.0.3, 00:00:48, FastEthernet0/1
     172.32.0.0/24 is subnetted, 1 subnets
D       172.32.0.0 [90/307200] via 10.0.0.3, 00:00:49, FastEthernet0/1
     10.0.0.0/24 is subnetted, 1 subnets
C       10.0.0.0 is directly connected, FastEthernet0/1
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R1#

Do i misunderstand that lonest match theory or do i mis-configure my router?

 

 

 

 

 

5 REPLIES
Cisco Employee

Kian,Can you better explain

Kian,

Can you better explain the issue?. Did I understood that you changed "network 192.168.1.2 0.0.0.15 rea 0" from "network 192.168.1.0 0.0.0.255 area 0"?.

 

If so, it wont influence anything. network command enabled as part of EIGRP/OSPF is only to enable the respective interface. But it doesnt advertise with subnet otehr than the one configured in the interface.

If the above understanding on your problem is different, please let us know.

 

-Nagendra

New Member

Hi Nagendra, It is not an

Hi Nagendra,

 

It is not an issue. I am just trying to test whether if the above theory is correct or not.

Yes. I have changed the network from network 192.168.1.0 0.0.0.255 area 0" to "network 192.168.1.2 0.0.0.15 area 0". So it won't works influence anything.

I have tried changing the AD of the OSPF route and it did works.

How to influence the route for OSPF to take precedence over EIGRP using the longest match theory in this case besides changing the AD?

Cisco Employee

Hi Kian,You basically need to

Hi Kian,

You basically need to receive prefix with longer mask from one protocol while lesser mask on other. Incase of single area you may not be able to do it. But with EIGRP, you cn try summary-address under advertising interface.

For example, if you have A---B---C running both ospf and eigrp and if c.c.c.c/24 is a prefx advertised by c (via both protocl), configure "ip summary-address eigrp <> c.0.0.0 255.0.0.0" under interface towards A on B.

 

You can see it advertise with mask as 8 while ospf advertise c.c.c.0/24 and will be preferred (hile u will see c0.0.0./8 in your RIB).

 

-Nagendra

New Member

Hi Nagendra,

Hi Nagendra, So it means that we are not able to configure on OSPF single or multiple areas directly to influence the route. But we can influence other protocol like EIGRP to show that theory? But the example show the longest match is /24 which is OSPF. It should show that OSPF as the prefer route?
Purple

Hi,AD is used when 2 equal

Hi,

AD is used when 2 equal length prefixes are advertised by 2 different sources and lower AD will get installed in RIB.

metric is used when 2 equal length prefixes are advertised by same source and lowest metric will get installed in RIB.

if 2 different prefixes are advertised either by same source or different sources then they will both be installed in RIB.

Now when the router needs to forward traffic for some destination it will look in its RIB and will choose the longest match prefix.

So at this point the router doesn't care about the source or the metric just about the longest match.

You can test this simply by using a static host route(/32) for some destination that you have lesser length in RIB already via any other routing protocol and you will see it will use the /32 route as it is the longest match.

 

Regards

 

Alain

Don't forget to rate helpful posts.
191
Views
0
Helpful
5
Replies