简介
本文档介绍如何在基于Cisco Nexus NXOS®的交换机上配置路由重分发。
先决条件
要求
Cisco 建议您了解以下主题:
- Nexus NX-OS 软件。
- 路由协议:开放最短路径优先(OSPF)、边界网关协议(BGP)、增强型内部网关路由协议(EIGRP)。
使用的组件
本文档中的信息基于NXOS版本10.2.5.M的Cisco Nexus 9000。
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
配置
网络图
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允许所有路由,本文中前缀列表配置的目的是说明您可以选择/过滤重新分发的路由。
第二步:创建与前缀列表中指定的条件匹配的路由映射。
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
注意:重分配iBGP路由要求使用match route-type internal命令,默认情况下,仅重分配eBGP路由。
第三步:将来自其他协议(本例中为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
第二步: 创建与前缀列表中指定的条件匹配的路由映射。
Nexus-B(config)# route-map OSPF-TO-BGP permit 10
Nexus-B(config-route-map)# match ip address prefix-list REDISTRIBUTION
第三步: 将路由重新分发到来自另一个协议(本例中为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
第二步: 创建与前缀列表中指定的条件匹配的路由映射。
Nexus-C(config)# route-map EIGRP-TO-BGP permit 10
Nexus-C(config-route-map)# match ip address prefix-list REDISTRIBUTION
第三步: 将来自另一个协议(本例中为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
第二步: 创建与前缀列表中指定的条件匹配的路由映射。
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
第三步: 将来自其他协议(本例中为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