Showing results for 
Search instead for 
Did you mean: 

Modify Cost of OSPF Route using route map and Distribute List

Hi all,

First time poster here. Hoping to benefit from your insight.

I have a test environment with a hub and spoke architecture using OSPF as the routing protocol. Each spoke and the hub connect to each other over two simulated service provider WANs with the traffic being load balanced over the two.  

What I want to be able to do is to set the cost of routes being learned by the hub from only one location over a specific interface to a higher cost without changing/ impacting the routing from the hub standpoint to other locations. The config below is how I have sought to do this. However, the routes are still being installed on the hub router with the default costs. I'm testing this in GNS3 using the C7200 image.

What am I missing? 



R2#show run | sec route-map
route-map INCREASE permit 10
match ip address prefix-list MYNET

match interface GigabitEthernet2/0
set metric 100
route-map INCREASE permit 20


R2#show ip prefix-list
ip prefix-list MYNET: 1 entries
seq 5 permit


R2#show run | sec router
router ospf 10
network area 0
network area 0
network area 0
distribute-list route-map INCREASE in


R2#show ip route
Codes: L - local, 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, H - NHRP, l - LISP
+ - replicated route, % - next hop override

Gateway of last resort is not set

C is directly connected, GigabitEthernet2/0
L is directly connected, GigabitEthernet2/0
C is directly connected, GigabitEthernet1/0
L is directly connected, GigabitEthernet1/0
O [110/2] via, 00:00:02, GigabitEthernet1/0 
                        [110/2] via, 01:01:31, GigabitEthernet2/0<---- the route I want to modifiy is variably subnetted, 2 subnets, 2 masks
C is directly connected, GigabitEthernet3/0
L is directly connected, GigabitEthernet3/0

1 Accepted Solution

Accepted Solutions

Hello ,

PBR you can use the following to check the availibility of next/hop if next hop is not reachable standard destination routing is used

set ip next-hop address

set ip next-hop verify-availability


Hope to help



View solution in original post

12 Replies 12

MHM Cisco World
VIP Mentor VIP Mentor
VIP Mentor

Can you draw the topology

Topology attached.

Tyson Joachims
Rising star
Rising star

I was able to increase the cost of the route in my test lab using all the same configurations you used. It is also strange that the routing table on R2 shows the network without the CIDR. Can you please provide the output from the following command on R2?

show ip ospf rib

I try and also same result couldn't change Cost for specific prefix,
I use GNS3 use image 7200.
which image you use ?

I used the same image as you did, 7200.


Could it be a bug within GNS 3?

Here's the output of the command requested below.


Base Topology (MTID 0)

OSPF local RIB
Codes: * - Best, > - Installed in global RIB

*, Intra, cost 1, area 0, Connected
via, GigabitEthernet2/0
*, Intra, cost 1, area 0, Connected
via, GigabitEthernet1/0
*>, Intra, cost 2, area 0
via, GigabitEthernet1/0
via, GigabitEthernet2/0
*, Intra, cost 1, area 0, Connected
via, GigabitEthernet3/0

Giuseppe Larosa
Hall of Fame Master Hall of Fame Master
Hall of Fame Master


try the following:

clear ip ospf proc


However, OSPF is a link state protocol so the changes are not effective on the LSA and they are local to the node where the distribution list is configured


Hope to help


Hi Guiseppe,


I tried clearing the ospf process before but unfortunately it didn't work. I am also aware that the change will not propagate to neighbouring routers. Thanks for the reminder.

Hello @vaughanreese_jones ,

in a real world network I would use PBR to achieve the desired result instead of attempting to tweak OSPF that is not so easy for its link state nature.


Hope to help



 @Giuseppe Larosa 


I thought about that. My issue though is that if the link goes down there wouldn't be a dynamic which over to the available link.

This is why I want to adjust the cost so that in the even of failure it will dynamically use the next available route.