詳細解析配置BGP負載共享

字號:

1. BGP鄰居之間使用Loopback地址進行負載共享
    該場景展示如何在多條(可有6條)等價鏈路上完成負載共享。該鏈路建立在本地AS中一臺路由器和遠程AS中另一臺路由器之間是一個單宿主末端網(wǎng)絡(luò) BGP環(huán)境。
    配置如下:
    RouterA
    RA(config)#int s1/1
    RA(config-if)#ip add 150.10.10.1 255.255.255.0
    RA(config-if)#no sh
    RA(config-if)#int s1/2
    RA(config-if)#ip add 160.20.20.1 255.255.255.0
    RA(config-if)#no sh
    RA(config-if)#int lo0
    RA(config-if)#ip add 1.1.1.1 255.255.255.0
    RA(config)#router bgp 11
    RA(config-router)#nei 2.2.2.2 remote-as 10
    RA(config-router)#nei 2.2.2.2 update-source lo0
    RA(config-router)#nei 2.2.2.2 ebgp-multihop
    RA(config-router)#router eigrp 12
    RA(config-router)#net 1.0.0.0
    RA(config-router)#net 150.10.0.0
    RA(config-router)#net 160.20.0.0
    RA(config-router)#no auto-summary
    RouterB
    RB(config)#int lo0
    RB(config-if)#ip add 2.2.2.2 255.255.255.0
    RB(config-if)#int s1/1
    RB(config-if)#no ip route-cache
    RB(config-if)#ip add 160.20.20.2 255.255.255.0
    RB(config-if)#no sh
    RB(config-if)#int s1/2
    RB(config-if)#no ip route-cache
    RB(config-if)#ip add 150.10.10.2 255.255.255.0
    RB(config-if)#no sh
    RB(config-if)#router bgp 10
    RB(config-router)#nei 1.1.1.1 remote-as 11
    RB(config-router)#nei 1.1.1.1 update-source lo0
    RB(config-router)#nei 1.1.1.1 ebgp-multihop
    RB(config-router)#router eigrp 12
    RB(config-router)#net 2.0.0.0
    RB(config-router)#net 150.10.0.0
    RB(config-router)#net 160.20.0.0
    RB(config-router)#no auto-summary
    驗證基于數(shù)據(jù)包(過程交換)的負載均衡:
    RA#sh ip ro
    Gateway of last resort is not set
     1.0.0.0/24 is subnetted, 1 subnets
    C 1.1.1.0 is directly connected, Loopback0
     2.0.0.0/24 is subnetted, 1 subnets
    D 2.2.2.0 [90/2297856] via 150.10.10.2, 00:18:47, Serial1/1
     [90/2297856] via 160.20.20.2, 00:18:47, Serial1/2
     160.20.0.0/24 is subnetted, 1 subnets
    C 160.20.20.0 is directly connected, Serial1/2
     150.10.0.0/24 is subnetted, 1 subnets
    C 150.10.10.0 is directly connected, Serial1/1
    RA#traceroute 2.2.2.2
    Type escape sequence to abort.
    Tracing the route to 2.2.2.2
     1 150.10.10.2 36 msec
    160.20.20.2 60 msec *
    2. 單臺邊界路由器多宿主末端網(wǎng)絡(luò)連接到單一ISP環(huán)境中的負載共享
    本場景展示了當(dāng)在遠程AS和本地AS之間存在多條鏈路時如何完成負載共享。鏈路建立在本地AS中的一個路由器和遠程AS中的多個路由器之間。
    默認情況下BGP只從可能存在的等價路徑中選擇出一條的路徑,通過命令maximum-path對可選擇的等價路徑數(shù)目(1~6)進行修改。
    配置如下:
    RouterA
    RouterA (config)#int s1/0
    RouterA (config-if)#ip add 160.20.20.1 255.255.255.0
    RouterA (config-if)#no sh
    RouterA (config)#int s1/2
    RouterA (config-if)#ip add 150.10.10.1 255.255.255.0
    RouterA (config-if)#no sh
    RouterA (config-if)#int lo0
    RouterA (config-if)#ip add 1.1.1.1 255.255.255.0
    RouterA (config-if)#router bgp 11
    RouterA (config-router)#network 1.0.0.0
    RouterA (config-router)#neighbor 150.10.10.2 remote-as 10
    RouterA (config-router)#neighbor 160.20.20.2 remote-as 10
    RouterA (config-router)#maximum-paths 2
    RouterB
    RourterB(config)#int s1/2
    RourterB(config-if)#ip add 160.20.20.2 255.255.255.0
    RourterB(config-if)#no sh
    RourterB(config-if)#int fa0/0
    RourterB(config-if)#ip add 2.2.2.1 255.255.255.0
    RourterB(config-if)#no sh
    RourterB(config)#router bgp 10
    RourterB(config-router)#network 2.0.0.0
    RourterB(config-router)#neighbor 160.20.20.1 remote-as 11
    RourterB(config-router)#auto-summary
    RouterC
    RourterB(config)#int s1/2
    RourterB(config-if)#ip add 150.10.10.2 255.255.255.0
    RourterB(config-if)#no sh
    RourterB(config-if)#int fa0/0
    RourterB(config-if)#ip add 2.2.2.2 255.255.255.0
    RourterB(config-if)#no sh
    RourterB(config)#router bgp 10
    RourterB(config-router)#network 2.0.0.0
    RourterB(config-router)#neighbor 150.10.10.1 remote-as 11
    RourterB(config-router)#auto-summary
    驗證:
    RouterA# sh ip bgp
    BGP table version is 5, local router ID is 1.1.1.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
    *> 1.0.0.0 0.0.0.0 0 32768 i
    *> 2.0.0.0 160.20.20.2 0 0 10 i
    * 150.10.10.2 0 0 10 i
    RouterA#sh ip ro
    Gateway of last resort is not set
     1.0.0.0/24 is subnetted, 1 subnets
    C 1.1.1.0 is directly connected, Loopback0
    B 2.0.0.0/8 [20/0] via 150.10.10.2, 00:16:32
     [20/0] via 160.20.20.2, 00:15:47
     160.20.0.0/24 is subnetted, 1 subnets
    C 160.20.20.0 is directly connected, Serial1/0
     150.10.0.0/24 is subnetted, 1 subnets
    C 150.10.10.0 is directly connected, Serial1/2
    RouterA#
    RouterA#traceroute 2.2.2.2
    Type escape sequence to abort.
    Tracing the route to 2.2.2.2
     1 150.10.10.2 64 msec
    160.20.20.2 92 msec *
    3. 多臺邊界路由器多宿主末端網(wǎng)絡(luò)連接到單一ISP環(huán)境中的負載共享
    這個場景展示了當(dāng)通過多個本地路由器到達同一ISP具有多條連接時如何完成負載共享。兩個eBGP對等體分別建立在兩個獨立的本地路由器上。在兩條鏈路上負載均衡是不可能發(fā)生的因為BGP會在從eBGP和iBGP學(xué)來的路由中挑選出一條的路由。在去往AS10的多條路徑上進行負載共享是很好的選擇,這種負載共享可以基于預(yù)先制定的路由策略讓去往某一特定網(wǎng)絡(luò)的流量在兩條鏈路上通過。此外,當(dāng)其中一條鏈路失效后另外一條鏈路能充當(dāng)其備分鏈路。
    現(xiàn)在假定AS11的BGP路由策略如下:
    ● AS11接收來自AS10的本地路由,連同其余一些默認的Inetnet路由。
    ● 外出流量策略是:
    ①從R101去往Internet的所有流量走R101-R103這條鏈路。
    ②若R101-R103鏈路失效則R101去往Internet的所有流量從R102到達AS10.
    ③從R102去往Internet的所有流量走R102-R104這條鏈路。
    ④若R102-R104鏈路失效則R102去往Internet的所有流量從R101到達AS10.
    ●進入流量的策略是:
    ①從Inetnet到網(wǎng)絡(luò)192.168.11.0/24的流量走R103-R101這條鏈路。
    ②從Inetnet到網(wǎng)絡(luò)192.168.12.0/24的流量走R104-R102這條鏈路。
    ③如果到AS10的其中一條鏈路失效,那么另一條鏈路必須路由所有從Intnet返回到AS11的流量。
    要達成以上策略,就要使得經(jīng)R101到R103所通告192.168.11.0的As-Path比經(jīng)R102到R104的As-Path短,則AS10就會選擇R103-R101鏈路為路徑。同樣的,經(jīng)R102-R104鏈路所通告的192.168.12.0也要有較短的As-Path,那么AS10就會為去往AS11網(wǎng)絡(luò)192.168.12.0的流量優(yōu)選鏈路R104-R102.
    對于外出的流量,BGP會根據(jù)通過eBGP學(xué)得的路由來決定路徑,這些路由也可從iBGP學(xué)到。所以R101既可以通過eBGP從R103學(xué)到10.10.34.0又可以通過iBGP從R102學(xué)到。但是外部路徑優(yōu)先于內(nèi)部路徑。所以R101到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
    R101(config)#int s1/1
    R101(config-if)#ip add 10.10.13.1 255.255.255.0
    R101(config-if)#no sh
    R101(config-if)#int fa0/0
    R101(config-if)#ip add 192.168.12.1 255.255.255.0
    R101(config-if)#ip add 192.168.11.1 255.255.255.0 sec
    R101(config-if)#no sh
    R101(config)#router bgp 11
    R101(config-router)#no syn
    R101(config-router)#net 192.168.11.0
    R101(config-router)#net 192.168.12.0
    R101(config-router)#nei 10.10.13.3 remote-as 10
    R101(config-router)#nei 10.10.13.3 route-map R101-R103-MAP out
    R101(config-router)#nei 192.168.12.2 remote-as 11
    R101(config-router)#nei 192.168.12.2 next-hop-self
    R101(config-router)#maximum-paths 2
    R101(config-router)#no auto-summary
    R101(config-router)#access-list 1 permit 192.168.12.0
    R101(config)#access-list 2 per 192.168.11.0
    R101(config)#route-map R101-R103-MAP per 10
    R101(config-route-map)#match ip add 1
    R101(config-route-map)#set as-path prepend 11 11 11
    R101(config-route-map)#route-map R101-R103-MAP per 20
    R101(config-route-map)#match ip add 2
    R102
    R102(config)#int s1/2
    R102(config-if)#ip add 10.10.24.2 255.255.255.0
    R102(config-if)#no sh
    R102(config-if)#int fa0/0
    R102(config-if)#ip add 192.168.12.2 255.255.255.0
    R102(config-if)#ip add 192.168.11.2 255.255.255.0 sec
    R102(config-if)#no sh
    R102(config)#router bgp 11
    R102(config-router)#no syn
    R102(config-router)#net 192.168.11.0
    R102(config-router)#net 192.168.12.0
    R102(config-router)#nei 10.10.24.4 remote-as 10
    R102(config-router)#nei 10.10.24.4 route-map R102-R104-MAP out
    R102(config-router)#nei 192.168.12.1 remote-as 11
    R102(config-router)#nei 192.168.12.1 next-hop-self
    R102(config-router)#no auto-summary
    R102(config-router)#access-list 1 permit 192.168.11.0
    R102(config)#access-list 2 per 192.168.12.0
    R102(config)#route-map R102-R104-MAP per 10
    R102(config-route-map)#match ip add 1
    R102(config-route-map)#set as-path prepend 11 11 11
    R102(config-route-map)#route-map R102-R104-MAP per 20
    R102(config-route-map)#match ip add 2
    R103
    R103(config)#int s1/0
    R103(config-if)#ip add 10.10.13.3 255.255.255.0
    R103(config-if)#no sh
    R103(config-if)#int fa0/0
    R103(config-if)#ip add 10.10.34.3 255.255.255.0
    R103(config-if)#no sh
    R103(config)#router bgp 10
    R103(config-router)#no syn
    R103(config-router)#net 10.10.34.0 mask 255.255.255.0
    R103(config-router)#nei 10.10.13.1 remote-as 11
    R103(config-router)#nei 10.10.13.1 default-originate
    R103(config-router)#nei 10.10.34.4 remote-as 10
    R103(config-router)#nei 10.10.34.4 next-hop-self
    R103(config-router)#no auto-summary
    R104
    R104(config)#int s1/0
    R104(config-if)#ip add 10.10.24.4 255.255.255.0
    R104(config-if)#no sh
    R104(config-if)#int fa0/0
    R104(config-if)#ip add 10.10.34.4 255.255.255.0
    R104(config-if)#no sh
    R104(config)#router bgp 10
    R104(config-router)#no syn
    R104(config-router)#nei 10.10.24.2 remote-as 11
    R104(config-router)#nei 10.10.24.2 default-originate
    R104(config-router)#nei 10.10.34.3 remote-as 10
    R104(config-router)#nei 10.10.34.3 next-hop-self
    R104(config-router)#no auto-summary
    R101的BGP表中顯示所以去往Internet的流量都通過鏈R101-R103.
    R101#sh ip bgp
    BGP table version is 6, 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
    *> 10.10.34.0/24 10.10.13.3 0 0 10 i
    * i 192.168.12.2 100 0 10 i
    * 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#sh ip ro
    Gateway of last resort is 10.10.13.3 to network 0.0.0.0
    C 192.168.12.0/24 is directly connected, FastEthernet0/0
    C 192.168.11.0/24 is directly connected, FastEthernet0/0
     10.0.0.0/24 is subnetted, 2 subnets
    C 10.10.13.0 is directly connected, Serial1/1
    B 10.10.34.0 [20/0] via 10.10.13.3, 00:02:39
    B* 0.0.0.0/0 [20/0] via 10.10.13.3, 00:13:01
    R102的BGP表中顯示按照路由策略所以去往AS10的流量都通過R102-R104.
    R102#sh ip bgp
    BGP table version is 5, 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
    * i 192.168.12.1 100 0 10 i
    * i10.10.34.0/24 192.168.12.1 0 100 0 10 i
    *> 10.10.24.4 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#sh ip ro
    Gateway of last resort is 10.10.24.4 to network 0.0.0.0
    C 192.168.12.0/24 is directly connected, FastEthernet0/0
    C 192.168.11.0/24 is directly connected, FastEthernet0/0
     10.0.0.0/24 is subnetted, 2 subnets
    C 10.10.24.0 is directly connected, Serial1/2
    B 10.10.34.0 [20/0] via 10.10.24.4, 00:04:12
    B* 0.0.0.0/0 [20/0] via 10.10.24.4, 00:12:08
    驗證從AS10進入AS11的流量。去往網(wǎng)絡(luò)192.168.11.0的流量走鏈路R103-R101,去往網(wǎng)絡(luò)162.168.12.0的流量走鏈路R104-R102.
    R103# sh ip bgp
    BGP table version is 5, 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
    *>i192.168.12.0 10.10.34.4 0 100 0 11 i
    * 10.10.13.1 0 0 11 11 11 11 i
    R103#sh ip ro
    Gateway of last resort is not set
    B 192.168.12.0/24 [200/0] via 10.10.34.4, 00:49:14
    B 192.168.11.0/24 [20/0] via 10.10.13.1, 00:52:36
     10.0.0.0/24 is subnetted, 2 subnets
    C 10.10.13.0 is directly connected, Serial1/0
    C 10.10.34.0 is directly connected, FastEthernet0/0
    在R104上情況相同。
    當(dāng)R101-R103的鏈路失效后,R102-R104成為其備分鏈路
    R103(config)#int s1/0
    R103(config-if)#sh
    R101#sh ip bgp
    BGP table version is 8, 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
    *>i10.10.34.0/24 192.168.12.2 100 0 10 i
    * 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#sh ip ro
    Gateway of last resort is 192.168.12.2 to network 0.0.0.0
    C 192.168.12.0/24 is directly connected, FastEthernet0/0
    C 192.168.11.0/24 is directly connected, FastEthernet0/0
     10.0.0.0/24 is subnetted, 1 subnets
    B 10.10.34.0 [200/0] via 192.168.12.2, 00:01:42
    B* 0.0.0.0/0 [200/0] via 192.168.12.2, 00:01:42
    R103#sh ip bgp
    BGP table version is 7, 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#sh ip ro
    Gateway of last resort is not set
    B 192.168.12.0/24 [200/0] via 10.10.34.4, 01:09:47
    B 192.168.11.0/24 [200/0] via 10.10.34.4, 00:14:08
     10.0.0.0/24 is subnetted, 1 subnets
    C 10.10.34.0 is directly connected, FastEthernet0/0