边界网关协议 (BGP) 条件通告功能可以根据 BGP 表中是否存在其他前缀,提供对路由通告的更多控制。
在尝试此配置之前,请确保熟悉:
Cisco IOS.软件版本11.1CC和11.2介绍了本文描述的BGP条件通告功能,该功能在以后版本中同样能够使用。
本文档中的信息基于以下软件和硬件版本:
Cisco IOS® 软件版本 12.2(13)T13
Cisco 2500 系列路由器
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您使用的是真实网络,请确保您已经了解所有命令的潜在影响。
通常,会传播路由,而不管是否存在不同的路径。BGP 条件通告功能使用 neighbor advertise-map 命令的 non-exist-map 和 advertise-map 关键词,目的是按路由前缀跟踪路由。如果路由前缀不出现在non-exist-map命令输出中,那就公布advertise-map命令指定的路由。此功能对于多宿主网络非常有用,在多宿主网络中,只有在来自其他提供商的信息不存在时,才会将有些前缀通告给其中一个提供商(这表示在对等会话中出现故障或出现部分可达性问题)。
除了BGP路由器发送到其对等体的正常公告之外,还发送有条件的BGP公告。
有关文件规则的更多信息请参见“ Cisco技术提示规则”。
本部分提供有关如何配置本文档所述功能的信息。
注意:要查找有关本文档中使用的命令的其他信息,请使用IOS命令查找工具
本文档使用此图所示的网络设置。
此处,R103的环回接口用于通告192.168.50.0/24到R102。R102有一个BGP网络128.16.16.0/24,默认情况下,该网络会通告给其外部BGP(eBGP)对等体R101和R103。
使用 BGP 条件通告功能,您现在可以在 R102 上完成以下任务:
如果192.168.50.0/24在R102的BGP协议表中存在,那么请勿将128.16.16.0/24网络通告给R101。
如果R102的 BGP协议表不存在192.168.50.0/24,则向R101通告128.16.16.0/24网络。
在 Cisco IOS® 12.2T 或更高版本中,exist-map 关键字也可以用于完成以下任务:
如果 192.168.50.0/24 存在于 R102 的 BGP 表中,则向 R101 通告 128.16.16.0/24 网络。
如果 192.168.50.0/24 不存在于 R102 的 BGP 表中,则不向 R101 通告 128.16.16.0/24 网络。
本文档使用以下配置:
注意:此示例讨论non-exist-map关键字。exist-map 关键字的用法与此类似。
R102 |
---|
hostname R102 ! interface Loopback0 ip address 128.16.16.1 255.255.255.0 ! interface Serial8/0 ip address 10.10.10.2 255.255.255.0 ! interface Serial9/0 ip address 10.10.20.2 255.255.255.0 ! router bgp 2 bgp log-neighbor-changes network 128.16.16.0 mask 255.255.255.0 network 130.130.0.0 neighbor 10.10.10.1 remote-as 1 neighbor 10.10.10.1 advertise-map ADVERTISE non-exist-map NON-EXIST !--- Advertises the routes matched in the route-map ADVERTISE (128.16.16.0/24) !--- only if the routes matched in route-map NON-EXIST (192.168.50.0/24) !--- do not exist in the BGP table. neighbor 10.10.20.3 remote-as 3 ! ip route 130.130.0.0 255.255.0.0 Null0 ! access-list 60 permit 128.16.16.0 0.0.0.255 access-list 65 permit 192.168.50.0 0.0.0.255 ! route-map NON-EXIST permit 10 match ip address 65 ! route-map ADVERTISE permit 10 match ip address 60 ! |
R103 |
---|
hostname R103 ! interface Loopback0 ip address 192.168.50.1 255.255.255.0 ! interface Serial9/0 ip address 10.10.20.3 255.255.255.0 ! router bgp 3 bgp log-neighbor-changes network 192.168.50.0 neighbor 10.10.20.2 remote-as 2 ! |
R101 |
---|
hostname R101 ! interface Loopback0 ip address 200.200.200.1 255.255.255.0 ! interface Serial8/0 ip address 10.10.10.1 255.255.255.0 ! router bgp 1 bgp log-neighbor-changes network 200.200.200.0 neighbor 10.10.10.2 remote-as 2 ! |
此示例验证当 R102 的 BGP 表中存在 192.168.50.0/24 时 BGP 的情况:
首先查看 192.168.50.0/24 是否存在于 R102 的 BGP 表中:
R102# show ip bgp BGP table version is 6, local router ID is 128.16.16.1 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 *> 128.16.16.0/24 0.0.0.0 0 32768 i *> 130.130.0.0 0.0.0.0 0 32768 i *> 192.168.50.0 10.10.20.3 0 0 3 i *> 200.200.200.0 10.10.10.1 0 0 1 i
由于 192.168.50.0/24 存在于 R102 的 BGP 表中,因此 R102 不能向 R101 通告 128.16.16/24。
R102# show ip bgp neighbors 10.10.10.1 advertised-routes BGP table version is 6, local router ID is 128.16.16.1 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 *> 130.130.0.0 0.0.0.0 0 32768 i *> 192.168.50.0 10.10.20.3 0 0 3 i !--- Note 128.16.16.0/24 is not advertised to neighbor 10.10.10.1. R102# show ip bgp 128.16.16.0 BGP routing table entry for 128.16.16.0/24, version 6 Paths: (1 available, best #1, table Default-IP-Routing-Table) Advertised to non peer-group peers: !--- This is not advertised to R101. 10.10.20.3 Local 0.0.0.0 from 0.0.0.0 (128.16.16.1) Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
然后检查 R102 上条件通告的状态:
R102# show ip bgp neighbors 10.10.10.1 BGP neighbor is 10.10.10.1, remote AS 1, external link BGP version 4, remote router ID 200.200.200.1 BGP state = Established, up for 02:27:07 Last read 00:00:07, hold time is 180, keepalive interval is 60 seconds !--- Output suppressed. For address family: IPv4 Unicast BGP table version 6, neighbor version 6 Index 1, Offset 0, Mask 0x2 Condition-map NON-EXIST, Advertise-map ADVERTISE, status: Withdraw 1 accepted prefixes consume 36 bytes Prefix advertised 3, suppressed 0, withdrawn 1 Number of NLRIs in the update sent: max 1, min 0 !--- Output suppressed.
输出显示条件通告已“撤销”,并且与路由映射“ADVERTISE”匹配的网络未通告给对等体 10.10.10.1。
要确认未向 R101 通告与路由映射“ADVERTISE”匹配的路由,请检查 R101 上的 BGP 表:
R101# show ip bgp 128.16.16.0 % Network not in table
此示例显示当 R102 的 BGP 表中不存在网络 192.168.50.0/24 时 BGP 的情况:
首先,关闭 R103 上的环回接口 0,防止 R103 再向 R102 通告 192.168.50.0/24。
R103(config)# interface loopback 0 R103(config-if)# shutdown R103(config-if)# 03:29:36: %LINK-5-CHANGED: Interface Loopback0, changed state to administratively down
然后验证 R102 没有获知 192.168.50.0/24,并且网络不包括在 R102 的 BGP 表中。
R102# show ip bgp BGP table version is 8, local router ID is 128.16.16.1 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 *> 128.16.16.0/24 0.0.0.0 0 32768 i *> 130.130.0.0 0.0.0.0 0 32768 i *> 200.200.200.0 10.10.10.1 0 0 1 i !--- Note 192.168.50.0/24 is not present.
现在,看一看条件通告需要多长时间才能生效:
R102# debug ip bgp updates *Mar 1 02:39:18.059: BGP(0): 10.10.20.3 rcv UPDATE about 192.168.50.0/24 -- withdrawn *Mar 1 02:39:18.059: BGP(0): no valid path for 192.168.50.0/24 *Mar 1 02:39:18.079: BGP(0): nettable_walker 192.168.50.0/24 no best path *Mar 1 02:39:18.219: BGP(0): 10.10.10.1 computing updates, afi 0, neighbor version 10, table version 11, starting at 0.0.0.0 *Mar 1 02:39:18.219: BGP(0): 10.10.10.1 send unreachable 192.168.50.0/24 *Mar 1 02:39:18.219: BGP(0): 10.10.10.1 send UPDATE 192.168.50.0/24 -- unreachable *Mar 1 02:39:18.219: BGP(0): 10.10.10.1 1 updates enqueued (average=27, maximum=27) *Mar 1 02:39:18.219: BGP(0): 10.10.10.1 update run completed, afi 0, ran for 0ms, neighbor version 10, start version 11, throttled to 11 *Mar 1 02:40:04.747: BPG(0): Condition NON-EXIST changes to Advertise *Mar 1 02:40:04.747: BGP(0): net 128.16.16.0/24 matches ADV MAP ADVERTISE: bump version to 12 *Mar 1 02:40:05.187: BGP(0): nettable_walker 128.16.16.0/24 route sourced locally *Mar 1 02:40:05.187: BGP(0): 10.10.10.1 computing updates, afi 0, neighbor version 11, table version 12, starting at 0.0.0.0 *Mar 1 02:40:05.187: BGP(0): 10.10.10.1 128.16.16.0/24 matches advertise map ADVERTISE, state: Advertise *Mar 1 02:40:05.187: BGP(0): 10.10.10.1 send UPDATE (format) 128.16.16.0/24, next 10.10.10.2, metric 0, path *Mar 1 02:40:05.187: BGP(0): 10.10.10.1 1 updates enqueued (average=52, maximum=52) *Mar 1 02:40:05.187: BGP(0): 10.10.10.1 update run completed, afi 0, ran for 0ms, neighbor version 11, start version 12, throttled to 12
有条件通告进程由BGP扫描程序进程触发,它每60秒运行。这意味着条件通告生效的最长时间是 60 秒。条件通告可以更快生效,这取决于从 BGP 表中删除跟踪的路由的时间以及 BGP 扫描程序的下个实例出现的时间。在 R102 上发出以下命令,以验证 R102 上邻居 10.10.10.1 的条件通告状态:
R102# show ip bgp neighbors 10.10.10.1 BGP neighbor is 10.10.10.1, remote AS 1, external link BGP version 4, remote router ID 200.200.200.1 BGP state = Established, up for 02:45:27 Last read 00:00:27, hold time is 180, keepalive interval is 60 seconds !--- Output suppressed. For address family: IPv4 Unicast BGP table version 12, neighbor version 12 Index 1, Offset 0, Mask 0x2 Condition-map NON-EXIST, Advertise-map ADVERTISE, status: Advertise 1 accepted prefixes consume 36 bytes Prefix advertised 6, suppressed 0, withdrawn 4 Number of NLRIs in the update sent: max 1, min 0 !--- Output suppressed.
R101 的 BGP 表和路由表包含 128.16.16.0/24,如下所示:
注意:在此示例输出中,除了BGP路由器向其对等体发送的正常BGP通告(网络130.130.0.0/16)外,还发送有条件BGP通告(网络128.16.16.0/24)。
R101# show ip bgp BGP table version is 18, local router ID is 200.200.200.1 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 *> 128.16.16.0/24 10.10.10.2 0 0 2 i *> 130.130.0.0 10.10.10.2 0 0 2 i *> 200.200.200.0 0.0.0.0 0 32768 i
R101# show ip route bgp 128.16.0.0/24 is subnetted, 1 subnets B 128.16.16.0 [20/0] via 10.10.10.2, 00:09:32 B 130.130.0.0/16 [20/0] via 10.10.10.2, 02:48:46
此示例涉及如何在 R102 上重新安装 192.168.50.0/24 网络,目的是查看 BGP 的状态如何从“通告”更改为“撤销”。
要重新安装 192.168.50.0/24,请发出 no shutdown 命令,以便在 R103 上启动接口环回 0。
R103(config)# interface loopback 0 R103(config-if)# no shutdown R103(config-if)# 03:49:06: %LINK-3-UPDOWN: Interface Loopback0, changed state to up 03:49:07: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up !--- R102 kicks in conditional advertisement the moment the !--- conditional network is received again. *Mar 1 02:51:42.227: BGP(0): 10.10.20.3 rcvd UPDATE w/ attr: nexthop 10.10.20.3, origin i, metric 0, path 3 *Mar 1 02:51:42.227: BGP(0): 10.10.20.3 rcvd 192.168.50.0/24 *Mar 1 02:51:42.247: BGP(0): Revise route installing 192.168.50.0/24 -> 10.10.20.3 to main IP table *Mar 1 02:51:42.379: BGP(0): 10.10.10.1 computing updates, afi 0, neighbor version 12, table version 13, starting at 0.0.0.0 *Mar 1 02:51:42.379: BGP(0): 10.10.10.1 send UPDATE (format) 192.168.50.0/24, next 10.10.10.2, metric 0, path 3 *Mar 1 02:51:42.379: BGP(0): 10.10.10.1 1 updates enqueued (average=47, maximum=47) *Mar 1 02:51:42.379: BGP(0): 10.10.10.1 update run completed, afi 0, ran for 0ms, neighbor version 12, start version 13, throttled to 13 *Mar 1 02:52:09.159: BPG(0): Condition NON-EXIST changes to Withdraw *Mar 1 02:52:09.159: BGP(0): net 128.16.16.0/24 matches ADV MAP ADVERTISE: bump version to 14 *Mar 1 02:52:09.499: BGP(0): nettable_walker 128.16.16.0/24 route sourced locally *Mar 1 02:52:11.559: BGP(0): 10.10.10.1 computing updates, afi 0, neighbor version 13, table version 14, starting at 0.0.0.0 *Mar 1 02:52:11.559: BGP(0): 10.10.10.1 128.16.16.0/24 matches advertise map ADVERTISE, state: Withdraw *Mar 1 02:52:11.559: BGP(0): 10.10.10.1 send unreachable 128.16.16.0/24 *Mar 1 02:52:11.559: BGP(0): 10.10.10.1 send UPDATE 128.16.16.0/24 -- unreachable *Mar 1 02:52:11.559: BGP(0): 10.10.10.1 1 updates enqueued (average=27, maximum=27) *Mar 1 02:52:11.559: BGP(0): 10.10.10.1 update run completed, afi 0, ran for 0ms, neighbor version 13, start version 14, throttled to 14
R102 不再向 R101 通告 128.16.16.0/24。
R102# show ip bgp neighbors 10.10.10.1 advertised-routes BGP table version is 14, local router ID is 128.16.16.1 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 *> 130.130.0.0 0.0.0.0 0 32768 i *> 192.168.50.0 10.10.20.3 0 0 3 i !--- Note 128.16.16.0/24 is not advertised. R102# show ip bgp neighbors 10.10.10.1 BGP neighbor is 10.10.10.1, remote AS 1, external link BGP version 4, remote router ID 200.200.200.1 BGP state = Established, up for 03:01:32 Last read 00:00:31, hold time is 180, keepalive interval is 60 seconds Neighbor capabilities: !--- Output supressed. For address family: IPv4 Unicast BGP table version 14, neighbor version 14 Index 1, Offset 0, Mask 0x2 Condition-map NON-EXIST, Advertise-map ADVERTISE, status: Withdraw 1 accepted prefixes consume 36 bytes Prefix advertised 7, suppressed 0, withdrawn 5 Number of NLRIs in the update sent: max 1, min 0 !--- Output supressed.
注意:在现实场景中,AS1和AS3连接到Internet(全局BGP)。 因此,网络 192.168.50.0/24 可以通过全局 BGP 网格从 AS3 传播到 AS1 (R101) BGP 表,而 AS1 则可向 R102 传播前缀 192.168.50.0(根据 AS1 和 AS2 之间的策略协议)。 如果 R101 将从全局 BGP 网格获知的 AS3 路由传播到 R102,且不在 non-exist map 中放置附加检查,则条件通告可能失败。
请考虑以下情况,以便更好地了解条件通告的失败原因。AS1 从全局 BGP 网格获知 192.168.50.0/24 并向 AS2 (R102) 通告 192.168.50.0/24。R102也从R103的直接对等体那里获知前缀192.168.50.0/24 (在R102到R103的链路上)。 当R102和R103之间的直接链路发生故障时,您预计前缀192.168.50.0/24不再存在于R102的BGP表中,条件通告将启动并向R101通告前缀128.16.16.0/24。但是,由于前缀192.168.50.0/24继续存在在R102 BGP表(从R101获知)中,条件通告会中断,因为R102 BGP表中仍存在非存在映射中的前缀。要确保仅从到 AS3 的直接连接(R102 到 R103)获知前缀 192.168.50.0/24 以使条件通告生效,则应在 non-exist map 下添加 match as_path 语句,使之与从直接连接获知的前缀 192.168.50.0/24 的 AS_PATH(本例中为 AS 3)相匹配。 本例的正则表达式为^3。有关正则表达式的详细信息,请参阅在BGP中使用正则表达式。请注意,您不能只匹配 as-path 而不匹配前缀。match as-path 只能补充已匹配前缀的匹配标准。换句话说,如果某个 AS # 不存在前缀,则不能向邻居通告一些前缀。
此处显示 R102 上的新配置。新增内容用粗体显示。
R101 |
---|
hostname R102 ! interface Loopback0 ip address 128.16.16.1 255.255.255.0 ! interface Serial8/0 ip address 10.10.10.2 255.255.255.0 ! interface Serial9/0 ip address 10.10.20.2 255.255.255.0 ! router bgp 2 bgp log-neighbor-changes network 128.16.16.0 mask 255.255.255.0 network 130.130.0.0 neighbor 10.10.10.1 remote-as 1 neighbor 10.10.10.1 advertise-map ADVERTISE non-exist-map NON-EXIST neighbor 10.10.20.3 remote-as 3 ! ip route 130.130.0.0 255.255.0.0 Null0 ! ip as-path access-list 1 permit ^3 ! access-list 60 permit 128.16.16.0 0.0.0.255 access-list 65 permit 192.168.50.0 0.0.0.255 ! route-map NON-EXIST permit 10 match ip address 65 match as-path 1 ! route-map ADVERTISE permit 10 match ip address 60 ! |
有两个与 BGP 和条件通告相关的已知 bug。有关详细信息,请参阅 Bug 工具包中的 bug CSCdp18563(仅限注册用户)和 CSCdp20320(仅限注册用户)。
版本 | 发布日期 | 备注 |
---|---|---|
1.0 |
10-Aug-2005 |
初始版本 |