OSPF OR Static Route

Unanswered Question
Jul 16th, 2009

Hi Team,

I have a query if i have 2 routes to the same destination one is learned via ospf and another one is via static route with AD-110.Which route will be used for forwarding the data packet and why?

I have this problem too.
0 votes
  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
milan.kulik Thu, 07/16/2009 - 04:26


IMHO, static route will be used for forwarding, as it will get metric=0, even while the same AD.



Pavel Bykov Thu, 07/16/2009 - 04:42

Actually metric shouldn't matter, as it serves as comparison between routes within routing protocol. Routing table bases it's primary decision on a routing table.

Note, you cannot change metric of a static route.

Static will be preferred, i think because of internal mechanisms:

SW1(config)#ip route 111

SW1(config)#do sh ip route is subnetted, 1 subnets

O [110/2] via, 00:00:05, FastEthernet0/16

SW1(config)#ip route 110

SW1(config)#do sh ip route is subnetted, 1 subnets

S [110/0] via

milan.kulik Thu, 07/16/2009 - 05:01

Yes, I agree you cannot change metric of a static route - it's always 0.

I also agree metric should be used to compare only routes within one routing protocol table.

I know setting OSPF and static the same AD is incorrect and is not included in Cisco Routing Path selection algorithm


But what makes the router to chose the static route in this case?



pavelsh_ucs Thu, 07/16/2009 - 06:03

static route has administrative distance 1. OSPF has administrative distance 0.

So cisco prefer static route because it have smaller administrative distance.

Metrics are compared after administrative distance comparison.

Mohamed Sobair Thu, 07/16/2009 - 12:23

Hi Guys,

The router select the path to a particular destination based on the following characterstics:

1- The longest lenth of the Network is always prefered first.

2- The lowest Administrative distance is Secondly prefered.

3- If there is a tie, then the Lowest metric is prefered.

4- If there is a tie, then the router performs equal cost load-sharing.



milan.kulik Thu, 07/16/2009 - 12:54

Hi Mohamed,

I was thinking so, but Pavlo corrected me.

Let's say you assign the same Administrative distance to OSPF and EIGRP. Would it make sense to compare metrics?

Probably not.

There is another rule probably in IOS.

I guess the rule might be:

If two routing protocols are having the same AD assigned by the configurator mistake, the protocol with lower default AD wins.

(Thus static wins over OSPF in a case both having the same AD assigned, as I've seen in my lab.)

But I have not found any Cisco document confirming this idea :-(



Pavel Bykov Mon, 07/20/2009 - 00:17

Pavel, that is not what we are talking about, and you are wrong about distances. OSPF does not have AD of 0.

Mohamed, that is just basic rules what you are describing.

Here is the actual process of installing route to the routing table:

1. Routing protocol tries to install a new route into RIB.

2. RIB checks if that route is already present in the routing table. (route here being a combination of network and prefix, therefore is a different route than and are considered separately)

3. If it is not, it installs the route.

4. If it is already present, it asks the previous owner, to decide if the new route should be installed or not.

5. The old owner decides, if it will allow installation of new route or not, based on AD and or other internal mechanisms.

So you see, routing table itself is a passive mechanism and does not have a direct say in this. In our case, there is a static route, that tries to install itself in the routing table. RIB passes this route to the OSPF process and asks for the result.

OSPF does it's comparisons and for some reason prefers static over it's own route - this may be IOS OSPF implementation specific thing.


This Discussion