cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4574
Views
7
Helpful
10
Replies

Intra area routes metric preference in OSPF

Kishore Chennupati
Rising star
Rising star

Hi All,

I have 2 routers as below. They run ospf. Now I have advertised a couple of loopbacks from R3 into ospf.  20.1.1.1 and 10.1.1.1.

What I want to do is to assign a different metric say 20 only to 10.1.1.1. How can i achieve this? The routers are in the same area.

How can I make the change on R3 or R2?. I am happy with either one. I dont want to use the cost on the interface as it will change the metric for all the routes. Currently the metric is 2 as you can see from below output

R2-------R3

R2#sh ip route

     20.0.0.0/32 is subnetted, 1 subnets

O       20.1.1.1 [110/2] via 192.168.1.3, 00:00:01, GigabitEthernet1/0

     10.0.0.0/32 is subnetted, 1 subnets

O       10.1.1.1 [110/2] via 192.168.1.3, 00:00:01, GigabitEthernet1/0

C    192.168.1.0/24 is directly connected, GigabitEthernet1/0

R2#

3 Accepted Solutions

Accepted Solutions

Change the ospf cost under specific loopback interface.

Regards

XieYao

View solution in original post

Peter Paluch
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

Hello Kishore,

Link-state protocols generally don't allow you the luxury of manipulating individual prefixes because they are not at the core of what link-state protocols communicate between routers. In these protocols, the core element is the link, i.e. an interconnection of a router to a network object. The cost is tied to this link, and if there is an IP network on this link, then the cost is derived from it. All you can do in intra-area application is to modify the cost of this link (i.e. interface), but as you noted yourself, this action will also modify the metric of routes reachable through that link (interface). So your options here are really limited. I am not sure if there is any way you could access the metric of an intra-area prefix while not touching the cost of the interface on which the prefix is configured. I surely do not know of any.

You'd need to force the link-state protocol start working like a distance-vector to get access to individual prefixes. So in your case, one of the easiest ways to accomplish this would actually be to redistribute the connected loopbacks into OSPF, using metric type 1 and setting its initial value depending on the prefix. Redistributing networks into OSPF rather than having them injected as internal networks has its drawbacks, though, and is not universally usable. But as an exercise, this might do the trick.

Best regards,

Peter

View solution in original post

Hello Kishore,

what Xie has suggested is the only viable option for differentiating metric for only selected intra area routes in OSPF.

Because OSPF is link state, there is no chance to use a concept like an offset-list to selectively modify the cost of a few of intra area routes:  link state database must be identical in all routers that belong to the same area, so any change to the cost between routers would impact all routes.

In practice, the use of different cost on the VLan client side allows to differentiate the return path to a selected subset of routes, for example by making lower the cost on the HSRP master device for the subnet if there is the need for symmetrical paths.

Hope to help

Giuseppe

View solution in original post

10 Replies 10

tobyarnett
Beginner
Beginner

Kishore,

When you use OSPF the meteoric is a calculation based off of the bandwidth. So your options would be to change the default cost in the routing process, manually assign a cost in the interface, or change the bandwidth statement on the interface. This will give you three different methods to achieve your goals.

The way I see this best is to use the "IP ospf cost" command in interface configuration mode. This command will override the default cost value on the specific interface.

Toby


Sent from Cisco Technical Support Android App

-Toby


Please don't forget to rate any helpful post.

_____________________________________
There are no great limits to growth because there are no limits of human intelligence, imagination, and wonder.
- Ronald Reagan

Toby,

As I mentioned in my original post, I dont want to use the interface cost as that will affect the metric for all the routes. I only want to change the metric for specific routes

Thanks

Change the ospf cost under specific loopback interface.

Regards

XieYao

Hi Xie,

good point. but what if they were learned from some where else. The thing i want to know is how do we change the cost of intra are routes between say 2 routers like in the orginal post

Anyone else who can assist here please?

Peter Paluch
Hall of Fame Cisco Employee Hall of Fame Cisco Employee
Hall of Fame Cisco Employee

Hello Kishore,

Link-state protocols generally don't allow you the luxury of manipulating individual prefixes because they are not at the core of what link-state protocols communicate between routers. In these protocols, the core element is the link, i.e. an interconnection of a router to a network object. The cost is tied to this link, and if there is an IP network on this link, then the cost is derived from it. All you can do in intra-area application is to modify the cost of this link (i.e. interface), but as you noted yourself, this action will also modify the metric of routes reachable through that link (interface). So your options here are really limited. I am not sure if there is any way you could access the metric of an intra-area prefix while not touching the cost of the interface on which the prefix is configured. I surely do not know of any.

You'd need to force the link-state protocol start working like a distance-vector to get access to individual prefixes. So in your case, one of the easiest ways to accomplish this would actually be to redistribute the connected loopbacks into OSPF, using metric type 1 and setting its initial value depending on the prefix. Redistributing networks into OSPF rather than having them injected as internal networks has its drawbacks, though, and is not universally usable. But as an exercise, this might do the trick.

Best regards,

Peter

Hi Peter,

Thanks for you reply. Appreciate your input anyday. I have just given a simple example here. But below is my actual scenario.

So lets say the network is something like this. The ospf area is say 0.

   BGP      OSPF     OSPF     OSPF    BGP

R0--------R1-----------R2--------R3---------R4---------R5

On R1,the routes from BGP get redistributed into OSPF using a type E1 and metric 30. The same thing happens on R4 but with a metric of 10 for the same BGP routes.  Therefore R2 prefers the route via R3 as it has a lower cost. However, I want to change that i.e I want R2 to go via R1 without changing the metrics on R1 or R4.

Is this possible. How can i achieve this if its doable?

Regards, Kishore

Hello Kishore,

what Xie has suggested is the only viable option for differentiating metric for only selected intra area routes in OSPF.

Because OSPF is link state, there is no chance to use a concept like an offset-list to selectively modify the cost of a few of intra area routes:  link state database must be identical in all routers that belong to the same area, so any change to the cost between routers would impact all routes.

In practice, the use of different cost on the VLan client side allows to differentiate the return path to a selected subset of routes, for example by making lower the cost on the HSRP master device for the subnet if there is the need for symmetrical paths.

Hope to help

Giuseppe

Hi Guiseppe,

Thanks heaps for the reply. Hope you are well. So based on my scenario above(Reply to Peter's post) , what could be the recommended solution?

I dont have any loopbacks etc. That was just for a simple example. The real example is what I posted in reply to Peter's post.

Thanks in advance :-)

Regards, Kishore

Hello Kishore,

in the scenario with multiple exit points to BGP network the best move is to use O E1 external route type. Because the internal path to ASBR/Forwarding address is added to seed metric.

At this point you need to choice two seed metric so that the difference between the two seed metric makes R2 to prefer R1 as exit point.

In real world you are likely to use a non default reference bandwidth so this is also to be taken in account to accomodate GE or 10Ge links.

In your example is enough to use seed metric 10 and 11 for example to achieve the desired result with default settings.

Hope to help

Giuseppe

Kishore,

I think there have been enough people here that are stating the same basic principles for how to resolve your issue. I believe your hesitance is with the command:

router ospf xx

auto-cost reference bandwidth xxxx

This command will affect all interfaces all routes. However you can use the command below to affect only the routes out of a specific interface.

interface GIg0/1

ip ospf cost xxxx

If you don't use either of these you can equally change the bandwidth metric on the interface (which gives the same basic result as the ip ospf cost statement.

Alternately you can do a residribute static or redistribute connected command. Any time your redistribute a route into OSPF it becomes an Intra area route versus an Inter area route.

I think you can get the results you want best by applying the ip ospf cost statement at the interface and adjusting the metric to the desired level to prefer the interface or not.

Other than the statements above there is not much more your going to be able to do in OSPF unless you want to use policy based routing and make your configurations a lot more difficult than they probably should be.

-Toby

Please remember to rate any helpful posts.

-Toby


Please don't forget to rate any helpful post.

_____________________________________
There are no great limits to growth because there are no limits of human intelligence, imagination, and wonder.
- Ronald Reagan