簡介
本文檔介紹如何在基於Cisco Nexus NXOS®的交換機上配置路由重分發。
必要條件
需求
思科建議您瞭解以下主題:
- Nexus NX-OS軟體。
- 路由協定:開放最短路徑優先(OSPF)、邊界網關協定(BGP)、增強型內部網關路由協定(EIGRP)。
採用元件
本文檔中的資訊基於NXOS版本10.2.5.M的Cisco Nexus 9000。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
設定
網路圖表
![Redistribution](/c/dam/en/us/support/docs/switches/nexus-9000-series-switches/220615-configure-route-redistribution-on-nexus-00.jpeg)
loopback0 192.168.1.1/32
loopback0 192.168.2.1/32
loopback10 172.16.9.1/32
- NEXUS D正在通告EIGRP進程19中的環回:
loopback10 172.16.21.1/32
組態
在這種情況下,Nexus交換機已使用OSPF、iBGP和EIGRP會話建立鄰居會話。
注意:當在單個路由器的兩個或多個路由協定之間重分發時,重分發不可傳遞。簡而言之,如果路由器將協定1重新分發到協定2,然後協定2重新分發到協定3,則來自協定1的路由不會重新分發到協定3。
重新分發到OSPF。
NEXUS B:
步驟 1.使用需要重新分發的字首配置字首清單。
Nexus-B(config)# ip prefix-list REDISTRIBUTION seq 5 permit 0.0.0.0/0 le 32
注意:通過在步驟2上配置空白路由對映可以跳過此步驟,0.0.0.0/0 le 32 inside prefix-list允許所有路由,本文中字首清單配置的意圖旨在說明您可以選擇/過濾重新分發的路由。
步驟 2.建立與字首清單中指定的條件匹配的路由對映。
Nexus-B(config)# route-map BGP-TO-OSPF permit 10
Nexus-B(config-route-map)# match ip address prefix-list REDISTRIBUTION
Nexus-B(config-route-map)# match route-type internal
注意:match route-type internal命令是重分發iBGP路由的要求,預設情況下,僅重分發eBGP路由。
步驟 3.將來自其他協定(本例中為iBGP)的路由重分發到OSPF。
Nexus-B(config)# router ospf 21
Nexus-B(config-router)# router-id 2.2.2.2
Nexus-B(config-router)# redistribute bgp 6500 route-map BGP-TO-OSPF
重新分發到BGP。
NEXUS B:
步驟 1. 使用需要重新分發的字首配置字首清單。
Nexus-B(config)# ip prefix-list REDISTRIBUTION seq 5 permit 0.0.0.0/0 le 32
步驟 2. 建立與字首清單中指定的條件匹配的路由對映。
Nexus-B(config)# route-map OSPF-TO-BGP permit 10
Nexus-B(config-route-map)# match ip address prefix-list REDISTRIBUTION
步驟 3. 將路由重分佈到來自另一個協定(本例中為OSPF)的BGP中。
Nexus-B(config)# router bgp 6500
Nexus-B(config-router)# address-family ipv4 unicast
Nexus-B(config-router-af)# redistribute ospf 21 route-map OSPF-TO-BGP
Nexus-B(config-router-af)# neighbor 10.24.1.2
Nexus-B(config-router-neighbor)# remote-as 6500
Nexus-B(config-router-neighbor)# address-family ipv4 unicast
NEXUS C:
步驟 1. 使用需要重新分發的字首配置字首清單。
Nexus-C(config)# ip prefix-list REDISTRIBUTION seq 5 permit 0.0.0.0/0 le 32
步驟 2. 建立與字首清單中指定的條件匹配的路由對映。
Nexus-C(config)# route-map EIGRP-TO-BGP permit 10
Nexus-C(config-route-map)# match ip address prefix-list REDISTRIBUTION
步驟 3. 將路由重分佈到來自另一個協定(本例中為EIGRP)的BGP中。
Nexus-C(config)# router bgp 6500
Nexus-C(config-router)# address-family ipv4 unicast
Nexus-C(config-router-af)# redistribute eigrp 19 route-map EIGRP-TO-BGP
Nexus-C(config-router-af)# neighbor 10.24.1.1
Nexus-C(config-router-neighbor)# remote-as 6500
Nexus-C(config-router-neighbor)# address-family ipv4 unicast
重新分發到EIGRP。
NEXUS C:
步驟 1. 使用需要重新分發的字首配置字首清單。
Nexus-C(config)# ip prefix-list REDISTRIBUTION seq 5 permit 0.0.0.0/0 le 32
步驟 2. 建立與字首清單中指定的條件匹配的路由對映。
Nexus-C(config)# route-map BGP-TO-EIGRP permit 10
Nexus-C(config-route-map)# match ip address prefix-list REDISTRIBUTION
Nexus-C(config-route-map)# match route-type internal
步驟 3. 將路由重分佈到來自另一個協定(本例中為OSPF)的EIGRP中。
Nexus-C(config)# router eigrp 19
Nexus-C(config-router)# address-family ipv4 unicast
Nexus-C(config-router-af)# autonomous-system 17
Nexus-C(config-router-af)# router-id 11.11.11.11
Nexus-C(config-router-af)# redistribute bgp 6500 route-map BGP-TO-EIGRP
驗證
配置重分發後,Nexus裝置開始接收來自其他協定的路由,這些路由顯示為外部路由。
Nexus-A路由表:
Nexus-A# show ip route ospf-21
IP Route Table for VRF "default"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%
' in via output denotes VRF
172.16.21.1/32, ubest/mbest: 1/0 *via 10.12.1.2, Eth1/36, [110/1], 00:00:57, ospf-21, type-2, tag 6500 <<< <<< this prefix is external to OSPF as it is coming from redistribution, originated from Nexus-B, the original route comes from Nexus-D. 192.168.2.1/32, ubest/mbest: 1/0 *via 10.12.1.2, Eth1/36, [110/2], 00:00:57, ospf-21, intra Nexus-A# show ip route direct IP Route Table for VRF "default" '*' denotes best ucast next-hop '**' denotes best mcast next-hop '[x/y]' denotes [preference/metric] '%
' in via output denotes VRF
10.12.1.0/24, ubest/mbest: 1/0, attached *via 10.12.1.1, Eth1/36, [0/0], 01:37:21, direct 192.168.1.1/32, ubest/mbest: 2/0, attached *via 192.168.1.1, Lo0, [0/0], 23:42:19, direct
Nexus-B路由表:
Nexus-B# show ip route ospf-21
IP Route Table for VRF "default"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%
' in via output denotes VRF
192.168.1.1/32, ubest/mbest: 1/0 *via 10.12.1.1, Eth1/49, [110/2], 00:15:08, ospf-21, intra Nexus-B# show ip route bgp-6500 IP Route Table for VRF "default" '*' denotes best ucast next-hop '**' denotes best mcast next-hop '[x/y]' denotes [preference/metric] '%
' in via output denotes VRF
172.16.21.1/32, ubest/mbest: 1/0 *via 10.24.1.2, [200/128576], 00:19:49, bgp-6500, internal, tag 6500 <<< This prefix is learned by iBGP from Nexus-C, the original route is coming from the EIGRP redistribution, originated from NexusD.
Nexus-C路由表:
Nexus-C# show ip route bgp-6500
IP Route Table for VRF "default"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%
' in via output denotes VRF
192.168.1.1/32, ubest/mbest: 1/0 *via 10.24.1.1, [200/2], 00:15:59, bgp-6500, internal, tag 6500 <<< This prefix is coming from iBGP, the route was originated from Nexus-A. Nexus-C# show ip route eigrp-19 IP Route Table for VRF "default" '*' denotes best ucast next-hop '**' denotes best mcast next-hop '[x/y]' denotes [preference/metric] '%
' in via output denotes VRF
172.16.21.1/32, ubest/mbest: 1/0 *via 10.36.1.2, Eth1/49, [90/128576], 00:26:03, eigrp-19, internal
重分發統計資訊,僅用於EIGRP:
Nexus-C# show ip eigrp 19 route-map statistics redistribute bgp 6500
IP-EIGRP Route-map Traffic Statistics for AS 17 VRF default
C: No. of comparisions, M: No. of matches
route-map BGP-TO-EIGRP permit 10
match ip address prefix-list REDISTRIBUTION C: 2 M: 2
match route-type internal C: 2 M: 2
Total accept count for policy: 2
Total reject count for policy: 0
Nexus-D路由表:
Nexus-D# show ip route eigrp-19
IP Route Table for VRF "default"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%
' in via output denotes VRF
172.16.9.1/32, ubest/mbest: 1/0 *via 10.36.1.1, Eth1/2, [90/128576], 00:29:14, eigrp-19, internal 192.168.1.1/32, ubest/mbest: 1/0 *via 10.36.1.1, Eth1/2, [170/51456], 00:12:49, eigrp-19, external, tag 6500 <<< This prefix is external to EIGRP as it is coming from redistribution, it comes from BGP but it was originated on Nexus-A. Nexus-D# sh ip route direct IP Route Table for VRF "default" '*' denotes best ucast next-hop '**' denotes best mcast next-hop '[x/y]' denotes [preference/metric] '%
' in via output denotes VRF
10.36.1.0/24, ubest/mbest: 1/0, attached *via 10.36.1.2, Eth1/2, [0/0], 1d00h, direct 172.16.21.1/32, ubest/mbest: 2/0, attached *via 172.16.21.1, Lo10, [0/0], 01:47:30, direct
Nexus-B(config)# router bgp 6500
Nexus-B(config-router)# address-family ipv4 unicast
Nexus-B(config-router-af)# redistribute ospf 21 route-map OSPF-TO-BGP
Nexus-B(config-router-af)# neighbor 10.24.1.2
Nexus-B(config-router-neighbor)# remote-as 6500
Nexus-B(config-router-neighbor)# address-family ipv4 unicast