简介
本文档介绍如何配置和验证边界网关协议(BGP)条件通告功能。
先决条件
要求
Cisco 建议您了解以下主题:
使用的组件
本文档不限于特定的软件和硬件版本。
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
背景信息
边界网关协议 (BGP) 条件通告功能可以根据 BGP 表中是否存在其他前缀,提供对路由通告的更多控制。
本文档中介绍的BGP条件通告功能在Cisco IOS®软件版本11.1和11.2中引入,并在更高版本中提供。
通常,会传播路由,而不管是否存在不同的路径。BGP 条件通告功能使用 neighbor advertise-map 命令的 non-exist-map 和 advertise-map 关键词,目的是按路由前缀跟踪路由。如果路由前缀不出现在non-exist-map命令输出中,那就公布advertise-map命令指定的路由。此功能对于多宿主网络非常有用,在多宿主网络中,只有在来自其他提供商的信息不存在时,才会将有些前缀通告给其中一个提供商(这表示在对等会话中出现故障或出现部分可达性问题)。
除了BGP路由器发送到其对等体的正常公告之外,还发送有条件的BGP公告。
规则
有关文件规则的更多信息请参见“ Cisco技术提示规则”。
配置
本部分提供有关如何配置本文档所述功能的信息。
注意:要寻找关于用于本文的指令的其他信息,请使用Cisco IOS命令查找工具。只有思科注册用户才能访问内部思科工具和信息。
网络图
本文档使用此图所示的网络设置。
此处,R103 的环回接口用于向 R102 通告 192.168.50.0/24。默认情况下,R102有一个BGP网络172.16.16.0/24,会通告给其外部BGP (eBGP)对等体R101和R103。
网络设置
使用 BGP 条件通告功能,您现在可以在 R102 上完成以下任务:
在Cisco IOS 12.2T或更高版本中,exist-map 关键字也可以用于完成以下任务:
配置条件通告功能
本文档使用以下配置:
注意:此处的示例讨论non-exist-map关键字。exist-map 关键字的用法与此类似。
R102 |
hostname R102
!
interface Loopback0
ip address 172.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 172.16.16.0 mask 255.255.255.0
network 172.31.130.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 (172.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 172.31.130.0 255.255.0.0 Null0
!
access-list 60 permit 172.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 10.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 10.200.200.0
neighbor 10.10.10.2 remote-as 2
! |
检查配置
示例 1
此示例验证当192.168.50.0/24在R102 BGP表中时BGP的外观:
检查配置
首先检查R102 BGP表中是否存在192.168.50.0/24:
R102#show ip bgp
BGP table version is 6, local router ID is 172.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
*> 172.16.16.0/24 0.0.0.0 0 32768 i
*> 172.31.130.0 0.0.0.0 0 32768 i
*> 192.168.50.0 10.10.20.3 0 0 3 i
*> 10.200.200.0 10.10.10.1 0 0 1 i
由于192.168.50.0/24位于R102 BGP表中,因此R102不得向R101通告172.16.16.0/24。
R102#show ip bgp neighbors 10.10.10.1 advertised-routes
BGP table version is 6, local router ID is 172.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
*> 172.31.130.0 0.0.0.0 0 32768 i
*> 192.168.50.0 10.10.20.3 0 0 3 i
!--- Note 172.16.16.0/24 is not advertised to neighbor 10.10.10.1.
R102#show ip bgp 172.16.16.0
BGP routing table entry for 172.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 (172.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 10.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 172.16.16.0
% Network not in table
示例 2
此示例显示当 R102 的 BGP 表中不存在网络 192.168.50.0/24 时 BGP 的情况:
192.168.50.0/24在R102 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 172.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
*> 172.16.16.0/24 0.0.0.0 0 32768 i
*> 172.31.130.0 0.0.0.0 0 32768 i
*> 10.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 172.16.16.0/24 matches ADV MAP ADVERTISE:
bump version to 12
*Mar 1 02:40:05.187: BGP(0): nettable_walker 172.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 172.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) 172.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 10.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表和路由表有172.16.16.0/24,如下所示:
注意:在此示例输出中,除了BGP路由器发送给其对等体的正常BGP通告(网络172.31.130.0/16)外,还发送有条件BGP通告(网络172.16.16.0/24)。
R101#show ip bgp
BGP table version is 18, local router ID is 10.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
*> 172.16.16.0/24 10.10.10.2 0 0 2 i
*> 172.31.130.0 10.10.10.2 0 0 2 i
*> 10.200.200.0 0.0.0.0 0 32768 i
R101#show ip route bgp
172.16.0.0/24 is subnetted, 1 subnets
B 172.16.16.0 [20/0] via 10.10.10.2, 00:09:32
B 172.31.130.0/16 [20/0] via 10.10.10.2, 02:48:46
示例 3
本示例涉及在R102中重新安装192.168.50.0/24网络,以便查看BGP如何从Advertise 更改为Withdraw。
BGP如何从Advertise更改为Withdraw
要重新安装192.168.50.0/24,请发出 no shutdown 命令,以使R103上的接口环回0变为“UP”。
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 172.16.16.0/24 matches ADV MAP
ADVERTISE: bump version to 14
*Mar 1 02:52:09.499: BGP(0): nettable_walker 172.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 172.16.16.0/24 matches advertise
map ADVERTISE, state: Withdraw
*Mar 1 02:52:11.559: BGP(0): 10.10.10.1 send unreachable 172.16.16.0/24
*Mar 1 02:52:11.559: BGP(0): 10.10.10.1 send UPDATE 172.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通告172.16.16.0/24。
R102#show ip bgp neighbors 10.10.10.1 advertised-routes
BGP table version is 14, local router ID is 172.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
*> 172.31.130.0 0.0.0.0 0 32768 i
*> 192.168.50.0 10.10.20.3 0 0 3 i
!--- Note 172.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 10.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连接到互联网(全局BGP)。因此,网络192.168.50.0/24可以通过全局BGP网格从AS3传播到AS1 (R101) BGP表。而 AS1 则可向 R102 传播前缀 192.168.50.0(根据 AS1 和 AS2 之间的策略协议)。如果R101将从全局BGP网格获知的AS3路由传播到R102,则如果没有将其他检查放置在非存在映射中,则条件通告可能失败。
请考虑以下情况,以便更好地了解条件通告的失败原因。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表中,并且条件通告生效并将前缀172.16.16.0/24通告到R101。但是,由于前缀192.168.50.0/24继续存在于R102 BGP表中(从R101获知),因此条件通告中断,因为non-exist map中的前缀仍存在于R102 BGP表中。要确保从与AS3的直接连接(R102到R103)中获知前缀192.168.50.0/24,以使条件通告生效,请在non-exist map 下添加一个match as_path语句,该语句与从直接连接(本例中为AS 3)获知的前缀192.168.50.0/24的AS_PATH匹配。本例的正则表达式是 ^3。有关正则表达式的详细信息,请参阅在 BGP 中使用正则表达式。请注意,您不能只匹配 as-path 而不匹配前缀。match as-path 只能补充已匹配前缀的匹配标准。换句话说,如果某个 AS # 不存在前缀,则不能向邻居通告一些前缀。
此处显示 R102 上的新配置。新增内容用粗体显示。
R101 |
hostname R102
!
interface Loopback0
ip address 172.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 172.16.16.0 mask 255.255.255.0
network 172.31.130.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 172.31.130.0 255.255.0.0 Null0
!
ip as-path access-list 1 permit ^3
!
access-list 60 permit 172.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
! |
相关信息