DynagenでCCIEを目指す
20100612 BGP ポリシーベースルーティング MEDのオプション
最終更新:
it_certification
-
view
目的
- MEDを設定する際に使用するオプションの使い方を確認します。
構成
- 設定概要
- 下記構成図の通りのBGP 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 R4]] 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 ! 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 ! 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 ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
- 初期設定 R4
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R4 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 4.4.4.4 255.255.255.255 ! interface FastEthernet1/0 ip address 192.168.2.4 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 neighborの設定
構成図の通りのBGP neighborを確立させます。
R1(config)#router bgp 1 R1(config-router)#neighbor 192.168.1.2 remote-as 2 R1(config-router)#neighbor 192.168.1.3 remote-as 3 R1(config-router)#network 1.1.1.1 mask 255.255.255.255 R1(config-router)#network 192.168.1.0 mask 255.255.255.0 R2(config)#router bgp 2 R2(config-router)#neighbor 192.168.1.1 remote-as 1 R2(config-router)#neighbor 192.168.2.4 remote-as 4 R2(config-router)#network 2.2.2.2 mask 255.255.255.255 R2(config-router)#network 192.168.2.0 mask 255.255.255.0 R3(config)#router bgp 3 R3(config-router)#neighbor 192.168.1.1 remote-as 1 R3(config-router)#neighbor 192.168.2.4 remote-as 4 R3(config-router)#network 3.3.3.3 mask 255.255.255.255 R3(config-router)#network 192.168.2.0 mask 255.255.255.0 R4(config)#router bgp 4 R4(config-router)#neighbor 192.168.2.2 remote-as 2 R4(config-router)#neighbor 192.168.2.3 remote-as 3 R4(config-router)#network 4.4.4.4 mask 255.255.255.255
- ルーティングの確認
上記で設定したBGPによってルートが交換できているかを確認します。
R1#show ip bgp BGP table version is 7, 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 *> 1.1.1.1/32 0.0.0.0 0 32768 i *> 2.2.2.2/32 192.168.1.2 0 0 2 i *> 3.3.3.3/32 192.168.1.3 0 0 3 i * 4.4.4.4/32 192.168.1.3 0 3 4 i *> 192.168.1.2 0 2 4 i *> 192.168.1.0 0.0.0.0 0 32768 i * 192.168.2.0 192.168.1.3 0 0 3 i *> 192.168.1.2 0 0 2 i R1#
検証2 bgp always-compare-med
- MED値の設定
192.168.2.0/24に対するMED値をR2, R3で設定し、R1に通知します。
R2(config)#access-list 1 permit 192.168.2.0 R2(config)# R2(config)# R2(config)#route-map MED permit 10 R2(config-route-map)#match ip address 1 R2(config-route-map)#set metric 100 R2(config-route-map)#exit R2(config)#route-map MED permit 20 R2(config-route-map)#exit R2(config)# R2(config)# R2(config)#router bgp 2 R2(config-router)#neighbor 192.168.1.1 route-map MED out R2(config-router)#^Z R2# *Mar 1 00:15:33.915: %SYS-5-CONFIG_I: Configured from console by console R2# R2# R2#clear ip bgp 192.168.1.1 out R3(config)#access-list 1 permit 192.168.2.0 R3(config)# R3(config)# R3(config)#route-map MED permit 10 R3(config-route-map)#match ip address 1 R3(config-route-map)#set metric 50 R3(config-route-map)#exit R3(config)#route-map MED permit 20 R3(config-route-map)#exit R3(config)# R3(config)# R3(config)#router bgp 3 R3(config-router)#neighbor 192.168.1.1 route-map MED out R3(config-router)#^Z R3# R3# R3# *Mar 1 00:24:13.687: %SYS-5-CONFIG_I: Configured from console by consolele R3#clear ip bgp 192.168.1.1 out
- BGPテーブルの確認
ベストパスを再決定されるためにclear ip bgp * コマンドを発行してから、BGPテーブルを確認します。192.168.2.0/24へのルートに着目すると、MED値が小さい192.168.1.3がベストパスになっていません。MED値は同じASから受信した場合のみ比較が行われるため、AS2, AS3と異なるルートから受信ルートのMED値は比較されません。
R1#clear ip bgp * R1# *Mar 1 00:24:24.431: %BGP-5-ADJCHANGE: neighbor 192.168.1.2 Down User reset *Mar 1 00:24:24.435: %BGP-5-ADJCHANGE: neighbor 192.168.1.3 Down User reset *Mar 1 00:25:04.415: %BGP-5-ADJCHANGE: neighbor 192.168.1.2 Up *Mar 1 00:25:09.031: %BGP-5-ADJCHANGE: neighbor 192.168.1.3 Up R1# R1#show ip bgp BGP table version is 8, 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 *> 1.1.1.1/32 0.0.0.0 0 32768 i * 2.2.2.2/32 192.168.1.3 0 3 4 2 i *> 192.168.1.2 0 0 2 i *> 3.3.3.3/32 192.168.1.3 0 0 3 i * 192.168.1.2 0 2 4 3 i * 4.4.4.4/32 192.168.1.3 0 3 4 i *> 192.168.1.2 0 2 4 i *> 192.168.1.0 0.0.0.0 0 32768 i * 192.168.2.0 192.168.1.3 50 0 3 i <- MED値が小さい方が優先されない *> 192.168.1.2 100 0 2 i R1#
- bgp always-compare-med
ASが異なる場合でもMED値の比較を行いたい場合は、bgp always-compare-medコマンドを発行します。このコマンドを発行した後に、BGPテーブルを確認すると、MED値が小さいルートがベストパスになっている事が確認できます。
R1(config)#router bgp 1 R1(config-router)#bgp always-compare-med R1(config-router)#^Z R1# *Mar 1 00:26:44.827: %SYS-5-CONFIG_I: Configured from console by console R1#clear ip bgp * R1# *Mar 1 00:26:52.715: %BGP-5-ADJCHANGE: neighbor 192.168.1.2 Down User reset *Mar 1 00:26:52.719: %BGP-5-ADJCHANGE: neighbor 192.168.1.3 Down User reset *Mar 1 00:27:28.439: %BGP-5-ADJCHANGE: neighbor 192.168.1.3 Up *Mar 1 00:27:41.667: %BGP-5-ADJCHANGE: neighbor 192.168.1.2 Up R1# R1# R1#show ip bgp BGP table version is 8, 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 *> 1.1.1.1/32 0.0.0.0 0 32768 i *> 2.2.2.2/32 192.168.1.2 0 0 2 i * 192.168.1.3 0 3 4 2 i * 3.3.3.3/32 192.168.1.2 0 2 4 3 i *> 192.168.1.3 0 0 3 i * 4.4.4.4/32 192.168.1.2 0 2 4 i *> 192.168.1.3 0 3 4 i *> 192.168.1.0 0.0.0.0 0 32768 i * 192.168.2.0 192.168.1.2 100 0 2 i *> 192.168.1.3 50 0 3 i <- MED値が小さい方が優先される R1#
検証3 MED値が空欄の場合の取り扱い
- MED値の定義
R2にて4.4.4.4/32へのルートのMED値を10として設定します。
R2(config)#access-list 2 permit 4.4.4.4 R2(config)# R2(config)# R2(config)#no route-map MED R2(config)#route-map MED permit 10 R2(config-route-map)#match ip address 1 R2(config-route-map)#set metric 50 R2(config-route-map)#exit R2(config)#route-map MED permit 20 R2(config-route-map)#match ip address 2 R2(config-route-map)#set metric 10 R2(config-route-map)#exit R2(config)#route-map MED permit 1000 R2(config-route-map)#^Z R2# *Mar 1 00:31:30.603: %SYS-5-CONFIG_I: Configured from console by console R2# R2# R2#clear ip bgp 192.168.1.1 out
- ベストパスの確認
R1にて4.4.4.4/32におけるベストパスを確認します。デフォルトの挙動では、MEDが空欄の場合はMEDが0であるものとして扱われるため、MED値を設定していない192.168.1.3経由のルートの方がベストパスになります。
R1#show ip bgp BGP table version is 8, 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 *> 1.1.1.1/32 0.0.0.0 0 32768 i *> 2.2.2.2/32 192.168.1.2 0 0 2 i * 192.168.1.3 0 3 4 2 i * 3.3.3.3/32 192.168.1.2 0 2 4 3 i *> 192.168.1.3 0 0 3 i * 4.4.4.4/32 192.168.1.2 10 0 2 4 i *> 192.168.1.3 0 3 4 i <- MED値を設定していない方が優先されます。 *> 192.168.1.0 0.0.0.0 0 32768 i *> 192.168.2.0 192.168.1.2 50 0 2 i * 192.168.1.3 50 0 3 i R1#
検証4 bgp bestpath med missing-as-worst
- bgp bestpath med missing-as-worst
MED値が設定されていないルートの方が優先されるのが困る場合は、bgp bestpath med missing-as-worstコマンドを使用します。このコマンドを使用すると、MED値が設定されていないルートのMED値が最大になります。
R1(config)#router bgp 1 R1(config-router)#bgp bestpath med missing-as-worst
- ベストパスの確認
MED値が設定されていなかったルートに対して、Metric欄に最大値が記入されており、ベストパスが切り替わった事が分かります。
R1#show ip bgp BGP table version is 9, 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 *> 1.1.1.1/32 0.0.0.0 0 32768 i *> 2.2.2.2/32 192.168.1.2 0 0 2 i * 192.168.1.3 4294967295 0 3 4 2 i * 3.3.3.3/32 192.168.1.2 4294967295 0 2 4 3 i *> 192.168.1.3 0 0 3 i *> 4.4.4.4/32 192.168.1.2 10 0 2 4 i * 192.168.1.3 4294967295 0 3 4 i *> 192.168.1.0 0.0.0.0 0 32768 i *> 192.168.2.0 192.168.1.2 50 0 2 i * 192.168.1.3 50 0 3 i R1#
添付ファイル