简介
本文档介绍用于将默认路由通告给基于Cisco Nexus NX-OS的交换机上的BGP邻居的配置边界网关协议。
先决条件
要求
思科建议事先了解以下主题:
- Nexus NX-OS软件
- 路由协议,特别是边界网关协议(BGP)。
使用的组件
本文档中的信息基于采用NX-OS版本7.3(0)D1(1)的Cisco Nexus 7000。
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
配置
network 命令
network 0.0.0.0/0 命令可在 BGP 路由信息库 (BGP RIB) 中注入默认路由。
前提条件是通过任何其他路由协议或使用静态路由手动配置所获得的路由表中存在默认路由。
默认路由注入 BGP RIB 后,如果为每个邻居分别进行配置的出站过滤器未明确拒绝,便会通告给所有 BGP 邻居。
show running-config 输出中的 BGP 配置:
Nexus BGP 配置 |
Nexus# show running-config bgp
!Command: show running-config bgp
!Time: Tue Dec 4 01:27:43 2018
version 7.3(0)D1(1)
feature bgp
router bgp 64512
address-family ipv4 unicast
network 0.0.0.0/0
neighbor 10.1.3.3
remote-as 64512
address-family ipv4 unicast
|
在本例中,Nexus从增强型内部网关路由协议(EIGRP)协议接收默认路由。因此,Nexus 路由表显示,默认路由通过 EIGRP 获得。
Nexus 路由表 |
Nexus# show ip route 0.0.0.0 IP Route Table for VRF "default" '*' denotes best ucast next-hop '**' denotes best mcast next-hop '[x/y]' denotes [preference/metric] '%<string>' in via output denotes VRF <string>
0.0.0.0/0, ubest/mbest: 1/0 *via 10.1.2.2, Eth2/1, [170/2816], 00:00:50, eigrp-1, external Nexus# |
由于满足前提条件,BGP RIB 显示 0.0.0.0/0 为有效最佳路径,默认路由在路由表中,network 0.0.0.0/0命令在BGP配置部分配置。
Nexus BGP RIB(BGP 表) |
Nexus# show bgp ipv4 unicast
BGP routing table information for VRF default, address family IPv4 Unicast
BGP table version is 13, local router ID is 10.255.255.1
Status: s-suppressed, x-deleted, S-stale, d-dampened, h-history, *-valid, >-best
Path type: i-internal, e-external, c-confed, l-local, a-aggregate, r-redist, I-i
njected
Origin codes: i - IGP, e - EGP, ? - incomplete, | - multipath, & - backup
Network Next Hop Metric LocPrf Weight Path
*>l0.0.0.0/0 0.0.0.0 100 32768 i
|
advertised-routes参数显示向BGP对等体10.1.3.3通告默认路由。
向特定 BGP 对等体通告的 Nexus BGP 路由 |
Nexus# show bgp ipv4 unicast neighbors 10.1.3.3 advertised-routes
Peer 10.1.3.3 routes for address family IPv4 Unicast:
BGP table version is 13, local router ID is 10.255.255.1
Status: s-suppressed, x-deleted, S-stale, d-dampened, h-history, *-valid, >-best
Path type: i-internal, e-external, c-confed, l-local, a-aggregate, r-redist, I-i
njected
Origin codes: i - IGP, e - EGP, ? - incomplete, | - multipath, & - backup
Network Next Hop Metric LocPrf Weight Path
*>l0.0.0.0/0 0.0.0.0 100 32768 i
|
Redistribute 命令和 Default-Information Originate 命令
在 BGP 进程中配置的 redistribute 命令通过特定源路由协议(且已获 route-map 许可),在 BGP RIB 中注入路由表中除默认路由之外的所有路由。
此外,要允许从BGP RIB中的源路由协议安装默认路由,需要命令default-information originate。
默认路由注入 BGP RIB 后,如果为每个邻居分别进行配置的出站过滤器未明确拒绝,便会通告给所有 BGP 邻居。
BGP 配置部分显示已使用 redistribute eigrp 和 default-information originate 命令。
Nexus BGP 配置 |
Nexus# show running-config bgp
!Command: show running-config bgp
!Time: Tue Dec 4 01:33:41 2018
version 7.3(0)D1(1)
feature bgp
router bgp 64512
address-family ipv4 unicast
redistribute eigrp 1 route-map PERMIT-ALL
default-information originate
neighbor 10.1.3.3
remote-as 64512
address-family ipv4 unicast
A route map with no match entry permits all routes.
route-map PERMIT-ALL permit 10 |
在本例中,Nexus 接收的默认路由来自 EIGRP 协议。因此,Nexus 路由表显示,默认路由通过 EIGRP 获得。
Nexus 路由表 |
Nexus# show ip route eigrp
IP Route Table for VRF "default"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%<string>' in via output denotes VRF <string>
0.0.0.0/0, ubest/mbest: 1/0
*via 10.1.2.2, Eth2/1, [170/2816], 00:07:19, eigrp-1, external
192.168.2.0/24, ubest/mbest: 1/0
*via 10.1.2.2, Eth2/1, [170/2816], 00:00:07, eigrp-1, external
|
BGP RIB显示0.0.0.0/0为有效路径,并且满足前提条件。默认路由已从BGP中的源路由协议重分配,并且BGP配置部分中配置了default-information originate命令。
Nexus BGP RIB(BGP 表) |
Nexus# show bgp ipv4 unicast
BGP routing table information for VRF default, address family IPv4 Unicast
BGP table version is 17, local router ID is 10.255.255.1
Status: s-suppressed, x-deleted, S-stale, d-dampened, h-history, *-valid, >-best
Path type: i-internal, e-external, c-confed, l-local, a-aggregate, r-redist, I-i
njected
Origin codes: i - IGP, e - EGP, ? - incomplete, | - multipath, & - backup
Network Next Hop Metric LocPrf Weight Path
*>r0.0.0.0/0 0.0.0.0 2816 100 32768 ?
*>r192.168.2.0/24 0.0.0.0 2816 100 32768 ?
|
advertised-routes参数显示向BGP对等体10.1.3.3通告默认路由。
向特定 BGP 对等体通告的 Nexus BGP 路由 |
Nexus# show bgp ipv4 unicast neighbors 10.1.3.3 advertised-routes
Peer 10.1.3.3 routes for address family IPv4 Unicast:
BGP table version is 17, local router ID is 10.255.255.1
Status: s-suppressed, x-deleted, S-stale, d-dampened, h-history, *-valid, >-best
Path type: i-internal, e-external, c-confed, l-local, a-aggregate, r-redist, I-i
njected
Origin codes: i - IGP, e - EGP, ? - incomplete, | - multipath, & - backup
Network Next Hop Metric LocPrf Weight Path
*>r0.0.0.0/0 0.0.0.0 2816 100 32768 ?
*>r192.168.2.0/24 0.0.0.0 2816 100 32768 ?
|
如果 BGP 配置中未使用 default-information originate 命令,则 BGP RIB 不会安装默认路由。
接下来的 BGP 配置部分显示仅使用 redistribute eigrp 命令。
Nexus BGP 配置 |
Nexus# show run bgp
!Command: show running-config bgp
!Time: Tue Dec 4 01:39:30 2018
version 7.3(0)D1(1)
feature bgp
router bgp 64512
address-family ipv4 unicast
redistribute eigrp 1 route-map PERMIT-ALL
neighbor 10.1.3.3
remote-as 64512
address-family ipv4 unicast
A route-map with no match entry permits all routes.
route-map PERMIT-ALL permit 10 |
路由表输出显示,默认路由通过 EIGRP 协议获得。
Nexus 路由表 |
Nexus# show ip route eigrp
IP Route Table for VRF "default"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%<string>' in via output denotes VRF <string>
0.0.0.0/0, ubest/mbest: 1/0
*via 10.1.2.2, Eth2/1, [170/2816], 00:07:19, eigrp-1, external
192.168.2.0/24, ubest/mbest: 1/0
*via 10.1.2.2, Eth2/1, [170/2816], 00:00:07, eigrp-1, external
|
如果未使用 default-information originate 命令,BGP RIB 不会安装 0.0.0.0/0 网络前缀。
Nexus BGP RIB(BGP 表) |
Nexus# show bgp ipv4 unicast
BGP routing table information for VRF default, address family IPv4 Unicast
BGP table version is 18, local router ID is 10.255.255.1
Status: s-suppressed, x-deleted, S-stale, d-dampened, h-history, *-valid, >-best
Path type: i-internal, e-external, c-confed, l-local, a-aggregate, r-redist, I-i
njected
Origin codes: i - IGP, e - EGP, ? - incomplete, | - multipath, & - backup
Network Next Hop Metric LocPrf Weight Path
*>r192.168.2.0/24 0.0.0.0 2816 100 32768 ?
|
注意:在Nexus 7000系列的NX-OS版本6.2(2)和Nexus 5000系列的6.0(2)N3(1)版本之前,不需要使用default-information originate命令。也曾通过redistribute命令在BGP RIB中注入默认路由。
Default-Originate 命令
default-originate 命令基于每个 BGP 邻居分别进行配置。此命令可人为生成默认路由,仅将其通告给特定的 BGP 对等体。
默认路由无需存在于路由表中,而且不会在BGP RIB中创建。
default-originate 命令基于每个邻居分别进行配置。
Nexus BGP 配置 |
Nexus# show running-config bgp
!Command: show running-config bgp !Time: Tue Dec 4 02:22:43 2018
version 7.3(0)D1(1) feature bgp
router bgp 64512 address-family ipv4 unicast network 192.168.1.0/24 neighbor 10.1.3.3 remote-as 64512 address-family ipv4 unicast default-originate |
路由表中无需存在默认路由。
Nexus 路由表 |
Nexus# show ip route 0.0.0.0
IP Route Table for VRF "default"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%<string>' in via output denotes VRF <string>
Nexus# |
BGP 表中未创建编号为 0.0.0.0/0 的条目。
Nexus BGP RIB(BGP 表) |
Nexus# show bgp ipv4 unicast
BGP routing table information for VRF default, address family IPv4 Unicast
BGP table version is 20, local router ID is 10.255.255.1
Status: s-suppressed, x-deleted, S-stale, d-dampened, h-history, *-valid, >-best
Path type: i-internal, e-external, c-confed, l-local, a-aggregate, r-redist, I-i
njected
Origin codes: i - IGP, e - EGP, ? - incomplete, | - multipath, & - backup
Network Next Hop Metric LocPrf Weight Path
*>l192.168.1.0/24 0.0.0.0 100 32768 i
|
在通告给 BGP 对等体 10.1.3.3 的路由中,可以找到条目 Originating default network 0.0.0.0/0
向特定 BGP 对等体通告的 Nexus BGP 路由 |
Nexus# show bgp ipv4 unicast neighbors 10.1.3.3 advertised-routes
Peer 10.1.3.3 routes for address family IPv4 Unicast:
BGP table version is 20, local router ID is 10.255.255.1
Status: s-suppressed, x-deleted, S-stale, d-dampened, h-history, *-valid, >-best
Path type: i-internal, e-external, c-confed, l-local, a-aggregate, r-redist, I-i
njected
Origin codes: i - IGP, e - EGP, ? - incomplete, | - multipath, & - backup
Originating default network 0.0.0.0/0
Network Next Hop Metric LocPrf Weight Path
*>l192.168.1.0/24 0.0.0.0 100 32768 i
|
或者,default-originate 命令可以使用 route-map 作为参数,有条件地通告默认路由。
可选的 default-originate route-map |
Nexus(config-router-neighbor-af)# default-originate ?
<CR>
route-map Route-map to specify criteria for originating default |
route-map 需要与路由表中安装的路由匹配,才能使 default-originate 向 BGP 对等体通告默认路由。
Nexus 路由表 |
Nexus# show ip route 192.168.3.0
IP Route Table for VRF "default"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%<string>' in via output denotes VRF <string>
Route not found
|
在这种情况下,名为ADVERTISE-DEFAULT-IF的路由映射引用一个名为NETWORKS的前缀列表和后一个192.168.3.0/24网络前缀,这些前缀必须存在于路由表中才能通告默认路由。
Nexus BGP 配置 |
ip prefix-list NETWORKS seq 5 permit 192.168.3.0/24 !
route-map ADVERTISE-DEFAULT-IF permit 10
match ip address prefix-list NETWORKS ! router bgp 64512 address-family ipv4 unicast network 192.168.1.0/24 neighbor 10.1.3.3 remote-as 64512 address-family ipv4 unicast default-originate route-map ADVERTISE-DEFAULT-IF |
由于路由表中没有 192.168.3.0/24,因此不会通告默认路由。
向特定 BGP 对等体通告的 Nexus BGP 路由 |
Nexus# show bgp ipv4 unicast neighbors 10.1.3.3 advertised-routes
Peer 10.1.3.3 routes for address family IPv4 Unicast:
BGP table version is 20, local router ID is 10.255.255.1
Status: s-suppressed, x-deleted, S-stale, d-dampened, h-history, *-valid, >-best
Path type: i-internal, e-external, c-confed, l-local, a-aggregate, r-redist, I-i
njected
Origin codes: i - IGP, e - EGP, ? - incomplete, | - multipath, & - backup
Network Next Hop Metric LocPrf Weight Path
*>l192.168.1.0/24 0.0.0.0 100 32768 i
|