cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
12129
Views
19
Helpful
22
Replies

Prefer a route learned via OSPF rather than BGP

graham smart
Level 1
Level 1

Hi All,

I learning a route via BGP and OSPF ( via two separate links )

I cant figure out the "best" way to configure the router to prefer the route via OSPF over BGP and if OSPF link fails, it would then use the BGP route.

Its currently learned via BGP

     199.199.199.0/32 is subnetted, 1 subnets
B       199.199.199.199 [20/0] via 12.0.0.1, 00:07:19

 

Routing entry for 199.199.199.199/32
  Known via "bgp 1001", distance 20, metric 0
  Tag 1000, type external
  Last update from 12.0.0.1 00:07:46 ago
  Routing Descriptor Blocks:
  * 12.0.0.1, from 12.0.0.1, 00:07:46 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 1000

 

 

When BGP is down, Its learned like this:

R5#sh ip route 199.199.199.199
Routing entry for 199.199.199.199/32
  Known via "ospf 1", distance 110, metric 1
  Tag 64512, type extern 2, forward metric 2
  Last update from 14.0.0.1 on FastEthernet0/1, 00:00:08 ago
  Routing Descriptor Blocks:
  * 14.0.0.1, from 14.0.0.1, 00:00:08 ago, via FastEthernet0/1
      Route metric is 1, traffic share count is 1
      Route tag 64512

 

 

 

Any help would be great.

Thanks

G

-Graham
Please note: My comments are simply suggestions. I cannot be held liable for any loss of data, life or marbles due to following my instructions.

Got a website? Need some live chat software?

22 Replies 22

Hi Thanks for your update.

With regards to changing stuff on other routers, I don't think this is practical.

It seems that whatever must be done to prefer ospf for this route must be done on R5.

 

Im starting to think that this isnt even possible ( Other than prefering ALL ospf over bgp as this works , but not really what is wanted. )

 

-Graham
Please note: My comments are simply suggestions. I cannot be held liable for any loss of data, life or marbles due to following my instructions.

Got a website? Need some live chat software?

Oh wait,

Hang on.

 

Ive put the 13.0.0.0 subnet in the ACL and now to lower the 13 subnet to 19.. and now its working.

Wooooooooooooooooooooooo   Thanks :)

R5#sh 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

     199.199.199.0/32 is subnetted, 1 subnets
O E2    199.199.199.199 [19/1] via 14.0.0.1, 00:29:08, FastEthernet0/1
     172.200.0.0/32 is subnetted, 2 subnets
B       172.200.0.4 [20/0] via 12.0.0.1, 00:28:42
B       172.200.0.2 [20/0] via 12.0.0.1, 00:28:42
     188.188.0.0/32 is subnetted, 1 subnets
C       188.188.188.188 is directly connected, Loopback1
     10.0.0.0/30 is subnetted, 3 subnets
B       10.0.0.8 [20/0] via 12.0.0.1, 00:28:42
B       10.0.0.12 [20/0] via 12.0.0.1, 00:28:42
B       10.0.0.0 [20/0] via 12.0.0.1, 00:28:44
     89.0.0.0/24 is subnetted, 1 subnets
B       89.0.0.0 [20/0] via 12.0.0.1, 00:15:10
     12.0.0.0/30 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, FastEthernet0/0
     13.0.0.0/30 is subnetted, 1 subnets
O       13.0.0.0 [19/2] via 14.0.0.1, 00:29:15, FastEthernet0/1
     14.0.0.0/30 is subnetted, 1 subnets
C       14.0.0.0 is directly connected, FastEthernet0/1

-Graham
Please note: My comments are simply suggestions. I cannot be held liable for any loss of data, life or marbles due to following my instructions.

Got a website? Need some live chat software?

Hello

5+  rating reply Rolf!

res

Paul


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

Hello

I would personally  use the bgp backdoor option instead of manipulating the distance metric of bgp itself.

This would advertise 199.199.199.199 in bgp as  local route thus increasing its metric to 200.and giving preference to OSPF as metric 110

 

On the router receiving this route

router bgp xx
network 199.199.199.199 mask 255.255.255.255 backdoor
exit

 

res

Paul


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

Thanks,

 

I tried this before, I see its increased the distance to 200, Yet the route still appears in teh routing table as "best" ?

Also, wont I have problems re-advertising the 199.199.199.199 route to the network behind this router? ( As backdoor doesnt re-advertise? )

Routing entry for 199.199.199.199/32
  Known via "bgp 1001", distance 200, metric 0
  Tag 1000, type locally generated
  Last update from 12.0.0.1 00:00:13 ago
  Routing Descriptor Blocks:
  * 12.0.0.1, from 12.0.0.1, 00:00:13 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 1000

 

R5#sh ip route | inc 199.199
     199.199.199.0/32 is subnetted, 1 subnets
B       199.199.199.199 [200/0] via 12.0.0.1, 00:00:58

 

Am I missing something?

 

OSPF is 100% advertising it to me.

R5#sh ip ospf database | inc 199.199
199.199.199.199 14.0.0.1        112         0x80000007 0x001D57 64512

 

 

Thanks

G

 

-Graham
Please note: My comments are simply suggestions. I cannot be held liable for any loss of data, life or marbles due to following my instructions.

Got a website? Need some live chat software?

Hello

Just to confirm, The receiving router has two paths to this route:

1) via BGP = metric 20
2) via ospf -  metric = 110

 

Now on the RECEIVING router for this route you've applied the backdoor command to bgp - correct?

res

Paul


 



 


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

That is correct.

 

Details below of backdoor command. It clearly changes the distance for BGP to 200 but doesnt seem to let ospf take the route.

Is there no other method to force a router to use one path over another?

If i change OSPF's AD to 201, OSPF's route appears instead of BGP.

I suppose the problem is that I dont want to change the whole AD of a routing protocol. 

I have tried with a route-map inbound to somehow change the weight etc but cant seem to get it working either.

 

R5#show ip route 199.199.199.199
Routing entry for 199.199.199.199/32
  Known via "bgp 1001", distance 20, metric 0
  Tag 1000, type external
  Last update from 12.0.0.1 01:35:54 ago
  Routing Descriptor Blocks:
  * 12.0.0.1, from 12.0.0.1, 01:35:54 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 1000

R5#
R5#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R5(config)#router bgp 1001
R5(config-router)#network 199.199.199.199 mask 255.255.255.255 backdoor
R5(config-router)#end
R5#show ip route 199.199.199.199
Routing entry for 199.199.199.199/32
  Known via "bgp 1001", distance 200, metric 0
  Tag 1000, type locally generated
  Last update from 12.0.0.1 00:00:03 ago
  Routing Descriptor Blocks:
  * 12.0.0.1, from 12.0.0.1, 00:00:03 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 1000

-Graham
Please note: My comments are simply suggestions. I cannot be held liable for any loss of data, life or marbles due to following my instructions.

Got a website? Need some live chat software?

Graham,

 

While this reply might be a bit late. I just wan't to described how I solve this problem before. If you would like to prefer OSPF to be the first router to be available you should place a lower weight on the BGP router for routes coming from BGP or a higher weight from routes coming from OSPF.

 

If you check the BGP router you will notice that the routes redistributed from OSPF will have a weight of 0 on BGP RIB, and that the route of from BGP will have 32768. I normally place a higher weight at the redistribution point from OSPF to BGP to be 40,000. Meaning for BGP to always prefer the router sourced from OSPF. With this setup OSPF will be always preferred until it disappears from the routing table at which point the route coming from BGP will be injected. I normally have this situation with MPLS providers.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking products for a $25 gift card