DynagenでCCIEを目指す
20100620 BGP 負荷分散
最終更新:
it_certification
-
view
目的
- BGPにおける、以下2通りの負荷分散方法を確認します。
- 方法1 : next-hopへの経路をIGPにより負荷分散させます
- 方法2 : BPGに対しmaximum-pathsを設定します
構成
- 設定概要
- 初期設定はip addressのみです
- 構成図

- netファイル
model = 3620 [localhost] [[3620]] image = C:\Program Files\Dynamips\images\c3620-j1s3-mz.123-18.bin ram = 128 [[ROUTER R1]] e0/0 = R2 e0/0 e0/1 = R2 e0/1 e0/2 = R3 e0/2 [[ROUTER R2]] e0/3 = LAN 1 [[ROUTER R3]] e0/3 = LAN 1
- 初期設定 R1
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R1 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 1.1.1.1 255.255.255.255 ! interface Ethernet0/0 ip address 192.168.12.1 255.255.255.128 half-duplex ! interface Ethernet0/1 ip address 192.168.12.129 255.255.255.128 half-duplex ! interface Ethernet0/2 ip address 192.168.13.1 255.255.255.0 half-duplex ! interface Ethernet0/3 no ip address shutdown half-duplex ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
- 初期設定 R2
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R2 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 2.2.2.2 255.255.255.255 ! interface Ethernet0/0 ip address 192.168.12.2 255.255.255.128 half-duplex ! interface Ethernet0/1 ip address 192.168.12.130 255.255.255.128 half-duplex ! interface Ethernet0/2 no ip address shutdown half-duplex ! interface Ethernet0/3 ip address 192.168.100.2 255.255.255.0 half-duplex ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
- 初期設定 R3
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R3 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 3.3.3.3 255.255.255.255 ! interface Ethernet0/0 no ip address shutdown half-duplex ! interface Ethernet0/1 no ip address shutdown half-duplex ! interface Ethernet0/2 ip address 192.168.13.3 255.255.255.0 half-duplex ! interface Ethernet0/3 ip address 192.168.100.3 255.255.255.0 half-duplex ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
検証1 IGPの設定
- IGPの設定
next-hopへの負荷分散を確認するため、IGPでR1, R2間の経路を負荷分散させます。
以下のようにOSPFで負荷分散するように設定を投入します(ついでにR3へのルーティングも設定しておきます)。
以下のようにOSPFで負荷分散するように設定を投入します(ついでにR3へのルーティングも設定しておきます)。
R1(config)#router ospf 1 R1(config-router)#network 192.168.12.1 0.0.0.0 area 0 R1(config-router)#network 192.168.12.129 0.0.0.0 area 0 R1(config-router)#network 192.168.13.1 0.0.0.0 area 0 R1(config-router)#network 1.1.1.1 0.0.0.0 area 0 R2(config)#router ospf 1 R2(config-router)#network 192.168.12.2 0.0.0.0 area 0 R2(config-router)#network 192.168.12.130 0.0.0.0 area 0 R2(config-router)#network 2.2.2.2 0.0.0.0 area 0 R3(config)#router ospf 1 R3(config-router)#network 192.168.13.3 0.0.0.0 area 0 R3(config-router)#network 3.3.3.3 0.0.0.0 area 0
- IGPの確認
R1, R2間で負荷分散されている事を確認します。
R1#show ip route ospf 2.0.0.0/32 is subnetted, 1 subnets O 2.2.2.2 [110/11] via 192.168.12.130, 00:00:08, Ethernet0/1 <- 2通りの経路がある事を確認します [110/11] via 192.168.12.2, 00:00:08, Ethernet0/0 <- 2通りの経路がある事を確認します 3.0.0.0/32 is subnetted, 1 subnets O 3.3.3.3 [110/11] via 192.168.13.3, 00:00:08, Ethernet0/2 R1# R2#show ip route ospf 1.0.0.0/32 is subnetted, 1 subnets O 1.1.1.1 [110/11] via 192.168.12.1, 00:00:46, Ethernet0/0 <- 2通りの経路がある事を確認します [110/11] via 192.168.12.129, 00:00:46, Ethernet0/1 <- 2通りの経路がある事を確認します O 192.168.13.0/24 [110/20] via 192.168.12.1, 00:00:46, Ethernet0/0 [110/20] via 192.168.12.129, 00:00:46, Ethernet0/1 3.0.0.0/32 is subnetted, 1 subnets O 3.3.3.3 [110/21] via 192.168.12.129, 00:00:46, Ethernet0/1 [110/21] via 192.168.12.1, 00:00:46, Ethernet0/0 R2#
検証2 next-hopへの負荷分散
- BGPの設定
R1, R2間でeBGP neighborの設定を行います。
R1(config)#router bgp 1 R1(config-router)#neighbor 2.2.2.2 remote-as 2 R1(config-router)#neighbor 2.2.2.2 update-source Loopback 0 R1(config-router)#neighbor 2.2.2.2 ebgp-multihop R2(config)#router bgp 2 R2(config-router)#neighbor 1.1.1.1 remote-as 1 R2(config-router)#neighbor 1.1.1.1 update-source Loopback 0 R2(config-router)#neighbor 1.1.1.1 ebgp-multihop R2(config-router)#network 192.168.100.0 mask 0
- BGPの確認
BGPにより経路が交換された事を確認します。
R1#show ip bgp BGP table version is 2, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 192.168.100.0 2.2.2.2 0 0 2 i R1#
- 負荷分散の確認
R1からnext-hopが2.2.2.2である192.168.100.3(R3 e0/3)に対し、tracerouteを実行します。2.2.2.2までの経路はIGPによるルーティングテーブルを参照するため、以下のように負荷分散されます。
R1#traceroute Protocol [ip]: Target IP address: 192.168.100.3 Source address: 1.1.1.1 Numeric display [n]: Timeout in seconds [3]: Probe count [3]: Minimum Time to Live [1]: Maximum Time to Live [30]: Port Number [33434]: Loose, Strict, Record, Timestamp, Verbose[none]: Type escape sequence to abort. Tracing the route to 192.168.100.3 1 192.168.12.2 8 msec <- R2 e0/0を経由しています 192.168.12.130 36 msec <- R2 e0/1を経由しています 192.168.12.2 36 msec <- R2 e0/0を経由しています 2 192.168.100.3 [AS 2] 60 msec 84 msec * R1#
検証3 maximum-pathsによる負荷分散
- shutdown
検証を簡略化するためmaximun-pathsを検証するのに不要な経路をshutdownします。R1 e0/1に対し、shutdownコマンドを発行します。
R1(config)#interface Ethernet 0/1 R1(config-if)#shutdown R1(config-if)# *Mar 1 00:13:56.603: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Ethernet0/1 from FULL to DOWN, Neighbor Down: Interface down or detached *Mar 1 00:13:58.595: %LINK-5-CHANGED: Interface Ethernet0/1, changed state to administratively down *Mar 1 00:13:59.595: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down R1(config-if)#
- BGP neighborの設定
R1, R3間でBGP neighborを確立させます。
R1(config)#router bgp 1 R1(config-router)#neighbor 3.3.3.3 remote-as 2 R1(config-router)#neighbor 3.3.3.3 update-source Loopback 0 R1(config-router)#neighbor 3.3.3.3 ebgp-multihop R3(config)#router bgp 2 R3(config-router)#neighbor 1.1.1.1 remote-as 1 R3(config-router)#neighbor 1.1.1.1 update-source Loopback 0 R3(config-router)#neighbor 1.1.1.1 ebgp-multihop R3(config-router)#network 192.168.100.0 mask 255.255.255.0 R1#show ip bgp summary BGP router identifier 1.1.1.1, local AS number 1 BGP table version is 2, main routing table version 2 1 network entries using 101 bytes of memory 2 path entries using 96 bytes of memory 1 BGP path attribute entries using 60 bytes of memory 1 BGP AS-PATH entries using 24 bytes of memory 0 BGP route-map cache entries using 0 bytes of memory 0 BGP filter-list cache entries using 0 bytes of memory BGP using 281 total bytes of memory BGP activity 2/1 prefixes, 4/2 paths, scan interval 60 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 2.2.2.2 4 2 22 14 2 0 0 00:01:09 1 3.3.3.3 4 2 5 5 2 0 0 00:00:02 1 R1#
- 負荷分散の設定
負荷分散するようR1のBGPに対し、maximum-pathsの設定を投入します。
R1(config)#router bgp 1 R1(config-router)#maximum-paths 2
- ルーティングテーブルの確認
R1から192.168.100.0/24への経路に着目します。BGPテーブルを見るとベストパスが存在し3.3.3.3経由の方が優先されるように見えますが、ルーティングテーブルを見るとベストパスではない2.2.2.2経由のルートも使用し負荷分散されている様子が読み取れます。
maximum-pathsを使用すると、ベストパスではない経路もルーティングテーブルに載るようになります。
maximum-pathsを使用すると、ベストパスではない経路もルーティングテーブルに載るようになります。
R1#show ip bgp BGP table version is 3, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 192.168.100.0 3.3.3.3 0 0 2 i * 2.2.2.2 0 0 2 i R1# R1# R1# R1#show ip route Codes: 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 Gateway of last resort is not set 192.168.12.0/25 is subnetted, 2 subnets C 192.168.12.0 is directly connected, Ethernet0/0 O 192.168.12.128 [110/20] via 192.168.12.2, 00:05:04, Ethernet0/0 1.0.0.0/32 is subnetted, 1 subnets C 1.1.1.1 is directly connected, Loopback0 C 192.168.13.0/24 is directly connected, Ethernet0/2 2.0.0.0/32 is subnetted, 1 subnets O 2.2.2.2 [110/11] via 192.168.12.2, 00:05:04, Ethernet0/0 3.0.0.0/32 is subnetted, 1 subnets O 3.3.3.3 [110/11] via 192.168.13.3, 00:05:04, Ethernet0/2 B 192.168.100.0/24 [20/0] via 2.2.2.2, 00:01:24 <- 負荷分散 [20/0] via 3.3.3.3, 00:00:04 <- 負荷分散 R1#
- tracerouteによる確認
R1#traceroute Protocol [ip]: Target IP address: 192.168.100.2 Source address: 1.1.1.1 Numeric display [n]: y Timeout in seconds [3]: Probe count [3]: Minimum Time to Live [1]: Maximum Time to Live [30]: Port Number [33434]: Loose, Strict, Record, Timestamp, Verbose[none]: Type escape sequence to abort. Tracing the route to 192.168.100.2 1 192.168.12.2 68 msec 192.168.13.3 96 msec * R1#
検証4 負荷分散されない場合
- metric設定
maximum-pathsによって負荷分散されるのは、path, metric, LocPrfなどの属性が全て同じ場合のみです。以下のように、metricを定義し、BGP属性が異なる場合について検証します。
R3(config)#route-map MAP_MED permit 10 R3(config-route-map)#set metric 10 R3(config-route-map)#exit R3(config)# R3(config)#router bgp 2 R3(config-router)#neighbor 1.1.1.1 route-map MAP_MED out R3(config-router)#^Z R3# *Mar 1 00:36:51.843: %SYS-5-CONFIG_I: Configured from console by console R3# R3#clear ip bgp 1.1.1.1 out R3#
- ルーティングテーブルの確認
この場合はmetricが異なるので、検証3の時のように負荷分散されません。
R1#show ip bgp BGP table version is 4, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path * 192.168.100.0 3.3.3.3 10 0 2 i <- metricが設定された事を確認 *> 2.2.2.2 0 0 2 i R1# R1# R1#show ip route Codes: 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 Gateway of last resort is not set 192.168.12.0/25 is subnetted, 2 subnets C 192.168.12.0 is directly connected, Ethernet0/0 O 192.168.12.128 [110/20] via 192.168.12.2, 00:06:38, Ethernet0/0 1.0.0.0/32 is subnetted, 1 subnets C 1.1.1.1 is directly connected, Loopback0 C 192.168.13.0/24 is directly connected, Ethernet0/2 2.0.0.0/32 is subnetted, 1 subnets O 2.2.2.2 [110/11] via 192.168.12.2, 00:06:38, Ethernet0/0 3.0.0.0/32 is subnetted, 1 subnets O 3.3.3.3 [110/11] via 192.168.13.3, 00:06:38, Ethernet0/2 B 192.168.100.0/24 [20/0] via 2.2.2.2, 00:00:08 <- 負荷分散されていない事を確認 R1#
添付ファイル