cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
11973
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?

2 Accepted Solutions

Accepted Solutions

Hi Graham,

could you check the Forwarding Address of the Type-5 LSA for 199.199.199.199 (show ip ospf database external 199.199.199.199)?

If it is non-zero (not 0.0.0.0), it has to be present as an OSPF internal route in the routing table (RFC 2328 16.4 [3]).

My best guess is that the network the FA belongs to is primarily learned via EBGP as well. If so, just increase the distance for that network in BGP too or (even better, if possible) make sure that the FA is set to 0.0.0.0 at the injecting OSPF ASBR (e.g. passive interface or network point-to-point).

Useful Cisco document: Common Routing Problem with OSPF Forwarding Address

 

HTH

Rolf

View solution in original post

Ok, cool, we are on the right track ;-)

What we need to accomplish now is that on R5 an OSPF-internal route for the 13.0.0.0 network is installed (1) or that the OSPF ASBR sets the FA to 0.0.0.0 (2).

1) On R5, either change the OSPF- or the EBGP (backdoor) distance for that prefix too.

2) On the OSPF ASBR (where you're redistributing BGP into OSPF), set the 13.0.0.0 interface OSPF passive (if no OSPF neighbor exists on that link) or use network type point-to-point or point-to-multipoint, if possible (in this case you'll have to change the network type on the neighbor(s) of that link as well).

HTH

Rolf

View solution in original post

22 Replies 22

Richard Burts
Hall of Fame
Hall of Fame

G

 

The easy solution would be to change the administrative distance of one of the protocols. Either increase the AD of EBGP so that it is greater than OSPF or decrease AD of OSPF so that it is less than EBGP.

 

HTH

 

Rick

HTH

Rick

Hi Thanks for the reply,

 

Unfortunately, I still require some paths via the BGP link to be preferred.

 

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

Hi @graham smart,

I have something and hope it works for you.

You can create an ACL specifying the route you want to manipulate, then in any of the routing protocols (it will depend in which of them you want to manipulate the AD) you have to tell the protocol that increase or decreased the AD of the route based on the next hop of that route, for example, let's say that you want to manipulate inside OSPF:

# access-list <#> permit x.x.x.x x.x.x.x 

# router ospf <process ID>

# distance 10 <next hop> <wildcard mask> <ACL ID>

-

In your case, it would go something like this:

# access-list 2 permit host 199.199.199.199

# router ospf 1

# distance 19 14.0.0.1 0.0.0.0 2

-

After this, the router will start to modify the AD "only for that route" based on the next hop that is advertising it.

You can try it in a lab enviroment and then let me know if that could help you.

Rgrds,

Martin, IT Specialist

Hi,

I have tried this, but for some reason it still prefers BGP.

If i use the generic distance setting for ospf and set ALL routes to 19, Then OSPF is the best path.

If I do it JUST for the 199.199.199.199/32 route. It doesnt seem to do anything.

 

router ospf 1
 router-id 14.0.0.2
 log-adjacency-changes
 network 0.0.0.0 255.255.255.255 area 0
 distance 19 14.0.0.1 0.0.0.0 2

 

 

 

R5#sh 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 00:01:58 ago
  Routing Descriptor Blocks:
  * 12.0.0.1, from 12.0.0.1, 00:01:58 ago
      Route metric is 0, traffic share count is 1
      AS Hops 2
      Route tag 1000

 

 

sh ip bgp

*> 199.199.199.199/32
                    12.0.0.1                               0 1000 64512 ?

 

If it set it for distance 19 for OSPF in general,

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

 

 

Something is going on here where its just not working for that single route?

 

 

If i shut down the BGP session, the OSPF route takes over as expected with a AD of 19..

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

 

 

Something else must be causeing BGP to me more preferable.

Even If i set BGP to had an AD of 250, Its still more preferable..

What the?

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

 

 

Any ideas?

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?

Hi @graham smart,

Did you specify the ACL with the address you want to manipulate?

-

access-list 2 permit 199.199.199.199 0.0.0.0

!

router ospf 1

distance 19 14.0.0.1 0.0.0.0 2

-

Without this the "distance" command won't recognize what route is going to manipulate. I'm telling you this because I didn't see it in your example.

Let me know if you did put it.

Rgrds,

Martin,  IT Specialist

Indeed, The acl is defined as you said.

 

If I shut down BGP, I can see the OSPF route with a AD of 19 ( As above )

As soon as BGP comes back, It takes over as the best route, even though it shows and AD of 20.

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

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

Well, maybe you won't like my opinion but ... What the heck!? How is it still believing in an AD of 250 over an AD of 110?

What IOS version are you using and what type of router is this?

Can you provide more output of your configuration?

I think that maybe it's a kind of bug. I've tried this scenario a lot of times and it works for me. :(

Waiting for your responses.

Rgrds,

Martin, IT Specialist

 

Lol, Yep . Im baffled.

 

Its a 7200 running a 15 IOS.

Im wondering if the Route metric is 0 on BGP routes and Route metric is 1 on OSPF routes have some kind of play in this problem.

It just doest make sense.

 

Ill get the full config when i'm back in the office.

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

Ok, but remember that metric is considered after administrative distance is checked.

Rgrds,

Martin, IT Specialist

Hi Graham,

could you check the Forwarding Address of the Type-5 LSA for 199.199.199.199 (show ip ospf database external 199.199.199.199)?

If it is non-zero (not 0.0.0.0), it has to be present as an OSPF internal route in the routing table (RFC 2328 16.4 [3]).

My best guess is that the network the FA belongs to is primarily learned via EBGP as well. If so, just increase the distance for that network in BGP too or (even better, if possible) make sure that the FA is set to 0.0.0.0 at the injecting OSPF ASBR (e.g. passive interface or network point-to-point).

Useful Cisco document: Common Routing Problem with OSPF Forwarding Address

 

HTH

Rolf

R5#sh ip ospf database external 199.199.199.199

            OSPF Router with ID (14.0.0.2) (Process ID 1)

                Type-5 AS External Link States

  LS age: 14
  Options: (No TOS-capability, DC)
  LS Type: AS External Link
  Link State ID: 199.199.199.199 (External Network Number )
  Advertising Router: 14.0.0.1
  LS Seq Number: 80000001
  Checksum: 0x2951
  Length: 36
  Network Mask: /32
        Metric Type: 2 (Larger than any link state path)
        TOS: 0
        Metric: 1
        Forward Address: 13.0.0.1
        External Route Tag: 64512

 

 

I have now set it to be point to point.

 

R5#sh ip ospf database external 199.199.199.199

            OSPF Router with ID (14.0.0.2) (Process ID 1)

                Type-5 AS External Link States

  LS age: 382
  Options: (No TOS-capability, DC)
  LS Type: AS External Link
  Link State ID: 199.199.199.199 (External Network Number )
  Advertising Router: 14.0.0.1
  LS Seq Number: 80000001
  Checksum: 0x2951
  Length: 36
  Network Mask: /32
        Metric Type: 2 (Larger than any link state path)
        TOS: 0
        Metric: 1
        Forward Address: 13.0.0.1
        External Route Tag: 64512

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

Running Config:

 

Building configuration...

Current configuration : 1417 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R5
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
no ip icmp rate-limit unreachable
ip cef
!
!
!
!
no ip domain lookup
!
multilink bundle-name authenticated
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
archive
 log config
  hidekeys
!
!
!
!
ip tcp synwait-time 5
!
!
!
!
interface Loopback1
 ip address 188.188.188.188 255.255.255.255
!
interface FastEthernet0/0
 ip address 12.0.0.2 255.255.255.252
 speed 100
 full-duplex
!
interface FastEthernet0/1
 ip address 14.0.0.2 255.255.255.252
 ip ospf network point-to-point
 speed 100
 full-duplex
!
interface FastEthernet1/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
router ospf 1
 router-id 14.0.0.2
 log-adjacency-changes
 network 0.0.0.0 255.255.255.255 area 0
 distance 19 14.0.0.1 0.0.0.0 2
!
router bgp 1001
 no synchronization
 bgp log-neighbor-changes
 redistribute connected
 neighbor 12.0.0.1 remote-as 1000
 no auto-summary
!
ip forward-protocol nd
!
!
no ip http server
no ip http secure-server
!
ip access-list extended BACKUP-PATH
 permit ip host 199.199.199.199 any
!
!
!
access-list 2 permit 199.199.199.199
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
!
line con 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line aux 0
 exec-timeout 0 0
 privilege level 15
 logging synchronous
line vty 0 4
 login
!
!
end

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

Good Job boy!

Rgrds,

Martin, IT Specialist

Ok, cool, we are on the right track ;-)

What we need to accomplish now is that on R5 an OSPF-internal route for the 13.0.0.0 network is installed (1) or that the OSPF ASBR sets the FA to 0.0.0.0 (2).

1) On R5, either change the OSPF- or the EBGP (backdoor) distance for that prefix too.

2) On the OSPF ASBR (where you're redistributing BGP into OSPF), set the 13.0.0.0 interface OSPF passive (if no OSPF neighbor exists on that link) or use network type point-to-point or point-to-multipoint, if possible (in this case you'll have to change the network type on the neighbor(s) of that link as well).

HTH

Rolf

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: