DynagenでCCIEを目指す
20100601 BGP AS_PATHに基づくmetric制御
最終更新:
it_certification
-
view
目的
- BGPとIGPを連携をする方法を確認します。
構成
- 設定概要
- LAN内はOSPFによってルーティングします。
- R2, ISP10とR3, ISP10の間でeBGP neighborを確立します。
- 構成図

- netファイル
model = 3620 [localhost] [[3620]] image = C:\Program Files\Dynamips\images\c3620-j1s3-mz.123-18.bin ram = 128 [[ROUTER R1]] f0/0 = LAN 1 [[ROUTER R2]] f0/0 = LAN 1 f1/0 = LAN 2 [[ROUTER R3]] f0/0 = LAN 1 f1/0 = LAN 2 [[ROUTER ISP10]] f1/0 = LAN 2
- 初期設定 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 FastEthernet0/0 ip address 192.168.1.1 255.255.255.0 duplex auto speed auto ! router ospf 1 log-adjacency-changes network 192.168.1.1 0.0.0.0 area 0 ! 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 FastEthernet0/0 ip address 192.168.1.2 255.255.255.0 duplex auto speed auto ! interface FastEthernet1/0 ip address 192.168.2.2 255.255.255.0 duplex auto speed auto ! router ospf 1 log-adjacency-changes network 192.168.1.2 0.0.0.0 area 0 ! 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 FastEthernet0/0 ip address 192.168.1.3 255.255.255.0 duplex auto speed auto ! interface FastEthernet1/0 ip address 192.168.2.3 255.255.255.0 duplex auto speed auto ! router ospf 1 log-adjacency-changes network 192.168.1.3 0.0.0.0 area 0 ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
- 初期設定 ISP10
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname ISP10 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 11.11.11.11 255.255.255.255 secondary ip address 22.22.22.22 255.255.255.255 secondary ip address 33.33.33.33 255.255.255.255 secondary ip address 10.10.10.10 255.255.255.255 ! interface FastEthernet1/0 ip address 192.168.2.10 255.255.255.0 duplex auto speed auto ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
検証1 BGPの基本設定
- BGPの設定
R2, ISP10とR3, ISP10の間でBGP neighborを確立します。
R2(config)#router bgp 1 R2(config-router)#neighbor 192.168.2.10 remote-as 2 R3(config)#router bgp 1 R3(config-router)#neighbor 192.168.2.10 remote-as 2 ISP10(config)#router bgp 2 ISP10(config-router)#neighbor 192.168.2.2 remote-as 1 ISP10(config-router)#neighbor 192.168.2.3 remote-as 1 ISP10(config-router)#network 11.11.11.11 mask 255.255.255.255 ISP10(config-router)#network 22.22.22.22 mask 255.255.255.255 ISP10(config-router)#network 33.33.33.33 mask 255.255.255.255
- BGPの確認
R2, R3でBGPによる経路通知ができているかを確認します。
R2#show ip bgp summary BGP router identifier 2.2.2.2, local AS number 1 BGP table version is 4, main routing table version 4 3 network entries using 303 bytes of memory 3 path entries using 144 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 531 total bytes of memory BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.2.10 4 2 5 5 4 0 0 00:01:30 3 R2# R2# R2# R2#show ip route bgp 33.0.0.0/32 is subnetted, 1 subnets B 33.33.33.33 [20/0] via 192.168.2.10, 00:00:48 22.0.0.0/32 is subnetted, 1 subnets B 22.22.22.22 [20/0] via 192.168.2.10, 00:00:48 11.0.0.0/32 is subnetted, 1 subnets B 11.11.11.11 [20/0] via 192.168.2.10, 00:00:48 R2#
検証2 複数ISPの再現
- AS_PATHの設定
Dynagenでは複数ASを経由するような大規模なネットワークのテストは難しいです。そこで、route-mapを使用して複数ASを経由したルートを再現します。
ISP10(config)#access-list 11 permit 11.11.11.11 ISP10(config)#access-list 22 permit 22.22.22.22 ISP10(config)#access-list 33 permit 33.33.33.33 ISP10(config)# ISP10(config)# ISP10(config)#route-map SET_AS_PATH permit 10 ISP10(config-route-map)#match ip address 11 ISP10(config-route-map)#set as-path prepend 10 ISP10(config-route-map)#exit ISP10(config)#route-map SET_AS_PATH permit 20 ISP10(config-route-map)#match ip address 22 ISP10(config-route-map)#set as-path prepend 20 ISP10(config-route-map)#exit ISP10(config)#route-map SET_AS_PATH permit 30 ISP10(config-route-map)#match ip address 33 ISP10(config-route-map)#set as-path prepend 30 ISP10(config-route-map)#exit ISP10(config)#route-map SET_AS_PATH permit 40 ISP10(config-route-map)#exit ISP10(config)# ISP10(config)# ISP10(config)#router bgp 2 ISP10(config-router)#neighbor 192.168.2.2 route-map SET_AS_PATH out ISP10(config-router)#neighbor 192.168.2.3 route-map SET_AS_PATH out
- ルートの再送信
以下のコマンドで、BGPで通知するルートを再送信します。
ISP10#clear ip bgp * out
- AS_PATHの確認
show ip bgpコマンドで、AS_PATHを確認します。
R2#show ip bgp BGP table version is 7, local router ID is 2.2.2.2 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 *> 11.11.11.11/32 192.168.2.10 0 0 2 10 i *> 22.22.22.22/32 192.168.2.10 0 0 2 20 i *> 33.33.33.33/32 192.168.2.10 0 0 2 30 i R2#
検証3 AS_PATHによるmetricの制御
- 設定概要
AS_PATHによりロードバランスをしたり主系・待機系の切替をしたりする事ができます。
以下の設定では、AS10を含むルートはR2経由、AS20を含むルートはR3経由になるように制御します。また、AS10, AS20を含まないものはロードバランスするようにします。
以下の設定では、AS10を含むルートはR2経由、AS20を含むルートはR3経由になるように制御します。また、AS10, AS20を含まないものはロードバランスするようにします。
- R2の設定
R2に以下の設定を投入します。
R2(config)#ip as-path access-list 10 permit .*_10_.* R2(config)#ip as-path access-list 20 permit .*_20_.* R2(config)# R2(config)# R2(config)#route-map BGP2OSPF permit 10 R2(config-route-map)#match as-path 10 R2(config-route-map)#set metric 50 R2(config-route-map)#exit R2(config)#route-map BGP2OSPF permit 20 R2(config-route-map)#match as-path 20 R2(config-route-map)#set metric 100 R2(config-route-map)#exit R2(config)#route-map BGP2OSPF permit 30 R2(config-route-map)#set metric 20 R2(config-route-map)#exit R2(config)# R2(config)# R2(config)#router ospf 1 R2(config-router)#redistribute bgp 1 route-map BGP2OSPF subnets
- R3の設定
R3に以下の設定を投入します。
R3(config)#ip as-path access-list 10 permit .*_10_.* R3(config)#ip as-path access-list 20 permit .*_20_.* R3(config)# R3(config)# R3(config)# R3(config)#route-map BGP2OSPF permit 10 R3(config-route-map)#match as-path 10 R3(config-route-map)#set metric 100 R3(config-route-map)#exit R3(config)#route-map BGP2OSPF permit 20 R3(config-route-map)#match as-path 20 R3(config-route-map)#set metric 50 R3(config-route-map)#exit R3(config)#route-map BGP2OSPF permit 30 R3(config-route-map)#set metric 20 R3(config-route-map)#exit R3(config)# R3(config)# R3(config)# R3(config)#router ospf 1 R3(config-router)#redistribute bgp 1 route-map BGP2OSPF subnets
- ルーティングテーブルの確認
AS10経由である11.11.11.11がR2経由で、AS20経由である22.22.22.22がR3経由である事が読み取れます。また、33.33.33.33はロードバランスされている事も分かります。
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 1.0.0.0/32 is subnetted, 1 subnets C 1.1.1.1 is directly connected, Loopback0 33.0.0.0/32 is subnetted, 1 subnets O E2 33.33.33.33 [110/20] via 192.168.1.2, 00:00:05, FastEthernet0/0 <- ロードバランス [110/20] via 192.168.1.3, 00:00:05, FastEthernet0/0 <- ロードバランス 22.0.0.0/32 is subnetted, 1 subnets O E2 22.22.22.22 [110/50] via 192.168.1.3, 00:00:05, FastEthernet0/0 <- R3経由 11.0.0.0/32 is subnetted, 1 subnets O E2 11.11.11.11 [110/50] via 192.168.1.2, 00:00:05, FastEthernet0/0 <- R2経由 C 192.168.1.0/24 is directly connected, FastEthernet0/0 R1#
検証4 デフォルトルート
- デフォルトルートの設定
デフォルトルートの設定をR2, R3に対して施します。なお、alwaysオプションは、「ルーティングテーブル上にデフォルトルートがなくても、デフォルトルートを他のルータに通知する」という意味です。
R2(config)#router ospf 1 R2(config-router)#default-information originate always metric 50 R3(config)#router ospf 1 R3(config-router)#default-information originate always metric 100
- ルーティングテーブルの確認
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 192.168.1.2 to network 0.0.0.0 1.0.0.0/32 is subnetted, 1 subnets C 1.1.1.1 is directly connected, Loopback0 33.0.0.0/32 is subnetted, 1 subnets O E2 33.33.33.33 [110/20] via 192.168.1.2, 00:02:08, FastEthernet0/0 [110/20] via 192.168.1.3, 00:02:08, FastEthernet0/0 22.0.0.0/32 is subnetted, 1 subnets O E2 22.22.22.22 [110/50] via 192.168.1.3, 00:02:08, FastEthernet0/0 11.0.0.0/32 is subnetted, 1 subnets O E2 11.11.11.11 [110/50] via 192.168.1.2, 00:02:08, FastEthernet0/0 C 192.168.1.0/24 is directly connected, FastEthernet0/0 O*E2 0.0.0.0/0 [110/50] via 192.168.1.2, 00:00:06, FastEthernet0/0 R1#
添付ファイル