簡介

    本檔案介紹Cisco路由器上開放最短路徑優先(OSPF)到邊界閘道通訊協定(BGP)重新分配的行為。

    必要條件

    需求

    Cisco建議您在使用本文檔之 前瞭解OSPF路由型別。

    採用元件

    本文件所述內容不限於特定軟體和硬體版本。

    本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。

    慣例

    如需文件慣例的詳細資訊,請參閱思科技術提示慣例。

    背景資訊

    本技術說明解釋思科路由器上OSPF到BGP重分發的行為。 RFC 1403 中概述了OSPF到BGP重分發的 行為。 OSPF路由有幾種型別:

      區域內 — 在多區域OSPF網路中,來自某一區域的路由被同一區域中的路由器視為區域內路由。在 show ip route 命令輸出中,這些路由標籤為O。

      區域間路 由 — 當路由通過OSPF區域邊界路由器(ABR)時,該路由稱為OSPF區域間路由。在 show ip route 命令輸出中,這些路 由被標籤 為O IA。

      區域內路由和區域間路由也稱為OSPF內部路由,因為它們是使用OSPF network 命令覆蓋介面時由OSPF自身生成的。

      External Type-2或External Type-1 — 重新分發到OSPF中的路由(如已連線、靜態或其他路由協定)稱為External Type-2或External Type-1。這些路由在 show ip route命令輸出中標籤為O E2或O E1

      NSSA External Type-2或NSSA External Type 1 — 將某個區域配置為非末節區域(NSSA)並將路由重分發到OSPF時,這些路由稱為NSSA External Type-2或NSSA External Type-1。這些路由在 show ip route 命令輸出中標籤為O N2或O N1。

    解釋外部和NSSA第2類或1類之間的差異超出本文檔的範圍 — 有關詳細資訊,請參閱OSPF設計手冊。

    預設行為是不將任何路由從OSPF重分發到BGP。必須配置重分發。您可以在OSPF到BGP重分發期間使用 route-map 命令過濾路由。要完成重分發,需要特定關鍵字 (如internal、external nssa- externalare)來重分發各自的路由。

    網路設定

    下面討論四種將OSPF路由重分發到BGP的情況。網路圖適用於前三種情況。第四個情況的圖和設定可在 將OSPF NSSA外部路由重分配到BGP 部分中找到。

    Redistribution OSPF to BGP Topology A 將OSPF重新分發到BGP拓撲A

    僅將OSPF內部(區域內和區域間)路由重分佈到BGP

    如果將OSPF重分發到BGP而不使用關鍵字,則預設情況下僅將OSPF區域內路由和區域間路由重分發到BGP。您可以在 router bgp 下將 internal 關鍵字與 redistribute 命令一起使用以重分發OSPF區域內路由和區域間路由。

    此配置是路由器B的新配置,它只將區域內路由(10.108.2.0/24)和區域間路由(10.108.1.0/24)重分發到BGP,並且只將OSPF內部(區域內和區域間)路由重分發到BGP:

    hostname RTB
    interface GigabitEthernet0/0
     ip address 10.3.3.1 255.255.255.0
     duplex auto
     speed auto
     media-type rj45
    interface GigabitEthernet0/1
     ip address 10.2.2.3 255.255.255.0
     duplex auto
     speed auto
     media-type rj45  
    !
    router ospf 1 network 10.2.2.0 0.0.0.255 area 1 
    !
    router bgp 100
    redistribute ospf 1

    !-- This redistributes only OSPF intra-area and inter-area routes into BGP.


    neighbor 10.3.3.2 remote-as 200
    !
    end

    RTB#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 a - application route + - replicated route, % - next hop override, p - overrides from PfR Gateway of last resort is not set 10.0.0.0/8 is variably subnetted, 6 subnets, 2 masks C 10.2.2.0/24 is directly connected, GigabitEthernet0/1 L 10.2.2.3/32 is directly connected, GigabitEthernet0/1 C 10.3.3.0/24 is directly connected, GigabitEthernet0/0 L 10.3.3.1/32 is directly connected, GigabitEthernet0/0 O IA 10.108.1.0/24 [110/3] via 10.2.2.2, 00:08:38, GigabitEthernet0/1 O 10.108.2.0/24 [110/2] via 10.2.2.2, 00:39:13, GigabitEthernet0/1 O E2 192.168.1.0/24 [110/20] via 10.2.2.2, 00:07:39, GigabitEthernet0/1 O E1 192.168.2.0/24 [110/23] via 10.2.2.2, 00:07:38, GigabitEthernet0/1

    路由器B僅重新分配OSPF內部路由:

    RTB#show ip bgp
    BGP table version is 12, local router ID is 10.3.3.1
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
                  r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
                  x best-external, a additional-path, c RIB-compressed, 
                  t secondary path, 
    Origin codes: i - IGP, e - EGP, ? - incomplete
    RPKI validation codes: V valid, I invalid, N Not found
         Network          Next Hop            Metric LocPrf Weight Path
     *>   10.2.2.0/24      0.0.0.0                  0         32768 ?
     *>   10.108.1.0/24    10.2.2.2                 3         32768 ?
     *>   10.108.2.0/24    10.2.2.2                 2         32768 ?
    

    路由器C從BGP獲知這些路由:

    RTC#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
           a - application route
           + - replicated route, % - next hop override, p - overrides from PfR
    Gateway of last resort is not set
          10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
    B        10.2.2.0/24 [20/0] via 10.3.3.1, 00:07:07
    C        10.3.3.0/24 is directly connected, GigabitEthernet0/0
    L        10.3.3.2/32 is directly connected, GigabitEthernet0/0
    B        10.108.1.0/24 [20/3] via 10.3.3.1, 00:07:07
    B        10.108.2.0/24 [20/2] via 10.3.3.1, 00:07:07
    RTC#show ip bgp
    BGP table version is 8, local router ID is 10.3.3.2
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
                  r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
                  x best-external, a additional-path, c RIB-compressed, 
                  t secondary path, 
    Origin codes: i - IGP, e - EGP, ? - incomplete
    RPKI validation codes: V valid, I invalid, N Not found
         Network          Next Hop            Metric LocPrf Weight Path
     *>   10.2.2.0/24      10.3.3.1                 0             0 100 ?
     *>   10.108.1.0/24    10.3.3.1                 3             0 100 ?
     *>   10.108.2.0/24    10.3.3.1                 2             0 100 ?
    

    僅將OSPF外部(型別1和2)路由重分發到BGP

    router bgp 下使用 external 關鍵字以及 redistribute 命令將OSPF外部路由重新分發到BGP。使用 external 關鍵字時,有三個選擇:

      重新分發外部型別1和型別2(預設)

      Redistribute型別1

      Redistribute型別2


    按如下所述在配置模式下輸入命令:

    RTB(config-router)#router bgp 100
    RTB(config-router)#redistribute ospf 1 match external
    

    在路由器B的此配置中,僅重分發OSPF外部路由,但第1類和第2類均如此:

    hostname RTB
    interface GigabitEthernet0/0
     ip address 10.3.3.1 255.255.255.0
     duplex auto
     speed auto
     media-type rj45
    interface GigabitEthernet0/1
     ip address 10.2.2.3 255.255.255.0
     duplex auto
     speed auto
     media-type rj45  
    router ospf 1
     network 10.2.2.0 0.0.0.255 area 1  
    router bgp 100   
    redistribute ospf 1 match external 1 external 2

    !--- This redistributes ONLY OSPF External routes, but both type-1 and type-2.

    neighbor 10.3.3.2 remote-as 200
    !
    end

    附註: 配置顯示輸入的命令是 redistribute ospf 1 match external 。這是正常的,因為OSPF會自動在配置中附 加external 1 external 2。它匹配OSPF外部1路由和外部2路由,並將兩個路由重分發到BGP。

    路由器B僅重新分配OSPF外部路由:

    RTB#show ip bgp
    BGP table version is 25, local router ID is 10.3.3.1
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
                  r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
                  x best-external, a additional-path, c RIB-compressed, 
                  t secondary path, 
    Origin codes: i - IGP, e - EGP, ? - incomplete
    RPKI validation codes: V valid, I invalid, N Not found
         Network          Next Hop            Metric LocPrf Weight Path
     *>   192.168.1.0      10.2.2.2                20         32768 ?
     *>   192.168.2.0      10.2.2.2                23         32768 ?
    

    路由器C從BGP獲知這兩條OSPF外部路由:

    RTC#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
           a - application route
           + - replicated route, % - next hop override, p - overrides from PfR
    Gateway of last resort is not set
          10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
    C        10.3.3.0/24 is directly connected, GigabitEthernet0/0
    L        10.3.3.2/32 is directly connected, GigabitEthernet0/0
    B     192.168.1.0/24 [20/20] via 10.3.3.1, 00:02:16
    B     192.168.2.0/24 [20/23] via 10.3.3.1, 00:02:16
    
    RTC#show ip bgp BGP table version is 21, local router ID is 10.3.3.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, t secondary path, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *> 192.168.1.0 10.3.3.1 20 0 100 ? *> 192.168.2.0 10.3.3.1 23 0 100 ?

    僅將OSPF外部第1類或第2類路由重分發到BGP

    在路由器B上,在 router bgp 100 命令下輸入以下命令,以僅重新分發OSPF External 1路由:

    RTB(config)#router bgp 100 
    RTB(config-router)#redistribute ospf 1 match external 1

    使用先前的設定時,路由器B(RTB)BGP表顯示它只能將外部1路由重分配到BGP,而所有其他OSPF路由都不會重分配到BGP:

    RTB#show ip bgp
    BGP table version is 28, local router ID is 10.3.3.1
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
                  r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
                  x best-external, a additional-path, c RIB-compressed, 
                  t secondary path, 
    Origin codes: i - IGP, e - EGP, ? - incomplete
    RPKI validation codes: V valid, I invalid, N Not found
         Network          Next Hop            Metric LocPrf Weight Path
     *>   192.168.2.0      10.2.2.2                23         32768 ?
    

    同樣地,在路由器B的 router bgp 100 下輸入以下命令可僅重新分配OSPF外部2路由:

    RTB(config)#router bgp 100 
    RTB(config-router)#redistribute ospf 1 match external 2

    將OSPF內部和外部路由重分發到BGP

    在此案例中,所有OSPF路由都使用 redistribute ospf <process> match internal external 命令中的 internal external 關鍵字重新分發到BGP,如以下路由器B配置所示:

    hostname RTB
    interface GigabitEthernet0/0
     ip address 10.3.3.1 255.255.255.0
     duplex auto
     speed auto
     media-type rj45
    interface GigabitEthernet0/1
     ip address 10.2.2.3 255.255.255.0
     duplex auto
     speed auto
     media-type rj45  
    router ospf 1
     network 10.2.2.0 0.0.0.255 area 1  
    router bgp 100
    redistribute ospf 1 match internal external 1 external 2

    !--- This redistributes all OSPF routes into BGP.

    neighbor 10.3.3.2 remote-as 200
    !
    end


    同樣,配置中的 external 替換為 external 1 external 2 。這是正常現象,除非您指定要重分佈到BGP中的特定外部路由。配置更改完成後,路由器B重新分發所有OSPF路由,路由器C開始從BGP獲取所有路由:

    RTB#show ip bgp
    BGP table version is 6, local router ID is 10.3.3.1
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
                  r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
                  x best-external, a additional-path, c RIB-compressed, 
                  t secondary path, 
    Origin codes: i - IGP, e - EGP, ? - incomplete
    RPKI validation codes: V valid, I invalid, N Not found
         Network          Next Hop            Metric LocPrf Weight Path
     *>   10.2.2.0/24      0.0.0.0                  0         32768 ?
     *>   10.108.1.0/24    10.2.2.2                 3         32768 ?
     *>   10.108.2.0/24    10.2.2.2                 2         32768 ?
     *>   192.168.1.0      10.2.2.2                20         32768 ?
     *>   192.168.2.0      10.2.2.2                23         32768 ?
    RTB#  RTC#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
           a - application route
           + - replicated route, % - next hop override, p - overrides from PfR
    Gateway of last resort is not set
          10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
    B        10.2.2.0/24 [20/0] via 10.3.3.1, 00:03:27
    C        10.3.3.0/24 is directly connected, GigabitEthernet0/0
    L        10.3.3.2/32 is directly connected, GigabitEthernet0/0
    B        10.108.1.0/24 [20/3] via 10.3.3.1, 00:03:27
    B        10.108.2.0/24 [20/2] via 10.3.3.1, 00:03:27
    B     192.168.1.0/24 [20/20] via 10.3.3.1, 00:03:27
    B     192.168.2.0/24 [20/23] via 10.3.3.1, 00:03:27
    

    將OSPF NSSA外部路由重分發到BGP

    這是一種特殊情況,其中只有NSSA路由重新分發到BGP中。此案例與 僅重分佈到BGP中的OSPF外部(型別1和2)路由 一節中描述的情況非常相似。唯一的區別是OSPF現在匹配NSSA外部路由,而不是僅匹配外部路由。路由器B的路由表顯示了以下OSPF NSSA外部路由:

    RTB#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
           a - application route
           + - replicated route, % - next hop override, p - overrides from PfR
    Gateway of last resort is not set
          10.0.0.0/8 is variably subnetted, 6 subnets, 2 masks
    C        10.2.2.0/24 is directly connected, GigabitEthernet0/1
    L        10.2.2.3/32 is directly connected, GigabitEthernet0/1
    C        10.3.3.0/24 is directly connected, GigabitEthernet0/0
    L        10.3.3.1/32 is directly connected, GigabitEthernet0/0
    O IA     10.108.1.0/24 [110/3] via 10.2.2.2, 00:05:00, GigabitEthernet0/1
    O        10.108.2.0/24 [110/2] via 10.2.2.2, 00:05:00, GigabitEthernet0/1
    O N2  192.168.1.0/24 [110/20] via 10.2.2.1, 00:10:14, GigabitEthernet0/1
    O N1  192.168.2.0/24 [110/22] via 10.2.2.2, 00:03:43, GigabitEthernet0/1
    

    以下網路圖是適用於此案例的:

    Redistribution OSPF to BGP Topology B 將OSPF重新分發到BGP拓撲B

    網路圖顯示,路由器B同時收到OSPF N1和N2路由。如果僅使用 nssa-external 關鍵字,則預設行為是重分發N1和N2路由。路由器B的這種配置允許我們將OSPF N2(192.168.1.0/24)和OSPF N1(192.168.2.0/24)路由重分發到BGP:

    hostname RTB
    interface GigabitEthernet0/0
     ip address 10.3.3.1 255.255.255.0
     duplex auto
     speed auto
     media-type rj45
    interface GigabitEthernet0/1
     ip address 10.2.2.3 255.255.255.0
     duplex auto
     speed auto
     media-type rj45  
    router ospf 1
    area 1 nssa  network 10.2.2.0 0.0.0.255 area 1 
    !
    router bgp 100

    redistribute ospf 1 match nssa-external 1 nssa-external 2 !--- This redistributes only OSPF NSSA-external routes Type-1 and Type-2 into BGP. neighbor 10.3.3.2 remote-as 200

    附註: 與OSPF外部配置類似,先前的配置顯示 match nssa-external 1 nssa-external 2 ,並且輸入的命令為 redistribute ospf 1 match nssa-external。 這是正常的,因為OSPF會自動在配置中附加 nssa-external 1 nssa-external 2 。它匹配OSPF N1和OSPF N2路由,並將兩個路由重分發到BGP。

    在路由器B上更改配置後,它會重新分配OSPF NSSA外部路由,而路由器C從BGP獲取OSPF NSSA外部路由:

    RTB#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
           a - application route
           + - replicated route, % - next hop override, p - overrides from PfR
    Gateway of last resort is not set
          10.0.0.0/8 is variably subnetted, 6 subnets, 2 masks
    C        10.2.2.0/24 is directly connected, GigabitEthernet0/1
    L        10.2.2.3/32 is directly connected, GigabitEthernet0/1
    C        10.3.3.0/24 is directly connected, GigabitEthernet0/0
    L        10.3.3.1/32 is directly connected, GigabitEthernet0/0
    O IA     10.108.1.0/24 [110/3] via 10.2.2.2, 00:09:40, GigabitEthernet0/1
    O        10.108.2.0/24 [110/2] via 10.2.2.2, 00:09:40, GigabitEthernet0/1
    O N2  192.168.1.0/24 [110/20] via 10.2.2.1, 00:14:54, GigabitEthernet0/1
    O N1  192.168.2.0/24 [110/22] via 10.2.2.2, 00:08:23, GigabitEthernet0/1
    RTB#show ip bgp
    BGP table version is 17, local router ID is 10.3.3.1
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
                  r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
                  x best-external, a additional-path, c RIB-compressed, 
                  t secondary path, 
    Origin codes: i - IGP, e - EGP, ? - incomplete
    RPKI validation codes: V valid, I invalid, N Not found
         Network          Next Hop            Metric LocPrf Weight Path
     *>   192.168.1.0      10.2.2.1                20         32768 ?
     *>   192.168.2.0      10.2.2.2                22         32768 ?
    RTB#  RTC#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
           a - application route
           + - replicated route, % - next hop override, p - overrides from PfR
    Gateway of last resort is not set
          10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
    C        10.3.3.0/24 is directly connected, GigabitEthernet0/0
    L        10.3.3.2/32 is directly connected, GigabitEthernet0/0
    B     192.168.1.0/24 [20/20] via 10.3.3.1, 00:01:29
    B     192.168.2.0/24 [20/22] via 10.3.3.1, 00:01:29
    RTC#show ip bgp
    BGP table version is 41, local router ID is 10.3.3.2
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
                  r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
                  x best-external, a additional-path, c RIB-compressed, 
                  t secondary path, 
    Origin codes: i - IGP, e - EGP, ? - incomplete
    RPKI validation codes: V valid, I invalid, N Not found
         Network          Next Hop            Metric LocPrf Weight Path
     *>   192.168.1.0      10.3.3.1                20             0 100 ?
     *>   192.168.2.0      10.3.3.1                22             0 100 ?
    

    與OSPF外部路由一樣,要僅重分發OSPF N1路由,請在路由器B的路由器BGP 100下輸入以下命令:

    RTB(config)#router bgp 100 
    RTB(config-router)#redistribute ospf 1 match nssa-external 1

    !--- This redistributes only OSPF NSSA-external Type-1 routes into BGP.

    要僅重分發OSPF N2路由,請在路由器B的路由器BGP 100下輸入以下命令:

    RTB(config)#router bgp 100  
    RTB(config-router)#
    redistribute ospf 1 match nssa-external 2

    !--- This redistributes only OSPF NSSA-external Type-2 routes into BGP.

    附註: 路由對映還可用於將OSPF型別1/2重分發到BGP。有關詳細資訊,請參閱 在BGP中重分發OSPF E2路由

    修改OSPF中的重分發選項

    瞭解連續配置更改如何改變配置非常重要。帶有match選項的新命令不會覆蓋上一個命令,但會新增到該命令中。下一個示例說明配置命令序列如何影響重分發:

    R4#configure terminal
    R4(config)#router bgp 100
    R4(config-router)#redistribute ospf 1 match internal
    R4(config-router)#^Z
    !--- Initially, you redistribute internal OSPF routes into BGP 100.
    R4#show run | include redistribute ospf
     redistribute ospf 1 match internal
    R4#configure terminal
    R4(config)#router bgp 100
    R4(config-router)#redistribute ospf 1 match external
    R4(config-router)#^Z
    !--- With this second command, you tell BGP to also redistribute external OSPF routes.
    R4#show run | include redistribute ospf
     redistribute ospf 1 match internal external 1 external 2
    R4#configure terminal
    R4(config)#router bgp 100
    R4(config-router)#no redistribute ospf 1 match external 2
    R4(config-router)#^Z
    !--- With this no command, you only disable the redistribution of external type 2 into BGP. 
    !--- All other types of routes previously configured remain. R4#show run | include redistribute ospf redistribute ospf 1 match internal external 1 !--- As you can see, internal and external type 1 remain. R4#configure terminal R4(config)#router bgp 100 R4(config-router)#no redistribute ospf 1 match internal external 1 R4(config-router)#^Z !--- Now, with this no command, which includes all configured keywords, it is important to note that you
    !--- still do not disable the redistribution fully. you only removed the keyword. After this,
    !--- the Cisco IOS still acts as the default—redistributing internal routes only. R4#show run | include redistribute ospf redistribute ospf 1 R4#configure terminal R4(config)#router bgp 100 R4(config-router)#no redistribute ospf 1 !--- Always use the previous command in order to completely disable redistribution. R4(config-router)# ^Z R4#show run | include redistribute ospf


    無法將iBGP獲知的路由重分發到IGP(如EIGRP和OSPF)

    路由重分發用於將通過使用一種協定獲知的路由傳播到另一種路由協定中。將BGP重新分發到IGP中時,只有eBGP獲知的路由會重新分發。內部邊界網關協定(iBGP)在路由器上獲知的路由不會引入到IGP中,以防止產生路由環路。

    預設情況下,iBGP重分發到IGP是禁用的。發出 bgp redistribute-internal 命令以啟用iBGP路由重分配到IGP。需要採取預防措施,才能使用路由對映將特定路由重分配到IGP中。

    將iBGP路由重分發到OSPF的示例配置如下所示:

    Router(config)#router bgp 65345 
    Router(config-router)#bgp redistribute-internal
    Router(config)#router ospf 100
    Router(config-router)#redistribute bgp 65345 subnets

    附註: 將iBGP路由重新分發到內部網關協定可能導致自治系統(AS)中的路由環路。 不建議這樣做。需要設定路由過濾器以控制匯入IGP中的資訊。

    將OSPF預設路由重分發到BGP

    若要將預設路由重分發到BGP,請使用 network 語句和 default-information originate 。在本示例中,OSPF預設路由重分發到BGP。這可以通過建立路由對映和分配預設網路(標準ACL允許)來完成。

    route-map map_default_only permit 10 match ip address acl_default_only ip access-list standard acl_default_only permit 0.0.0.0 router bgp 64601 network 0.0.0.0 redistribute ospf 1 route-map map_default_only default-information originate !

    !--- Distributes the default route in bgp

    設定後,使用 clear ip bgp * 命令清除bgp作業階段。

    相關資訊