cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Redistributing Internal BGP Routes Into OSPF

98766
Views
15
Helpful
7
Comments

     

    Introduction

     

    This document shows how to redistribute Internal BGP routes into OSPF process. Like in other IGP to IGP redistribution the behavior is different when redistributing IBGP into OSPF. IBGP learned routes are not forwarded to an IGP routing protocol through the redistribute command. Use command “bgp redistribute-internal” under the BGP process on the redistributing router.

     

    In the scenario depicted here, router R1 and R2 are running IBGP and router R2/R3 running OSPF Area 0. R1 is advertising two routes (1.1.1.1 /32 and 172.16.0.0 /16) through network command. R2 is redistributing BGP into OSPF area 0. It is required to redistribute selected internal routes (172.16.0.0 /16). The task is achieved by making use of prefix-list and route-map.

     

     

    A prefix-list, named B2O, is configured on R2 to match the prefix 172.16.0.0

     

                  ip prefix-list B2O seq 5 permit 172.16.0.0/16

     

    A route-map, named BGP-To_OSPF, is configured on R2

     

                route-map BGP-To_OSPF permit 10

                  match ip address prefix-list B2O

     

    In the vrification section, please check the output of "show ip route" command on R3.

     

    Prerequisite

     

    • Understanding of routing protocols – BGP and OSPF

     

    Topology Diagram

     

    Topology_Diag.GIF

    Configuration

     

     

    Router R1

    interface Loopback0

    ip address 1.1.1.1 255.255.255.255

    !

    interface Loopback1

    ip address 172.16.1.1 255.255.0.0

    !

    interface Serial1/0

    ip address 192.12.12.1 255.255.255.0

    serial restart-delay 0

    !

    router bgp 100

    no synchronization

    bgp router-id 1.1.1.1

    bgp log-neighbor-changes

    network 1.1.1.1 mask 255.255.255.255

    network 172.16.0.0

    neighbor 192.12.12.2 remote-as 100

    no auto-summary

     

    !

     

     

    Router R2

    interface Loopback0

      ip address 2.2.2.2 255.255.255.255

      !

    interface Serial1/0

      ip address 192.12.12.2 255.255.255.0

      serial restart-delay 0

      !

    interface FastEthernet2/0

      ip address 192.23.23.2 255.255.255.0

      duplex auto

      speed auto

      !

    router ospf 1

      router-id 2.2.2.2

      log-adjacency-changes

      redistribute bgp 100 metric 100 metric-type 1 subnets route-map BGP-To_OSPF

      network 192.23.23.2 0.0.0.0 area 0

    !

    router bgp 100

      no synchronization

      bgp router-id 2.2.2.2

      bgp log-neighbor-changes

      bgp redistribute-internal

      neighbor 192.12.12.1 remote-as 100

      no auto-summary

    !

    ip prefix-list B2O seq 5 permit 172.16.0.0/16

    !

    route-map BGP-To_OSPF permit 10

      match ip address prefix-list B2O

    !

     

     

    Router R3

    interface FastEthernet1/0

      ip address 192.23.23.3 255.255.255.0

      duplex auto

      speed auto

      !

    router ospf 1

      log-adjacency-changes

    network 192.23.23.3 0.0.0.0 area 0

     

    Verification Commands

     

    R1#sh ip bgp sum

    BGP router identifier 1.1.1.1, local AS number 100

    BGP table version is 3, main routing table version 3

    2 network entries using 240 bytes of memory

    2 path entries using 104 bytes of memory

    1/1 BGP path/bestpath attribute entries using 124 bytes of memory

    0 BGP route-map cache entries using 0 bytes of memory

    0 BGP filter-list cache entries using 0 bytes of memory

    BGP using 468 total bytes of memory

    BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs

     

    Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

    192.12.12.2     4          100     117     119        3    0    0 01:43:47        0

     

    R2#sh ip bgp sum

    BGP router identifier 2.2.2.2, local AS number 100

    BGP table version is 4, main routing table version 4

    2 network entries using 240 bytes of memory

    2 path entries using 104 bytes of memory

    1/1 BGP path/bestpath attribute entries using 124 bytes of memory

    0 BGP route-map cache entries using 0 bytes of memory

    0 BGP filter-list cache entries using 0 bytes of memory

    BGP using 468 total bytes of memory

    BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs

     

    Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

    192.12.12.1     4          100     119     118        4    0    0 01:43:36        2

     

    R2#sh ip bgp

    BGP table version is 4, local router ID is 2.2.2.2

    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

                  r RIB-failure, S Stale

    Origin codes: i - IGP, e - EGP, ? - incomplete

     

       Network          Next Hop            Metric LocPrf Weight Path

    *>i1.1.1.1/32       192.12.12.1              0    100      0 i

    *>i172.16.0.0       192.12.12.1              0    100      0 i

     

    R2#sh ip ospf ne

     

    Neighbor ID     Pri   State           Dead Time   Address         Interface

    192.23.23.3       1   FULL/DR         00:00:35    192.23.23.3     FastEthernet2/0

     

    R2#sh ip route 172.16.0.0

    Routing entry for 172.16.0.0/16

      Known via "bgp 100", distance 200, metric 0, type internal

      Redistributing via ospf 1

      Advertised by ospf 1 metric 100 metric-type 1 subnets route-map BGP-To_OSPF

      Last update from 192.12.12.1 01:01:54 ago

      Routing Descriptor Blocks:

      * 192.12.12.1, from 192.12.12.1, 01:01:54 ago

          Route metric is 0, traffic share count is 1

          AS Hops 0

          MPLS label: none

     

    R3#sh 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, + - replicated route

     

    Gateway of last resort is not set

     

    O E1  172.16.0.0/16 [110/101] via 192.23.23.2, 00:57:55, FastEthernet1/0

          192.23.23.0/24 is variably subnetted, 2 subnets, 2 masks

    C        192.23.23.0/24 is directly connected, FastEthernet1/0

    L        192.23.23.3/32 is directly connected, FastEthernet1/0

     

    Related Information

     

    Comments
    Contributor

    This document helped me a lot.

    Community Member

    Very useful Document. Nice One

    Cisco Employee

    Great Example, I was stuck with a ospf redistribution.

     

    Here  I found the cause. and how to accomplish my task.

     

    thanks a lot.  

    Community Member

    What are the LSA types we see when we redistribute BGP into OSPF?

    Cisco Employee

    should be the same as from any other protocol.  Type 5 (or 7 if into an NSSA).

    Here is output from a router with an eBGP neighbor advertising 8.8.8.8/32 and two iBGP neighbors.  The router is redistributing BGP into OSPF with default options only.  As you can see below, the route is present on the redistributing router as an eBGP route (AD 20) and is advertised to OSPF neighbors as an E2 route by default.  If it were an NSSA, the type would be N2.  With route-maps or options on the redistribute command we could make it an E1/N1.

    R3#sh run | s router ospf
    router ospf 1
    router-id 3.3.3.3
    redistribute bgp 123 subnets
    network 3.3.3.3 0.0.0.0 area 0
    network 10.10.0.0 0.0.255.255 area 0


    R3#sh run | s router bgp
    router bgp 123
    bgp router-id 3.3.3.3
    bgp log-neighbor-changes
    neighbor iBGP peer-group
    neighbor iBGP remote-as 123
    neighbor iBGP update-source Loopback3
    neighbor iBGP next-hop-self
    neighbor 1.1.1.1 peer-group iBGP
    neighbor 2.2.2.2 peer-group iBGP
    neighbor 38.38.38.8 remote-as 8
    maximum-paths ibgp 2


    R3#sh ip ro 8.8.8.8
    Routing entry for 8.8.8.8/32
    Known via "bgp 123", distance 20, metric 0
    Tag 8, type external
    Redistributing via ospf 1
    Advertised by ospf 1 subnets
    Last update from 38.38.38.8 00:00:55 ago
    Routing Descriptor Blocks:
    * 38.38.38.8, from 38.38.38.8, 00:00:55 ago
    Route metric is 0, traffic share count is 1
    AS Hops 1
    Route tag 8
    MPLS label: none


    R3#sh ip bgp 8.8.8.8
    BGP routing table entry for 8.8.8.8/32, version 2
    Paths: (1 available, best #1, table default)
    Multipath: iBGP
    Advertised to update-groups:
    2
    Refresh Epoch 1
    8
    38.38.38.8 from 38.38.38.8 (8.8.8.8)
    Origin incomplete, metric 0, localpref 100, valid, external, best
    rx pathid: 0, tx pathid: 0x0


    R3#sh ip ospf data ext 8.8.8.8

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

    Type-5 AS External Link States

    LS age: 74
    Options: (No TOS-capability, DC, Upward)
    LS Type: AS External Link
    Link State ID: 8.8.8.8 (External Network Number )
    Advertising Router: 3.3.3.3
    LS Seq Number: 80000001
    Checksum: 0xED91
    Length: 36

    Network Mask: /32
    Metric Type: 2 (Larger than any link state path)
    MTID: 0
    Metric: 1
    Forward Address: 0.0.0.0
    External Route Tag: 8

    R3#

    Beginner

    Hi I'm having the same issue. I'm pretty sure my redistribution from OSPF to BGP is wrong. not able to ping across gi0/0 of PE-1 from PC1. Topology is very similar. Configs and output below:

     

    Capture.PNG

     

     

    ****PE-1******
    !
    vrf definition CustA_HQ
     rd 100:10
     route-target export 100:10
     route-target import 100:10
     route-target import 100:20
     !
     address-family ipv4
     exit-address-family
    !
    vrf definition CustA_Remote
     rd 100:20
     route-target export 100:20
     route-target import 100:20
     !
    interface Loopback0
     description ///LOOPBACK0:MPLS-BGP///
     ip address 1.1.1.1 255.255.255.255
    !
    interface Loopback10
     description // VRF CustA_HQ - IGP LOOPBACK //
     ip address 1.1.1.10 255.255.255.255
    !
    interface GigabitEthernet0/0
     ip address 1.1.1.110 255.255.255.254
     ip ospf network point-to-point
     ip ospf 100 area 0
     media-type gbic
     speed 1000
     duplex full
     negotiation auto
    !
    interface GigabitEthernet1/0
     vrf forwarding CustA_HQ
     ip address 10.1.1.10 255.255.255.0
     negotiation auto
    !
    router ospf 10 vrf CustA_HQ
     router-id 1.1.1.10
     log-adjacency-changes detail
     redistribute bgp 100 metric 100 subnets route-map BGP_TO_OSPF
     network 1.1.1.10 0.0.0.0 area 0
     network 10.1.1.0 0.0.0.255 area 0
    !
    router ospf 100
     router-id 1.1.1.1
     log-adjacency-changes detail
     network 1.1.1.1 0.0.0.0 area 0
    !
    router bgp 100
     bgp log-neighbor-changes
     neighbor 2.2.2.2 remote-as 100
     neighbor 2.2.2.2 update-source Loopback0
     !
     address-family ipv4
      bgp redistribute-internal
      neighbor 2.2.2.2 activate
      neighbor 2.2.2.2 send-community extended
     exit-address-family
     !
     address-family vpnv4
      neighbor 2.2.2.2 activate
      neighbor 2.2.2.2 send-community extended
     exit-address-family
     !
     address-family ipv4 vrf CustA_HQ
      network 10.1.1.0 mask 255.255.255.0
      redistribute ospf 10 metric 5
     exit-address-family
    !
    ip prefix-list BGP_INTERNAL seq 5 permit 1.1.1.110/31
    !
    route-map BGP_TO_OSPF permit 10
     match ip address prefix-list BGP_INTERNAL
    !
    %%%%%%%%%%PE-1 PINGS%%%%%%%%%%%%%
    PE-1#ping vrf CustA_HQ 10.1.1.10
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 10.1.1.10, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/8 ms
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    PE-1#ping vrf CustA_HQ 10.1.1.1
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 16/28/48 ms
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    PE-1#ping vrf CustA_HQ 1.0.0.1
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 1.0.0.1, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 16/28/40 ms
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    PE-1#ping vrf CustA_HQ 1.0.0.2
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 1.0.0.2, timeout is 2 seconds:
    .!!!!
    Success rate is 80 percent (4/5), round-trip min/avg/max = 24/299/1084 ms
    %%%%%%%%%%%%%PE-1 ROUTES%%%%%%%%%%%%
    PE-1#
    PE-1#sh ip int brief
    Interface                   IP-Address      OK?    Method  Status                Protocol
    GigabitEthernet0/0     1.1.1.110       YES    manual    up                    up
    GigabitEthernet1/0     10.1.1.10       YES    manual    up                    up
    Loopback0                  1.1.1.1          YES    manual    up                    up
    Loopback10                1.1.1.10        YES    manual    up                    up
    PE-1#
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    PE-1#sh 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
    Gateway of last resort is not set

          1.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
    C        1.1.1.1/32 is directly connected, Loopback0
    C        1.1.1.10/32 is directly connected, Loopback10
    C        1.1.1.110/31 is directly connected, GigabitEthernet0/0
    L        1.1.1.110/32 is directly connected, GigabitEthernet0/0
          2.0.0.0/32 is subnetted, 1 subnets
    O        2.2.2.2 [110/2] via 1.1.1.111, 03:12:06, GigabitEthernet0/0
          111.0.0.0/32 is subnetted, 1 subnets
    C        111.111.111.10 is directly connected, Loopback1
    PE-1#
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    PE-1#sh ip bgp vpnv4 all
    BGP table version is 3, local router ID is 1.1.1.10
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
    Origin codes: i - IGP, e - EGP, ? - incomplete
         Network          Next Hop            Metric LocPrf Weight Path
    Route Distinguisher: 100:10 (default for vrf CustA_HQ)
     *>  1.0.0.0/29       10.1.1.1                 5         32768 ?
     *>  10.1.1.0/24      0.0.0.0                  0         32768 I
    ***********************CustA-HQ*********************
    hostname CustA-HQ
    !
    vrf definition CustA_HQ
     rd 100:10
     route-target export 100:10
     route-target import 100:10
     route-target import 100:20
     !
     address-family ipv4
     exit-address-family
    !
    vrf definition CustA_Remote
     rd 100:20
     route-target export 100:20
     route-target import 100:20
    !
    ip cef
    no ipv6 cef
    !
    interface Loopback10
     description // VRF CustA_HQ - IGP LOOPBACK //
     ip address 10.10.10.10 255.255.255.255
    !
    interface GigabitEthernet0/0
     vrf forwarding CustA_HQ
     ip address 10.1.1.1 255.255.255.0
     media-type gbic
     speed 1000
     duplex full
     negotiation auto
    !
    interface FastEthernet1/0
     vrf forwarding CustA_HQ
     ip address 1.0.0.1 255.255.255.248
     duplex full
    !
    router ospf 10 vrf CustA_HQ
     router-id 10.10.10.10
     log-adjacency-changes detail
     network 1.0.0.0 0.0.0.7 area 0
     network 10.1.1.0 0.0.0.255 area 0
     network 10.10.10.10 0.0.0.0 area 0
    !
    control-plane
    !
    !
    end
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    CustA-HQ#sh ip route vrf CustA_HQ

    Routing Table: CustA_HQ
    Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
           D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    Gateway of last resort is not set
          1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
    C        1.0.0.0/29 is directly connected, FastEthernet1/0
    L        1.0.0.1/32 is directly connected, FastEthernet1/0
          10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
    C        10.1.1.0/24 is directly connected, GigabitEthernet0/0
    L        10.1.1.1/32 is directly connected, GigabitEthernet0/0
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    CustA-HQ#sh 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
       Gateway of last resort is not set
          10.0.0.0/32 is subnetted, 1 subnets
    C        10.10.10.10 is directly connected, Loopback10
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    CustA-HQ#sh ip ospf neighbor
    Neighbor ID     Pri   State           Dead Time   Address         Interface
    1.1.1.10          1   FULL/DR         00:00:34    10.1.1.10       GigabitEthernet0/0
    CustA-HQ#
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    CustA-HQ#sh ip route vrf CustA_HQ 1.1.1.110

    Routing Table: CustA_HQ
    % Subnet not in table
    CustA-HQ#
    CustA-HQ#
    CustA-HQ#sh ip route 1.1.1.110
    % Network not in table
    CustA-HQ#

    %%%%PINGS FROM PC CONNECTED TO CustA-HQ%%%%%%
    PC1> ping 1.0.0.1
    84 bytes from 1.0.0.1 icmp_seq=1 ttl=255 time=9.051 ms
    84 bytes from 1.0.0.1 icmp_seq=2 ttl=255 time=9.007 ms

    PC1> ping 10.1.1.1
    84 bytes from 10.1.1.1 icmp_seq=1 ttl=255 time=15.626 ms
    84 bytes from 10.1.1.1 icmp_seq=2 ttl=255 time=15.626 ms

    PC1> ping 10.1.1.10
    84 bytes from 10.1.1.10 icmp_seq=1 ttl=254 time=46.878 ms
    84 bytes from 10.1.1.10 icmp_seq=2 ttl=254 time=31.246 ms

    PC1> ping 1.1.1.110
    *1.0.0.1 icmp_seq=1 ttl=255 time=15.626 ms (ICMP type:3, code:1, Destination host unreachable)

     

    Me also...

    CreatePlease to create content
    Content for Community-Ad