cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1035
Views
0
Helpful
7
Replies

OSPF OR Static Route

saurabh.bansal
Level 1
Level 1

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?

7 Replies 7

milan.kulik
Level 10
Level 10

Hi,

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

BR,

Milan

Pavel Bykov
Level 5
Level 5

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 7.7.7.7 255.255.255.255 10.0.0.2 111

SW1(config)#do sh ip route

7.0.0.0/32 is subnetted, 1 subnets

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

SW1(config)#ip route 7.7.7.7 255.255.255.255 10.0.0.2 110

SW1(config)#do sh ip route

7.0.0.0/32 is subnetted, 1 subnets

S 7.7.7.7 [110/0] via 10.0.0.2

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

http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094823.shtml

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

BR,

Milan

pavelsh_ucs
Level 1
Level 1

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
Level 7
Level 7

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.

HTH

Mohamed

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 :-(

BR,

Milan

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 1.1.1.0/32 is a different route than 1.1.1.0/31 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.

Review Cisco Networking for a $25 gift card