本產品的文件集力求使用無偏見用語。針對本文件集的目的,無偏見係定義為未根據年齡、身心障礙、性別、種族身分、民族身分、性別傾向、社會經濟地位及交織性表示歧視的用語。由於本產品軟體使用者介面中硬式編碼的語言、根據 RFP 文件使用的語言,或引用第三方產品的語言,因此本文件中可能會出現例外狀況。深入瞭解思科如何使用包容性用語。
思科已使用電腦和人工技術翻譯本文件,讓全世界的使用者能夠以自己的語言理解支援內容。請注意,即使是最佳機器翻譯,也不如專業譯者翻譯的內容準確。Cisco Systems, Inc. 對這些翻譯的準確度概不負責,並建議一律查看原始英文文件(提供連結)。
本文件說明負載共用,負載共用可讓路由器將傳出和傳入流量分散至多個路徑。
嘗試此組態之前,請確保符合以下要求:
BGP最佳路徑選取演演算法的知識
設定BGP的知識
本文件所述內容不限於特定軟體和硬體版本。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
傳入和傳出流量路徑是靜態派生的,或者使用動態協定派生,例如:
路由資訊通訊協定(RIP)
增強型內部閘道路由通訊協定(EIGRP)
開放最短路徑優先(OSPF)通訊協定
預設情況下,邊界閘道通訊協定(BGP)只會選擇單一的最佳路徑,且不會執行負載平衡。本文說明如何使用BGP在不同的情況下執行負載共用。有關負載平衡的其他資訊,請參閱負載平衡如何工作?。
此案例顯示當有多條等價連結(最多六條)時,如何實現負載共用。連結在本機自動化系統 (AS) 的一個路由器,以及單宿 BGP 環境中遠端 AS 的另一台路由器中終止。網路圖表就是一個例子。
本節使用以下網路設定:
本節使用以下配置:
路由器 A
interface loopback 0 ip address 192.168.1.1 255.255.255.255 interface GigabitEthernet0/1 ip address 10.20.20.1 255.255.255.0 interface GigabitEthernet0/0 ip address 10.10.10.1 255.255.255.0 router bgp 11 neighbor 192.168.2.2 remote-as 10 neighbor 192.168.2.2 update-source loopback 0 !--- Use the IP address of the loopback interface for TCP connections.
neighbor 192.168.2.2 ebgp-multihop !--- You must configure ebgp-multihop whenever the external BGP (eBGP) connections are not on the same network address.
router eigrp 12
network 192.168.1.1 0.0.0.0
network 10.0.0.0
no auto-summary
路由器 B
interface loopback 0 ip address 192.168.2.2 255.255.255.255 interface GigabitEthernet0/1 ip address 10.20.20.2 255.255.255.0 interface GigabitEthernet0/0 ip address 10.10.10.2 255.255.255.0 router bgp 10 neighbor 192.168.1.1 remote-as 11 neighbor 192.168.1.1 update-source loopback 0 !--- Use the IP address of the loopback interface for TCP connections.
neighbor 192.168.1.1 ebgp-multihop !--- You must configure ebgp-multihop whenever the eBGP connections are not on the same network address.
router eigrp 12
network 192.168.2.2 0.0.0.0
network 10.0.0.0 no auto-summary
注意:您可以使用靜態路由代替路由協定來引入兩條到達目的地的等價路徑。在本例中,EIGRP用於共用環回資訊。
使用本節內容,確認您的組態是否正常運作。
Cisco CLI Analyzer(僅供已註冊客戶使用)支援某些 show 指令。使用 Cisco CLI Analyzer 檢視 show 指令輸出的分析。
show ip route命令的輸出顯示EIGRP獲知的通往192.168.2.2網路的兩條路徑。show ip bgp summary命令顯示BGP鄰居是使用遠端路由器的環回介面構建的。traceroute命令的輸出表明負載分佈在兩個串列鏈路之間。在此案例中,負載共用會針對每個封包而發生。您可以在串列介面上發出ip route-cache命令,以便根據目標執行負載共用。您還可以使用Cisco Express Forwarding配置每個資料包和每個目標的負載均衡。有關如何配置Cisco快速轉發的詳細資訊,請參閱配置Cisco快速轉發。
RouterA#show ip route Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP a - application route + - replicated route, % - next hop override, p - overrides from PfR Gateway of last resort is not set 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks C 10.10.10.0/24 is directly connected, GigabitEthernet0/0 L 10.10.10.1/32 is directly connected, GigabitEthernet0/0 C 10.20.20.0/24 is directly connected, GigabitEthernet0/1 L 10.20.20.1/32 is directly connected, GigabitEthernet0/1 192.168.1.0/32 is subnetted, 1 subnets C 192.168.1.1 is directly connected, Loopback0 192.168.2.0/32 is subnetted, 1 subnets D 192.168.2.2 [90/130816] via 10.20.20.2, 00:02:01, GigabitEthernet0/1 [90/130816] via 10.10.10.2, 00:02:01, GigabitEthernet0/0 RouterA#
RouterA#show ip bgp summary BGP router identifier 192.168.1.1, local AS number 11 BGP table version is 1, main routing table version 1 Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.2.2 4 10 20 20 1 0 0 00:15:05 0
RouterA#traceroute 192.168.2.2 Type escape sequence to abort. Tracing the route to 192.168.2.2 VRF info: (vrf in name/id, vrf out name/id) 1 10.10.10.2 2 msec 10.20.20.2 2 msec 10.10.10.2 2 msec RouterA#
目前尚無特定資訊可用於排解此組態的疑難問題。
此案例顯示當遠端AS和本地AS之間存在多個鏈路時如何實現負載共用。這些鏈路在本地AS的一個路由器中終止,在單宿主BGP環境中的遠端AS的多個路由器上終止。網路圖表就是這樣一個網路的範例。
此示例配置使用maximum-paths命令。預設情況下,BGP會從一個AS得知的可能等價路徑中選擇一個最佳路徑。但是,您可以更改允許的並行等價路徑的最大數量。若要進行此變更,請在BGP設定下包括maximum-paths 命令。使用1到6之間的數字作為paths引數。
本節使用以下網路設定:
本節使用以下配置:
路由器 A
interface Loopback0 ip address 192.168.1.1 255.255.255.255 ! interface GigabitEthernet0/0 ip address 10.20.20.1 255.255.255.0 ! ! interface GigabitEthernet0/1 ip address 10.10.10.1 255.255.255.0 ! ! router bgp 11 neighbor 10.20.20.2 remote-as 10 neighbor 10.10.10.2 remote-as 10 network 192.168.1.1 mask 255.255.255.255 maximum-paths 2 !--- This command specifies the maximum number of paths to install in the routing table for a specific destination.
路由器 B
interface GigabitEthernet0/2 ip address 172.16.2.1 255.255.255.0 ! interface GigabitEthernet0/0 ip address 10.20.20.2 255.255.255.0 ! ! router bgp 10 neighbor 10.20.20.1 remote-as 11 network 172.16.2.0 mask 255.255.255.0
路由器 C
interface GigabitEthernet0/2 ip address 172.16.2.2 255.255.255.0 ! interface GigabitEthernet0/1 ip address 10.10.10.2 255.255.255.0 ! ! router bgp 10 neighbor 10.10.10.1 remote-as 11 network 172.16.2.0 mask 255.255.255.0
使用本節內容,確認您的組態是否正常運作。
Cisco CLI Analyzer(僅供已註冊客戶使用)支援某些 show 指令。使用 Cisco CLI Analyzer 檢視 show 指令輸出的分析。
show ip route命令的輸出顯示BGP獲知的指向172.16.2.0網路的兩條路徑。traceroute命令的輸出表明負載分佈在兩個串列鏈路之間。在此場景中,負載共用基於每個目標。show ip bgp命令會提供172.16.2.0網路的有效專案。
RouterA#show ip route Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP a - application route + - replicated route, % - next hop override, p - overrides from PfR Gateway of last resort is not set 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks C 10.10.10.0/24 is directly connected, GigabitEthernet0/1 L 10.10.10.1/32 is directly connected, GigabitEthernet0/1 C 10.20.20.0/24 is directly connected, GigabitEthernet0/0 L 10.20.20.1/32 is directly connected, GigabitEthernet0/0 172.16.0.0/24 is subnetted, 1 subnets B 172.16.2.0 [20/0] via 10.20.20.2, 00:08:51 [20/0] via 10.10.10.2, 00:08:51 192.168.1.0/32 is subnetted, 1 subnets C 192.168.1.1 is directly connected, Loopback0
RouterA#traceroute 172.16.2.2 source loopback0 Type escape sequence to abort. Tracing the route to 172.16.2.2 VRF info: (vrf in name/id, vrf out name/id) 1 10.10.10.2 3 msec 10.20.20.2 3 msec 10.10.10.2 3 msec RouterA#
RouterA#show ip bgp BGP table version is 4, local router ID is 192.168.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, t secondary path, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *m 172.16.2.0/24 10.10.10.2 0 0 10 i *> 10.20.20.2 0 0 10 i *> 192.168.1.1/32 0.0.0.0 0 32768 i
目前尚無特定資訊可用於排解此組態的疑難問題。
此案例顯示當有多個連線通過多個本地路由器連線到同一個ISP時,如何實現負載共用。兩個eBGP對等體在兩個獨立的本地路由器上終止。無法在這兩條連結上進行負載平衡,因為BGP會在從eBGP和內部BGP(iBGP)得知的網路中選擇單一最佳路徑。到AS 10的多個路徑之間的負載共用是下一個最佳選項。使用此類負載共用,根據預定義策略,發往特定網路的流量通過兩條鏈路傳輸。此外,如果一條鏈路發生故障,每條鏈路都會作為另一條鏈路的備份。
為簡單起見,假設AS 11的BGP路由策略為:
AS 11接受來自AS 10的本地路由,以及其餘網際網路路由的預設路由。
出站流量策略為:
所有從R101發往Internet的流量都會通過R101-R103鏈路傳輸。
如果R101-R103鏈路發生故障,則從R101到Internet的所有流量都會通過R102到AS 10。
同樣,所有從R102發往Internet的流量都會通過R102-R104鏈路。
如果R102-R104鏈路出現故障,則從R102到Internet的所有流量都會通過R101到AS 10。
入站流量策略為:
從Internet發往網路192.168.11.0/24的流量來自R103-R101鏈路。
從Internet發往網路192.168.12.0/24的流量來自R104-R102鏈路。
如果指向AS 10的一條鏈路發生故障,則另一條鏈路會將發往所有網路的流量從Internet路由回AS 11。
為實現這一點,從R101到R103宣佈192.168.11.0,其AS_PATH比從R102到R104宣佈的要短。AS 10查詢通過R103-R101鏈路的最佳路徑。同樣地,192.168.12.0會以通過R102-R104鏈路的較短路徑公佈。AS 10優先使用R104-R102鏈路來傳輸到AS 11中192.168.12.0的流量。
對於傳出流量,BGP會根據透過eBGP得知的路由決定最佳路徑。這些路由比通過iBGP獲知的路由更可取。因此,R101通過eBGP從R103獲知10.10.34.0,並通過iBGP從R102獲知10.10.34.0。外部路徑會選擇在內部路徑上。如果您檢視R101配置中的BGP表,通向10.10.34.0的路由將通過R101-R103鏈路,下一跳為10.10.13.3。在R102上,通向10.10.34.0的路由是通過R102-R104鏈路,下一跳為10.10.24.4。這實現了目的地為10.10.34.0的流量的負載共用。類似的原因也適用於R101和R102上的預設路由。有關BGP路徑選取標準的詳細資訊,請參閱BGP最佳路徑選取演演算法。
本節使用以下網路設定:
本節使用以下配置:
R10
hostname R101 ! interface Ethernet0/0 ip address 192.168.11.1 255.255.255.0 secondary ip address 192.168.12.1 255.255.255.0 ! interface Serial8/0 ip address 10.10.13.1 255.255.255.0 ! router bgp 11 no synchronization bgp log-neighbor-changes network 192.168.11.0 network 192.168.12.0 neighbor 10.10.13.3 remote-as 10 neighbor 10.10.13.3 route-map R101-103-MAP out !--- The AS_PATH is increased for 192.168.12.0. neighbor 192.168.12.2 remote-as 11 neighbor 192.168.12.2 next-hop-self maximum-paths 2 no auto-summary ! access-list 1 permit 192.168.12.0 access-list 2 permit 192.168.11.0 route-map R101-103-MAP permit 10 match ip address 1 set as-path prepend 11 11 11 ! route-map R101-103-MAP permit 20 match ip address 2
R102
hostname R102 ! interface Ethernet0/0 ip address 192.168.11.2 255.255.255.0 secondary ip address 192.168.12.2 255.255.255.0 ! interface Serial8/0 ip address 10.10.24.2 255.255.255.0 ! router bgp 11 no synchronization bgp log-neighbor-changes network 192.168.11.0 network 192.168.12.0 neighbor 10.10.24.4 remote-as 10 neighbor 10.10.24.4 route-map R102-104-MAP out !--- The AS_PATH is increased for 192.168.11.0. neighbor 192.168.12.1 remote-as 11 neighbor 192.168.12.1 next-hop-self no auto-summary ! access-list 1 permit 192.168.11.0 access-list 2 permit 192.168.12.0 route-map R102-104-MAP permit 10 match ip address 1 set as-path prepend 11 11 11 ! route-map R102-104-MAP permit 20 match ip address 2
R10
hostname R103 ! interface Ethernet0/0 ip address 10.10.34.3 255.255.255.0 ! interface Serial8/0 ip address 10.10.13.3 255.255.255.0 ! router bgp 10 no synchronization bgp log-neighbor-changes network 10.10.34.0 mask 255.255.255.0 neighbor 10.10.13.1 remote-as 11 neighbor 10.10.13.1 default-originate neighbor 10.10.34.4 remote-as 10 neighbor 10.10.34.4 next-hop-self no auto-summary
R10
hostname R104 ! interface Ethernet0/0 ip address 10.10.34.4 255.255.255.0 ! interface Serial8/0 ip address 10.10.24.4 255.255.255.0 ! router bgp 10 no synchronization bgp log-neighbor-changes neighbor 10.10.24.2 remote-as 11 neighbor 10.10.24.2 default-originate neighbor 10.10.34.3 remote-as 10 neighbor 10.10.34.3 next-hop-self no auto-summary
本節提供的資訊可用於確認您的組態是否正常運作。
Cisco CLI Analyzer 支援某些 show 指令(僅限註冊客戶) ,它允許您查看 show 指令輸出的分析。
註:show ip bgp命令輸出中的大於號(>)表示該網路可能路徑中的最佳路徑。如需詳細資訊,請參閱BGP最佳路徑選取演演算法。
R101中的BGP表顯示了通過R101-R103鏈路到達網際網路的所有傳出流量的最佳路徑。show ip route命令輸出用於確認路由表中的路由。
R101#show ip bgp BGP table version is 5, local router ID is 192.168.12.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 * i0.0.0.0 192.168.12.2 100 0 10 i *> 10.10.13.3 0 10 i !--- This is the next hop of R103. * i10.10.34.0/24 192.168.12.2 100 0 10 i *> 10.10.13.3 0 0 10 i !--- This is the next hop of R103. * i192.168.11.0 192.168.12.2 0 100 0 i *> 0.0.0.0 0 32768 i * i192.168.12.0 192.168.12.2 0 100 0 i *> 0.0.0.0 0 32768 i R101#show ip route !--- Output suppressed.
Gateway of last resort is 10.10.13.3 to network 0.0.0.0 C 192.168.12.0/24 is directly connected, Ethernet0/0 C 192.168.11.0/24 is directly connected, Ethernet0/0 10.0.0.0/24 is subnetted, 2 subnets C 10.10.13.0 is directly connected, Serial8/0 B 10.10.34.0 [20/0] via 10.10.13.3, 00:08:53 !--- This is the next hop of R103.
B* 0.0.0.0/0 [20/0] via 10.10.13.3, 00:08:53 !--- This is the next hop of R103.
以下是R102的BGP和路由表。根據該策略,R102通過R102-R104鏈路將所有流量路由到AS 10:
R102#show ip bgp BGP table version is 7, local router ID is 192.168.12.2 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 *> 0.0.0.0 10.10.24.4 0 10 i !--- This is the next hop of R104.
* i 192.168.12.1 100 0 10 i *> 10.10.34.0/24 10.10.24.4 0 10 i !--- This is the next hop of R104.
* i 192.168.12.1 0 100 0 10 i * i192.168.11.0 192.168.12.1 0 100 0 i *> 0.0.0.0 0 32768 i * i192.168.12.0 192.168.12.1 0 100 0 i *> 0.0.0.0 0 32768 i R102#show ip route !--- Output suppressed.
Gateway of last resort is 10.10.24.4 to network 0.0.0.0 C 192.168.12.0/24 is directly connected, Ethernet0/0 C 192.168.11.0/24 is directly connected, Ethernet0/0 10.0.0.0/24 is subnetted, 2 subnets C 10.10.24.0 is directly connected, Serial8/0 B 10.10.34.0 [20/0] via 10.10.24.4, 00:11:21 !--- This is the next hop of R104.
B* 0.0.0.0/0 [20/0] via 10.10.24.4, 00:11:21 !--- This is the next hop of R104.
網路192.168.11.0和192.168.12.0屬於AS 11。根據該策略,AS 11優先使用R103-R101鏈路傳輸發往網路192.168.11.0的流量,而使用R104-R102鏈路傳輸發往網路192.168.12.0的流量。
R103#show ip bgp BGP table version is 4, local router ID is 10.10.34.3 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 *> 10.10.34.0/24 0.0.0.0 0 32768 i *> 192.168.11.0 10.10.13.1 0 0 11 i !--- The next hop is R101. * 192.168.12.0 10.10.13.1 0 0 11 11 11 11 i *>i 10.10.34.4 0 100 0 11 i !--- The next hop is R104. R103#show ip route !--- Output suppressed. Gateway of last resort is not set B 192.168.12.0/24 [200/0] via 10.10.34.4, 00:04:46 !--- The next hop is R104. B 192.168.11.0/24 [20/0] via 10.10.13.1, 00:04:46 !--- The next hop is R101. 10.0.0.0/24 is subnetted, 2 subnets C 10.10.13.0 is directly connected, Serial8/0 C 10.10.34.0 is directly connected, Ethernet0/0
R103上網路192.168.11.0的最佳路徑是通過R103-R101鏈路,網路192.168.12.0的最佳路徑是通過R104到AS 11。在這種情況下,最短路徑長度決定最佳路徑。
同樣地,在R104上,BGP和路由表如下所示:
R104#show ip bgp BGP table version is 13, local router ID is 10.10.34.4 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 *>i10.10.34.0/24 10.10.34.3 0 100 0 i *>i192.168.11.0 10.10.34.3 0 100 0 11 i * 10.10.24.2 0 0 11 11 11 11 i *> 192.168.12.0 10.10.24.2 0 0 11 i R104#show ip route !--- Output suppressed. Gateway of last resort is not set B 192.168.12.0/24 [20/0] via 10.10.24.2, 00:49:06 !--- The next hop is R102. B 192.168.11.0/24 [200/0] via 10.10.34.3, 00:07:36 !--- The next hop is R103. 10.0.0.0/24 is subnetted, 2 subnets C 10.10.24.0 is directly connected, Serial8/0 C 10.10.34.0 is directly connected, Ethernet0/0
當R101-R103鏈路發生故障時,所有流量都必須通過R102重新路由。此圖說明此變更:
關閉R103上的R103-R101鏈路以模擬這種情況。
R103(config)#interface serial 8/0 R103(config-if)#shutdown *May 1 00:52:33.379: %BGP-5-ADJCHANGE: neighbor 10.10.13.1 Down Interface flap *May 1 00:52:35.311: %LINK-5-CHANGED: Interface Serial8/0, changed state to administratively down *May 1 00:52:36.127: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial8/0, changed state to down
檢驗到AS 10的出站路由。
R101#show ip bgp BGP table version is 17, local router ID is 192.168.12.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 *>i0.0.0.0 192.168.12.2 100 0 10 i !--- This is the next hop of R102.
*>i10.10.34.0/24 192.168.12.2 100 0 10 i
!--- This is the next hop of R102.
* i192.168.11.0 192.168.12.2 0 100 0 i
*> 0.0.0.0 0 32768 i
* i192.168.12.0 192.168.12.2 0 100 0 i
*> 0.0.0.0 0 32768 i
R101#show ip route
!--- Output suppressed.
Gateway of last resort is 192.168.12.2 to network 0.0.0.0
C 192.168.12.0/24 is directly connected, Ethernet0/0
C 192.168.11.0/24 is directly connected, Ethernet0/0
10.0.0.0/24 is subnetted, 1 subnets
B 10.10.34.0 [200/0] via 192.168.12.2, 00:01:34
B* 0.0.0.0/0 [200/0] via 192.168.12.2, 00:01:34
!--- All outbound traffic goes through R102.
R102#show ip route
!--- Output suppressed.
Gateway of last resort is 10.10.24.4 to network 0.0.0.0
C 192.168.12.0/24 is directly connected, Ethernet0/0
C 192.168.11.0/24 is directly connected, Ethernet0/0
10.0.0.0/24 is subnetted, 2 subnets
C 10.10.24.0 is directly connected, Serial8/0
B 10.10.34.0 [20/0] via 10.10.24.4, 00:13:22
B* 0.0.0.0/0 [20/0] via 10.10.24.4, 00:55:22
!--- All outbound traffic on R102 goes through R104.
檢驗R101-R103關閉時的入站流量路由。
R103#show ip bgp BGP table version is 6, local router ID is 10.10.34.3 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 *> 10.10.34.0/24 0.0.0.0 0 32768 i *>i192.168.11.0 10.10.34.4 0 100 0 11 11 11 11 i *>i192.168.12.0 10.10.34.4 0 100 0 11 i R103#show ip route !--- Output suppressed.
Gateway of last resort is not set
B 192.168.12.0/24 [200/0] via 10.10.34.4, 00:14:55
!--- The next hop is R104.
B 192.168.11.0/24 [200/0] via 10.10.34.4, 00:05:46
!--- The next hop is R104.
10.0.0.0/24 is subnetted, 1 subnets
C 10.10.34.0 is directly connected, Ethernet0/0
在R104上,192.168.11.0和192.168.12.0的流量通過R104-R102鏈路。
R104#show ip route !--- Output suppressed.
Gateway of last resort is not set
B 192.168.12.0/24 [20/0] via 10.10.24.2, 00:58:35
!--- The next hop is R102.
B 192.168.11.0/24 [20/0] via 10.10.24.2, 00:07:57
!--- The next hop is R102.
10.0.0.0/24 is subnetted, 2 subnets
C 10.10.24.0 is directly connected, Serial8/0
C 10.10.34.0 is directly connected, Ethernet0/0
目前尚無特定資訊可用於排解此組態的疑難問題。
在這種情況下,負載平衡不是多宿主環境中的選項,因此您只能執行負載共用。您無法執行負載平衡,因為BGP在從不同的AS獲取的BGP路由中僅選擇一條到達目的地的最佳路徑。我們的想法是為1.0.0.x到128.0.0.x範圍內從ISP(A)獲知的路由設定一個更好的度量,為從ISP(B)獲知的其餘路由設定一個更好的度量。網路圖表就是一個例子。
請參閱使用兩個不同服務提供商(多宿主)的BGP配置示例以瞭解其他資訊。
本節使用以下網路設定:
本節使用以下配置:
路由器 A
interface GigabitEthernet0/0 ip address 10.20.20.1 255.255.255.0 interface GigabitEthernet0/1 ip address 10.10.10.1 255.255.255.0 router bgp 11 neighbor 10.20.20.2 remote-as 10 neighbor 10.20.20.2 route-map UPDATES-1 in !--- This allows only the networks up to 128.0.0.x. neighbor 10.10.10.2 remote-as 12 neighbor 10.10.10.2 route-map UPDATES-2 in !--- This allows anything above the 128.0.0.x network. route-map UPDATES-1 permit 10 match ip address 1 set weight 100 route-map UPDATES-1 permit 20 match ip address 2 route-map UPDATES-2 permit 10 match ip address 1 route-map UPDATES-2 permit 20 match ip address 2 set weight 100 access-list 1 permit 0.0.0.0 127.255.255.255 access-list 2 deny 0.0.0.0 127.255.255.255 access-list 2 permit any
路由器 B
interface GigabitEthernet0/2 ip address 172.16.2.1 255.255.255.0
interface GigabitEthernet0/3 ip address 10.16.6.1 255.255.255.0 interface GigabitEthernet0/0 ip address 10.20.20.2 255.255.255.0 router bgp 10 neighbor 10.20.20.1 remote-as 11 network 172.16.2.0 mask 255.255.255.0 network 10.16.6.0 mask 255.255.255.0
路由器 C
interface GigabitEthernet0/3 ip address 10.16.6.2 255.255.255.0 interface GigabitEthernet0/2 ip address 172.16.2.2 255.255.255.0 interface GigabitEthernet0/1 ip address 10.10.10.2 255.255.255.0 router bgp 12 neighbor 10.10.10.1 remote-as 11 network 172.16.2.0 mask 255.255.255.0 network 10.16.6.0 mask 255.255.255.0
使用本節內容,確認您的組態是否正常運作。
Cisco CLI Analyzer(僅供已註冊客戶使用)支援某些 show 指令。使用 Cisco CLI Analyzer 檢視 show 指令輸出的分析。
show ip route命令的輸出和traceroute命令的輸出顯示任何低於128.0.0.x的網路都通過10.20.20.2退出RouterA。此路由是serial 0介面的下一跳。其餘網路通過10.10.10.2退出,這是serial 1介面的下一跳。
RouterA#show ip route
!--- Output suppressed.
Gateway of last resort is not set
B 172.16.2.0/24 [20/0] via 10.10.10.2, 00:13:16
!--- This is the next hop out through GigabitEthernet0/0.
B 10.16.6.0/24 [20/0] via 10.20.20.2, 00:13:16 !--- This is the next hop out through GigabitEthernet0/1.
!--- Output suppressed.RouterA#show ip cef 172.16.2.0 172.16.2.0/24 nexthop 10.10.10.2 GigabitEthernet0/1 RouterA#show ip cef 10.16.6.0 10.16.6.0/24 nexthop 10.20.20.2 GigabitEthernet0/0
RouterA#show ip bgp BGP table version is 10, local router ID is 192.168.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, t secondary path, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *> 10.16.6.0/24 10.20.20.2 0 100 10 i * 10.10.10.2 0 0 12 i * 172.16.2.0/24 10.20.20.2 0 0 10 i *> 10.10.10.2 0 100 12 i *> 192.168.1.1/32 0.0.0.0 0 32768 i
RouterA#traceroute 172.16.2.1 source loopback0 Type escape sequence to abort. Tracing the route to 172.16.2.1 VRF info: (vrf in name/id, vrf out name/id) 1 10.10.10.2 2 msec 3 msec 2 msec 2 172.16.2.1 [AS 12] 3 msec 3 msec * RouterA#traceroute 10.16.6.1 source loopback0 Type escape sequence to abort. Tracing the route to 10.16.6.1 VRF info: (vrf in name/id, vrf out name/id) 1 10.20.20.2 3 msec 2 msec * RouterA#
目前尚無特定資訊可用於排解此組態的疑難問題。
在具有兩個ISP的多宿主環境中無法實現負載均衡。BGP在從不同的AS獲取的BGP路徑中僅選擇通往目的地的單一最佳路徑,因此無法進行負載平衡。但是,負載共用在這種多宿 BGP 網路中是可行的。根據預定的策略,使用不同的BGP屬性來控制業務流。
本節討論使用最頻繁的多宿主配置。該配置顯示了如何實現負載共用。請參閱網路圖,其中AS 100的多主伺服器實現了可靠性和負載共用。
註:本示例中的IP地址符合RFC 1918專用地址空間標準。
為簡單起見,假設AS 100的BGP路由策略為:
AS 100接受來自兩個提供商的本地路由,以及其他Internet路由的預設路由。
出站流量策略為:
目的地為AS 300的流量通過R1-ISP(A)鏈路。
發往AS 400的流量通過R2-ISP(B)鏈路。
所有其他流量優先使用通過R1-ISP(A)鏈路的預設路由0.0.0.0。
如果R1-ISP(A)鏈路發生故障,所有流量都會通過R2-ISP(B)鏈路。
入站流量策略為:
從Internet發往網路10.10.10.0/24的流量來自ISP(A)-R1鏈路。
從Internet發往網路10.10.20.0/24的流量來自ISP(B)-R2鏈路。
如果一個ISP發生故障,另一個ISP會將所有網路的流量從Internet路由回AS 100。
本節使用以下網路設定:
本節使用以下配置:
R2
interface Ethernet0 ip address 192.168.21.2 255.255.255.0 ! interface Serial0 ip address 192.168.42.2 255.255.255.0 router bgp 100 no synchronization bgp log-neighbor-changes !--- The next two lines announce the networks to BGP peers. network 10.10.10.0 mask 255.255.255.0 network 10.10.20.0 mask 255.255.255.0 !--- The next line configures iBGP on R1. neighbor 192.168.21.1 remote-as 100 neighbor 192.168.21.1 next-hop-self !--- The next line configures eBGP with ISP(B). neighbor 192.168.42.4 remote-as 400 !--- This is the incoming policy route map for the application of attributes to specific routes. neighbor 192.168.42.4 route-map AS-400-INCOMING in !--- This is the outgoing policy route map for the application of attributes to specific routes. neighbor 192.168.42.4 route-map AS-400-OUTGOING out no auto-summary !--- This line sets the AS path access list, it permits all routes within the routing domain of the provider. ip as-path access-list 1 permit ^400$ !--- These two lines set the access list. access-list 10 permit 10.10.10.0 0.0.0.255 access-list 20 permit 10.10.20.0 0.0.0.255 !--- The next three lines configure LOCAL_PREF for routes that match AS path access list 1. route-map AS-400-INCOMING permit 10 match as-path 1 set local-preference 150 !--- Here, the route map prepends AS 100 to BGP updates for networks that are permitted by access list 10. route-map AS-400-OUTGOING permit 10 match ip address 10 set as-path prepend 100 !--- This line announces the network that is permitted by access list 20 without any changes in BGP attributes. route-map AS-400-OUTGOING permit 20 match ip address 20
R1
interface Serial0/0 ip address 192.168.31.1 255.255.255.0 ! interface Ethernet1/0 ip address 192.168.21.1 255.255.255.0 ! router bgp 100 no synchronization bgp log-neighbor-changes network 10.10.10.0 mask 255.255.255.0 network 10.10.20.0 mask 255.255.255.0 !--- IBGP peering with R2
neighbor 192.168.21.2 remote-as 100 neighbor 192.168.21.2 next-hop-self !--- This line sets eBGP peering with ISP(A). neighbor 192.168.31.3 remote-as 300 !--- This is the incoming policy route map for the application of attributes to specific routes. neighbor 192.168.31.3 route-map AS-300-INCOMING in !--- This is the outgoing policy route map for the application of attributes to specific routes. neighbor 192.168.31.3 route-map AS-300-OUTGOING out no auto-summary !--- This line sets the AS path access list, it permits all routes within the routing domain of the provider. ip as-path access-list 1 permit ^300$ !--- These two lines set the IP access list. access-list 10 permit 10.10.20.0 0.0.0.255 access-list 20 permit 10.10.10.0 0.0.0.255 !--- The next three lines configure LOCAL_PREF for routes that match AS path access list 1. route-map AS-300-INCOMING permit 10 match as-path 1 set local-preference 200 !--- Here, the route map prepends AS 100 to BGP updates for networks that are permitted by access list 10. route-map AS-300-OUTGOING permit 10 match ip address 10 set as-path prepend 100 !--- This line announces the network that is permitted by access list 20 without any changes in BGP attributes. route-map AS-300-OUTGOING permit 20 match ip address 20 !
使用本節內容,確認您的組態是否正常運作。
Cisco CLI Analyzer(僅供已註冊客戶使用)支援某些 show 指令。使用 Cisco CLI Analyzer 檢視 show 指令輸出的分析。
發出show ip bgp命令,以驗證傳出/傳入原則是否有效。
註:show ip bgp輸出中的大於號(>)表示該網路在可能的路徑中使用的最佳路徑。如需詳細資訊,請參閱BGP最佳路徑選取演演算法。
R1#show ip bgp BGP table version is 6, local router ID is 192.168.31.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete BGP table version is 6, local router ID is 192.168.31.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 *> 0.0.0.0 192.168.31.3 200 0 300 i !--- This line shows that the default route 0.0.0.0/0 is preferred through AS 300, ISP(A).
* i10.10.10.0/24 192.168.21.2 0 100 0 i
*> 0.0.0.0 0 32768 i
* i10.10.20.0/24 192.168.21.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*> 10.30.30.0/24 192.168.31.3 0 200 0 300 i
*>i10.40.40.0/24 192.168.21.2 0 150 0 400 i
!--- The route to network 10.30.30.0/24 (AS 300) is preferred through the R1-ISP(A) link.
!--- The route to network 10.40.40.0/24 (AS 400) is preferred through the R2-ISP(B) link.
現在,檢視R2上的show ip bgp輸出:
R2#show ip bgp BGP table version is 8, local router ID is 192.168.42.2 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 * 0.0.0.0 192.168.42.4 150 0 400 i *>i 192.168.21.1 200 0 300 i !--- This line shows that the default route 0.0.0.0/0 is preferred through AS 300, through the R2-ISP(B) link.
*> 10.10.10.0/24 0.0.0.0 0 32768 i
* i 192.168.21.1 0 100 0 i
*> 10.10.20.0/24 0.0.0.0 0 32768 i
* i 192.168.21.1 0 100 0 i
*>i10.30.30.0/24 192.168.21.1 0 200 0 300 i
*> 10.40.40.0/24 192.168.42.4 0 150 0 400 i !--- The route to network 10.30.30.0/24 (AS 300) is preferred through the R1-ISP(A) link.
!--- The route to network 10.40.40.0/24 (AS 400) is preferred through the R2-ISP(B) link.
在Router 6上發出show ip bgp命令,以觀察網路10.10.10.0/24和10.10.20.0/24的傳入原則:
R6#show ip bgp BGP table version is 15, local router ID is 192.168.64.6 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 *> 10.10.10.0/24 192.168.63.3 0 300 100 100 i !--- This line shows that network 10.10.10.0/24 is routed through AS 300
!--- with the ISP(A)-R1 link.
* 192.168.64.4 0 400 100 100 100 i
* 10.10.20.0/24 192.168.63.3 0 300 100 100 i
*> 192.168.64.4 0 400 100 i
!--- This line shows that network 10.10.20.0/24 is routed through AS 400
!--- with the ISP(B)-R2 link.
*> 10.30.30.0/24 192.168.63.3 0 0 300 i
*> 10.40.40.0/24 192.168.64.4 0 0 400 i
關閉R1上的R1-ISP(A)鏈路並觀察BGP表。希望所有到Internet的流量都通過R2-ISP(B)鏈路路由:
R1(config)#interface serial 0/0 R1(config-if)#shutdown *May 2 19:00:47.377: %BGP-5-ADJCHANGE: neighbor 192.168.31.3 Down Interface flap *May 2 19:00:48.277: %LINK-5-CHANGED: Interface Serial0/0, changed state to administratively down *May 23 12:00:51.255: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down R1#show ip bgp BGP table version is 12, local router ID is 192.168.31.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 *>i0.0.0.0 192.168.21.2 150 0 400 i !--- The best default path is now through the R2-ISP(B) link.
* i10.10.10.0/24 192.168.21.2 0 100 0 i
*> 0.0.0.0 0 32768 i
* i10.10.20.0/24 192.168.21.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*>i10.40.40.0/24 192.168.21.2 0 150 0 400 i
R2#show ip bgp
BGP table version is 14, local router ID is 192.168.42.2 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 *> 0.0.0.0 192.168.42.4 150 0 400 i !--- The best default route is now through ISP(B) with a local preference of 150.
* i10.10.10.0/24 192.168.21.1 0 100 0 i
*> 0.0.0.0 0 32768 i
* i10.10.20.0/24 192.168.21.1 0 100 0 i
*> 0.0.0.0 0 32768 i
*> 10.40.40.0/24 192.168.42.4 0 150 0 400 i
檢視路由器6中網路10.10.10.0/24的路由:
R6#show ip bgp BGP table version is 14, local router ID is 192.168.64.6 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 *> 10.10.10.0/24 192.168.64.4 0 400 100 100 i !--- Network 10.10.10.0 is reachable through ISP(B), which announced the network with AS path prepend.
*> 10.10.20.0/24 192.168.64.4 0 400 100 i
*> 10.30.30.0/24 192.168.63.3 0 0 300 i
*> 10.40.40.0/24 192.168.64.4 0 0 400 i
目前尚無特定資訊可用於排解此組態的疑難問題。
修訂 | 發佈日期 | 意見 |
---|---|---|
3.0 |
30-Aug-2023 |
已更新標題、背景資訊、樣式要求和格式。 |
2.0 |
21-Jul-2022 |
重新認證 |
1.0 |
10-Dec-2001 |
初始版本 |