簡介
本檔案介紹如何設定和驗證邊界閘道通訊協定(BGP)條件通告功能。
必要條件
需求
思科建議您瞭解以下主題:
採用元件
本文件所述內容不限於特定軟體和硬體版本。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
背景資訊
邊界網關協定(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 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 更改為Without。
BGP如何從通告更改為撤消
要重新安裝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連線到Internet (全局BGP)。因此,網路192.168.50.0/24可以透過全局BGP網狀從AS3傳播到AS1 (R101) BGP表。而AS1可以將字首192.168.50.0傳播到R102(取決於AS1和AS2之間的策略協定)。如果R101將從全局BGP網格獲知的AS3路由傳播到R102,則如果沒有在不存在的對映中放置附加檢查,條件通告可能會失敗。
為了更好地瞭解條件通告失敗的原因,請考慮以下情況。AS1從全局BGP網格獲知192.168.50.0/24並向AS2 (R102)通告192.168.50.0/24。R102還從其與R103的直接對等(透過R102與R103的鏈路)獲知字首192.168.50.0/24。當R102和R103之間的直接鏈路發生故障時,您預計字首192.168.50.0/24不再存在於R102的BGP表中,並且有條件通告開始並向R101通告字首172.16.16.0/24。但是,由於字首192.168.50.0/24繼續存在於R102 BGP表中(從R101獲知),因此條件通告中斷,因為non-exist map 中的字首仍存在於R102 BGP表中。為確保字首192.168.50.0/24只從與AS3的直接連線(R102到R103)中獲知,以便條件通告生效,請在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
! |
相關資訊