OSPF and BGP Puzzle

By Marko Milivojevic on January 4th, 2012

I love interesting problems that we face when studying for our CCIEs. Especially fun are those that come from an unusual behavior of protocols.

Couple of days ago, a student sent me this little problem. It looks simple, but let’s see how you do solving it.

Diagram

The setup is really straight-forward. Routers R2 and R5 are running OSPF in area 0. Router R2 has two static routes pointing to Null0 interface (0.0.0.0/0 and 10.0.0.0/8). This is the task:

  • Redistribute only 0.0.0.0/0 into OSPF on R2
  • Make sure the default route is received in OSPF on R5 and advertised in BGP to R4

Here is the relevant configuration on all three routers.

R2:

hostname R2
!
interface Loopback0
 ip address 192.168.0.2 255.255.255.255
!
interface Serial0/2/0
 ip address 192.168.25.2 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 Null0
ip route 10.0.0.0 255.0.0.0 Null0
!
ip prefix-list Redistribute seq 10 permit 0.0.0.0/0
!
route-map Connected permit 10
 match ip address prefix-list Redistribute
!
router ospf 1
 router-id 192.168.0.2
 network 192.168.0.0 0.0.255.255 area 0
 redistribute static subnets route-map Connected
!

R5:

hostname R5
!
interface Loopback0
 ip address 192.168.0.5 255.255.255.255
!
interface Serial0/0/0
 ip address 172.16.45.5 255.255.255.0
!
interface Serial0/2/0
 ip address 192.168.25.5 255.255.255.0
!
router ospf 1
 router-id 192.168.0.5
 network 192.168.0.0 0.0.255.255 area 0
!
router bgp 5
 bgp router-id 192.168.0.5
 neighbor 172.16.45.4 remote-as 4
 redistribute ospf 1
!

R4:

hostname R4
!
interface Loopback0
 ip address 172.16.0.4 255.255.255.255
!
interface Serial0/1/0
 ip address 172.16.45.4 255.255.255.0
!
router bgp 4
 bgp router-id 172.16.0.4
 neighbor 172.16.45.5 remote-as 5
!

We can see that both OSPF and BGP are operational:

R5:

R5#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.0.2       0   FULL/  -        00:00:34    192.168.25.2    Serial0/2/0

R5#show ip bgp summary | begin ^Neighbor
Neighbor        V          AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
172.16.45.4     4          4      31      33        4    0    0 00:29:56        0

However, not everything works as expected. Take a look at the OSPF routes on R5:

R5:

R5#show ip route ospf
     192.168.0.0/32 is subnetted, 2 subnets
O       192.168.0.2 [110/65] via 192.168.25.2, 00:31:28, Serial0/2/0

Also, let’s take a look at the BGP routes on R4:

R4:

R4#show ip route bgp
B    192.168.25.0/24 [20/0] via 172.16.45.5, 00:30:00
     192.168.0.0/32 is subnetted, 2 subnets
B       192.168.0.2 [20/65] via 172.16.45.5, 00:30:00
B       192.168.0.5 [20/0] via 172.16.45.5, 00:30:00

We can clearly see that the default route is missing on both R5 and R4. What’s wrong and how do we fix this problem? Post your thoughts and solutions in the comments below and in a few days, I’ll follow-up with the solution.

Happy studies!


Marko Milivojevic – CCIE #18427
Senior CCIE Instructor – IPexpert
Join our Online Study List

OSPF and BGP Puzzle, 3.8 out of 5 based on 13 ratings
Be Sociable, Share!

    Tags: BGP, CCIE, CCIE R&S, CCIE Routing & Switching, OSPF

    21 Responses to “OSPF and BGP Puzzle”

    1. Charbel Mouhayar says:

      On R2 under OSPF
      router ospf 1
      default-information originate always

      VA:F [1.9.22_1171]
      Rating: 1.0/5 (1 vote cast)
    2. David Betz says:

      Add default-information originate to the OSPF proc on R2, then add the same to the BGP proc on R5, also specifying explicit external matching on redistribution on BGP on R5 (i.e. match ospf 1 match external…– adding internal if you want internal stuff too).

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
    3. Nandan Mathure says:

      I believe that this is issue with the redistribute statement containing “external” keyword. OSPF by default only advertises the intra-area and inter-area routes if only “redistribute ospf 1″ is used. So in this case “external” keyword would help.

      VA:F [1.9.22_1171]
      Rating: 5.0/5 (3 votes cast)
    4. David says:

      R2

      router ospf 1
      default-information originate always

      VA:F [1.9.22_1171]
      Rating: 5.0/5 (2 votes cast)
    5. Daniel Dib says:

      It’s not possible to redistribute a static default into OSPF. To the best of my knowledge the only way to generate a default route in OSPF is with default-information originate or run stub routing.

      There could be a stupid router trick I haven’t seen though :)

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
    6. Seb says:

      You need a default-information originate on R2.
      With this command, the default appears on R5 routing table.

      As bgp redistribute only internal route from ospf, you need a redistribute ospf 1 match ex 2 on R5 in the router bgp 5.

      And finally, you need a default-information originate on the bgp router 5 on R5.

      SOrry for my poor english :-)

      VA:F [1.9.22_1171]
      Rating: 5.0/5 (3 votes cast)
    7. Joe Astorino says:

      Advertisement of a default route in OSPF can not work by redistributing a static default route. You need default-information originate for that function.

      Secondly, when you redistribute from OSPF into BGP you will need to specify external routes as part of that redistribution

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
    8. Joe Astorino says:

      Doh! One more thing — When you redistribute OSPF into BGP the default route will not go along with it by nature. You need to also add the default route into BGP. There are several ways to accomplish that.

      VA:F [1.9.22_1171]
      Rating: 4.5/5 (2 votes cast)
    9. Iban says:

      I think that this is the feault behaviour. Although the 0.0.0.0/0 is matching, it doesn’t create a Type-5 LSA to bring the default route to R5 . After applying the “default-information originate” command under R2′s ospf process you can see the default route in the database.

      In the other hand, you can’t redistribute a default route into BGP in this way. After checking that the default route is in the R5′s routing table you need the commands “bgp redistribute-internal” and “network 0.0.0.0 mask 0.0.0.0″.

      Nice minilab Marko :-)

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
    10. Karim Benhamouche says:

      Three things need to do :
      - On R2 :
      Router ospf 1
      default-information originate

      - On R5 :
      By default : redistribute ospf 1 => only internal prefixes but in our case this is not asked so you can delete the “redistribute ospf 1″ command.
      However, you have to explicitly announce the default-route with BGP to R4, so you can add, for example, this command :
      Router bgp 5
      neighbor 172.16.45.4 default-originate

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
    11. Mohammad Paracha says:

      under R2
      router ospf 1
      default information originate.

      under R5
      router bgp 5
      network 0.0.0.0 mask 0.0.0.0

      or

      neighbor 172.16.45.4 default-originate

      Thanks

      Mohammad Paracha

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
    12. Nandan Mathure says:

      I feel bad that I missed the important Point in my previous post ..1] default-information originate should be used on R2 as its the only way to get 0.0.0.0/0 route in ospf .I tried 2] neighbor 172.16.45.4 default originate under bgp on R5 which helped. But I think there may be some other way as well. But solution worked.
      R4#show ip route | beg Gate
      Gateway of last resort is 172.16.45.5 to network 0.0.0.0

      172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
      C 172.16.45.0/24 is directly connected, Serial0/0
      C 172.16.0.4/32 is directly connected, Loopback0
      B* 0.0.0.0/0 [20/0] via 172.16.45.5, 00:07:07
      R4#
      ————
      That being said when I add
      “redistribute ospf 1 match external internal” on R5
      i am able to get all routes into R4 which includes default route (due to addition of “neighbor 172.16.45.4 default-originate” under BGP 5)

      R4#show ip route | beg Gate
      Gateway of last resort is 172.16.45.5 to network 0.0.0.0

      B 192.168.25.0/24 [20/0] via 172.16.45.5, 00:00:09
      172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
      C 172.16.45.0/24 is directly connected, Serial0/0
      C 172.16.0.4/32 is directly connected, Loopback0
      192.168.0.0/32 is subnetted, 2 subnets
      B 192.168.0.2 [20/65] via 172.16.45.5, 00:00:09
      B 192.168.0.5 [20/0] via 172.16.45.5, 00:00:09
      B* 0.0.0.0/0 [20/0] via 172.16.45.5, 00:00:17
      R4#

      -Nandan

      VA:F [1.9.22_1171]
      Rating: 5.0/5 (4 votes cast)
    13. bence says:

      I think simply should forget about that 0.0.0.0/0 stuff and use ‘default-information originate always’ instead.
      I tried it in lab, it seems to be working:)

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      • Roman Shilenko says:

        “redistribute ospf 1 match internal external 2″
        is not necessary, everything works without it

        VA:F [1.9.22_1171]
        Rating: 0.0/5 (0 votes cast)
    14. bence says:

      A little detail:)

      On R5: router bgp 5
      no synchronization
      bgp router-id 192.168.0.5
      bgp log-neighbor-changes
      redistribute ospf 1 match internal external 2
      neighbor 172.16.45.4 remote-as 4
      neighbor 172.16.45.4 default-originate
      no auto-summary

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
    15. Roman Shilenko says:

      A little addition to the answer of Nandan Mathure.
      Command #2 on R5 (neighbor 172.16.45.4 default-originate) will send a default route to R4 even without having a default in R5′s routing table. So, both commands work independently and both are necessary.

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
    16. nbhduoc says:

      OK, the solution in this case is using command default-information.
      But why ospf doesn’t redistribute default-route into OSPF when we issue command: redistribute static? Plz give me some hints about it!

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
    17. Fabrizio Chessa says:

      R2 Configuration:

      hostname R2
      !
      interface Loopback0
      ip address 192.168.0.2 255.255.255.255
      ip ospf network point-to-point
      !
      interface Serial0/0
      description ** to R5 **
      ip address 192.168.25.2 255.255.255.0
      clock rate 2000000
      !
      router ospf 10
      router-id 192.168.0.2
      log-adjacency-changes
      network 192.168.0.0 0.0.255.255 area 0
      default-information originate always
      !
      ip route 0.0.0.0 0.0.0.0 Null0
      ip route 10.0.0.0 255.0.0.0 Null0
      !
      end

      R5 Configuration:

      hostname R5
      !
      interface Loopback0
      ip address 192.168.0.5 255.255.255.255
      ip ospf network point-to-point
      !
      interface Serial0/0
      description ** to R2 **
      ip address 192.168.25.5 255.255.255.0
      clock rate 2000000
      !
      interface Serial0/1
      description ** to R4 **
      ip address 172.16.45.5 255.255.255.0
      clock rate 2000000
      !
      router ospf 10
      router-id 192.168.0.5
      log-adjacency-changes
      network 192.168.0.0 0.0.255.255 area 0
      !
      router bgp 5
      no synchronization
      bgp router-id 192.168.0.5
      bgp log-neighbor-changes
      redistribute ospf 10 route-map RedistributeDefault
      neighbor 172.16.45.4 remote-as 4
      default-information originate
      no auto-summary
      !
      ip prefix-list DefaultRoute seq 5 permit 0.0.0.0/0
      !
      route-map RedistributeDefault permit 10
      match ip address prefix-list DefaultRoute
      match route-type external type-2
      !
      end

      R4 Configuration:

      hostname R4
      !
      interface Loopback0
      ip address 172.16.0.4 255.255.255.255
      !
      interface Serial0/1
      description ** to R5 **
      ip address 172.16.45.4 255.255.255.0
      clock rate 2000000
      !
      router bgp 4
      no synchronization
      bgp router-id 172.16.0.4
      bgp log-neighbor-changes
      neighbor 172.16.45.5 remote-as 5
      no auto-summary
      !
      end

      Routing Table on R5:

      R5(config-router)#do sh ip rou
      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 192.168.25.2 to network 0.0.0.0

      C 192.168.25.0/24 is directly connected, Serial0/0
      172.16.0.0/24 is subnetted, 1 subnets
      C 172.16.45.0 is directly connected, Serial0/1
      192.168.0.0/32 is subnetted, 2 subnets
      O 192.168.0.2 [110/65] via 192.168.25.2, 01:29:18, Serial0/0
      C 192.168.0.5 is directly connected, Loopback0
      O*E2 0.0.0.0/0 [110/1] via 192.168.25.2, 01:21:50, Serial0/0

      Routing Table on R4:

      R4#sh ip rou
      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 172.16.45.5 to network 0.0.0.0

      172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
      C 172.16.45.0/24 is directly connected, Serial0/1
      C 172.16.0.4/32 is directly connected, Loopback0
      B* 0.0.0.0/0 [20/1] via 172.16.45.5, 00:02:23

      I sended only default route on R4 with the prefix-list “DefaultRoute” in combination with route-map “RedistributeDefault”.

      VA:F [1.9.22_1171]
      Rating: 1.0/5 (1 vote cast)
    18. alx says:

      On R2:
      default-information originate

      In this case R5 will get 0.0.0.0 in routing table through ospf 1:
      R5#sh ip ro ospf 1 | i 0.0.0.0
      O*E2 0.0.0.0/0 [110/1] via 192.168.25.2, 00:01:54, FastEthernet0/0
      so R5 can redistribute routing information no 172.16.45.4. In my case (Cisco 7200 12.4(13b)) was no need to specify “match external” in “redistribute ospf 1″ and only command to do the trick was:
      router bgp 5
      network 0.0.0.0

      “neighbor 172.16.45.4 default-originate” is not really good idea because in case when R2 will stop announcing default information to R5, R4 will never know if this happened.

      VA:F [1.9.22_1171]
      Rating: 5.0/5 (4 votes cast)
    19. 1. Thanks Marko for sharing this. A good refresher for my CCNP ROUTE knowledge. :)
      2. Iban, the “bgp redistribute-internal” BGP router subcommand is not for this scenario (IGP > BGP). It is for IBGP > IGP. Some notes about this here: http://www.itcertnotes.com/2012/01/redistribution-between-igp-and-bgp.html
      3. Thanks all that I now learnt the “default-information originate” and the “neighbor X.X.X.X default-originate” BGP router subcommands. :-)

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
    20. Ranjit Barah says:

      In the router R5, we must redistribute ospf of type external also in the BGP configuration. Because R5 will receive the default route as type ospf extrernal from R2.

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)

    Leave a Reply