DynagenでCCIEを目指す
20100613 BGP ポリシーベースルーティング AS_PATH
最終更新:
it_certification
-
view
目的
- AS_PATH値によって経路を制御する方法を確認します。
- CCIE lab対策が目的です。かなりトリッキーな方法なので、実践的ではないと思います。
構成
- 設定概要
- R1, R2, R3の間でフルメッシュiBGP neighborを確立します。
- R1, R2, R3はEIGRPを用いて、Loopback I/Fへのルーティングを定義します。
- トップページ/動作検証 ネットワーク系/20100610 BGP ポリシーベースルーティング MEDの設定の検証1終了時点の設定と全く同じです。
- 構成図

- netファイル
model = 3620 [localhost] [[3620]] image = C:\Program Files\Dynamips\images\c3620-j1s3-mz.123-18.bin ram = 128 [[ROUTER R1]] f0/0 = R2 f0/0 f1/0 = R3 f0/0 [[ROUTER R2]] f1/0 = LAN 1 [[ROUTER R3]] f1/0 = LAN 1 [[ROUTER ISP10]] f1/0 = 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 172.16.0.1 255.255.255.0 secondary ip address 172.16.1.1 255.255.255.0 secondary ip address 172.16.2.1 255.255.255.0 secondary ip address 172.16.3.1 255.255.255.0 secondary ip address 1.1.1.1 255.255.255.255 ! interface FastEthernet0/0 ip address 192.168.12.1 255.255.255.0 duplex auto speed auto ! interface FastEthernet1/0 ip address 192.168.13.1 255.255.255.0 duplex auto speed auto ! router eigrp 1 network 1.1.1.1 0.0.0.0 network 172.16.0.0 network 192.168.12.0 network 192.168.13.0 no auto-summary ! 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.12.2 255.255.255.0 duplex auto speed auto ! interface FastEthernet1/0 ip address 192.168.100.2 255.255.255.0 duplex auto speed auto ! router eigrp 1 network 2.2.2.2 0.0.0.0 network 192.168.12.0 no auto-summary ! 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.13.3 255.255.255.0 duplex auto speed auto ! interface FastEthernet1/0 ip address 192.168.100.3 255.255.255.0 duplex auto speed auto ! router eigrp 1 network 3.3.3.3 0.0.0.0 network 192.168.13.0 no auto-summary ! 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 10.10.10.10 255.255.255.255 ! interface FastEthernet1/0 ip address 192.168.100.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 LOCPRFのような設定
- BGPテーブルの確認
設定投入前のR1のBGPテーブルを確認します。10.10.10.10/32へのベストパスが2.2.2.2経由になっています。
R1#show ip bgp BGP table version is 6, 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 * i10.10.10.10/32 3.3.3.3 0 100 0 2 i *>i 2.2.2.2 0 100 0 2 i <- ルータIDが小さい方が優先されます *> 172.16.0.0/24 0.0.0.0 0 32768 i *> 172.16.1.0/24 0.0.0.0 0 32768 i *> 172.16.2.0/24 0.0.0.0 0 32768 i *> 172.16.3.0/24 0.0.0.0 0 32768 i R1#
- AS_PATHの設定
AS_PATHを調整する事で、LOCPRFのようにASの出口を制御する事ができます。以下のようにR2から受信するルートにASをプリペンドする事でR3の方が優先されます。
R2(config)#ip as-path access-list 1 permit ^2 R2(config)# R2(config)# R2(config)#route-map LOCPRF permit 10 R2(config-route-map)#match as-path 1 R2(config-route-map)#set as-path prepend 100 200 R2(config-route-map)#exit R2(config)#route-map LOCPRF permit 1000 R2(config-route-map)#exit R2(config)# R2(config)# R2(config)#router bgp 1 R2(config-router)#neighbor 192.168.100.10 route-map LOCPRF in R2(config-router)#^Z R2# *Mar 1 00:10:32.155: %SYS-5-CONFIG_I: Configured from console by console R2# R2#clear ip bgp 192.168.100.10 in
- R1 BGPテーブルの確認
R1のBGPテーブルを確認します。10.10.10.10/32のベストパスが3.3.3.3経由に変わっています。また、10.10.10.10/32へのルートで2.2.2.2経由のものが消えているのはスプリットホライズンの影響です。スプリットホライズンの詳細はトップページ/動作検証 ネットワーク系/20100609 BGP ポリシーベースルーティング LocPrfを参照して下さい。
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 *>i10.10.10.10/32 3.3.3.3 0 100 0 2 i *> 172.16.0.0/24 0.0.0.0 0 32768 i *> 172.16.1.0/24 0.0.0.0 0 32768 i *> 172.16.2.0/24 0.0.0.0 0 32768 i *> 172.16.3.0/24 0.0.0.0 0 32768 i R1#
- R2 BGPテーブルの確認
R2のBGPテーブルを確認します。確かにAS_PATHがプリペンドされている事が分かります。
R2#show ip bgp BGP table version is 11, 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 *>i10.10.10.10/32 3.3.3.3 0 100 0 2 i * 192.168.100.10 0 0 100 200 2 i <- AS_PATHがプリペンドされた事が分かります r>i172.16.0.0/24 1.1.1.1 0 100 0 i r>i172.16.1.0/24 1.1.1.1 0 100 0 i r>i172.16.2.0/24 1.1.1.1 0 100 0 i r>i172.16.3.0/24 1.1.1.1 0 100 0 i R2#
検証2 MEDのような設定
- BGPテーブルの確認
設定投入前のISP10のBGPテーブルを確認します。172.16.X.0/24へのベストパスが2.2.2.2経由になっています。
ISP10#show ip bgp BGP table version is 6, local router ID is 10.10.10.10 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 *> 10.10.10.10/32 0.0.0.0 0 32768 i *> 172.16.0.0/24 192.168.100.2 0 1 i * 192.168.100.3 0 1 i *> 172.16.1.0/24 192.168.100.2 0 1 i * 192.168.100.3 0 1 i *> 172.16.2.0/24 192.168.100.2 0 1 i * 192.168.100.3 0 1 i *> 172.16.3.0/24 192.168.100.2 0 1 i * 192.168.100.3 0 1 i ISP10#
- AS_PATHの設定
AS_PATHを調整する事で、MEDのようにASの入口を制御する事ができます。以下のようにISP10へ送信するルートにASをプリペンドする事でR3の方が優先されます。
R2(config)#access-list 100 permit ip 172.16.0.0 0.0.1.0 255.255.255.0 0.0.0.0 R2(config)# R2(config)#route-map MED permit 10 R2(config-route-map)#match ip address 100 R2(config-route-map)#set as-path prepend 300 400 R2(config-route-map)#exit R2(config)#route-map MED permit 1000 R2(config-route-map)#exit R2(config)# R2(config)# R2(config)#router bgp 1 R2(config-router)#neighbor 192.168.100.10 route-map MED out R2(config-router)#^Z R2# *Mar 1 00:22:57.751: %SYS-5-CONFIG_I: Configured from console by console R2# R2# R2#clear ip bgp 192.168.100.10 out
- BGP テーブルの確認
AS_PATHがプリペンドされた事によって、192.168.100.3経由のルートの方が優先されるようになりました。
ISP10#show ip bgp BGP table version is 8, local router ID is 10.10.10.10 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 *> 10.10.10.10/32 0.0.0.0 0 32768 i * 172.16.0.0/24 192.168.100.2 0 1 300 400 i *> 192.168.100.3 0 1 i <- ASがプリペンドされていないルートの方が優先されます * 172.16.1.0/24 192.168.100.2 0 1 300 400 i *> 192.168.100.3 0 1 i <- ASがプリペンドされていないルートの方が優先されます *> 172.16.2.0/24 192.168.100.2 0 1 i * 192.168.100.3 0 1 i *> 172.16.3.0/24 192.168.100.2 0 1 i * 192.168.100.3 0 1 i ISP10#
検証3 AS_PATHによるフィルタ
- AS_PATHの設定
AS_PATHに2をプリペンドしたルートをAS2に送信する事でルートをフィルタする事ができます。ISP10はAS_PATHに2を含んでいるルートはループしているものであると判断するため、ルートは破棄されます。
設定例は以下の通りです。
設定例は以下の通りです。
R2(config)#access-list 101 permit ip 172.16.0.0 0.0.2.0 255.255.255.0 0.0.0.0 R2(config)# R2(config)# R2(config)#route-map FILTER permit 10 R2(config-route-map)#match ip address 101 R2(config-route-map)#set as-path prepend 2 R2(config-route-map)#exit R2(config)#route-map FILTER permit 1000 R2(config-route-map)#exit R2(config)# R2(config)#router bgp 1 R2(config-router)#neighbor 192.168.100.10 route-map FILTER out R2(config-router)#^Z R2# *Mar 1 00:26:02.571: %SYS-5-CONFIG_I: Configured from console by console R2# R2# R2#clear ip bgp 192.168.100.10 out R3(config)#access-list 101 permit ip 172.16.0.0 0.0.2.0 255.255.255.0 0.0.0.0 R3(config)# R3(config)# R3(config)#route-map FILTER permit 10 R3(config-route-map)#match ip address 101 R3(config-route-map)#set as-path prepend 2 R3(config-route-map)#exit R3(config)#route-map FILTER permit 1000 R3(config-route-map)#exit R3(config)# R3(config)# R3(config)#router bgp 1 R3(config-router)#neighbor 192.168.100.10 route-map FILTER out R3(config-router)#^Z R3# *Mar 1 00:27:25.475: %SYS-5-CONFIG_I: Configured from console by console R3# R3# R3#clear ip bgp 192.168.100.10 out
- BGPテーブルの確認
フィルタされたルートがBGPテーブルから消えている事が確認できます。試験対策用のトリッキーな設定になっていますが、172.16.0.0/24の第3オクテッドのワイルドカードが2(=000000010)であるので、フィルタされるルートは172.16.0.0/24, 172.16.2.0/24です。
ISP10#show ip bgp BGP table version is 11, local router ID is 10.10.10.10 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 *> 10.10.10.10/32 0.0.0.0 0 32768 i * 172.16.1.0/24 192.168.100.2 0 1 i *> 192.168.100.3 0 1 i *> 172.16.3.0/24 192.168.100.2 0 1 i * 192.168.100.3 0 1 i ISP10#
- ループの確認
ISP10がループしていると判断したルートを破棄している様子は、debug ip bgp updateで確認できます。
ISP10#debug ip bgp updates BGP updates debugging is on ISP10# *Mar 1 00:20:35.771: BGP(0): 192.168.100.3 rcvd UPDATE w/ attr: nexthop 192.168.100.3, origin i, path 1 *Mar 1 00:20:35.775: BGP(0): 192.168.100.3 rcvd 172.16.1.0/24...duplicate ignored *Mar 1 00:20:35.775: BGP(0): 192.168.100.3 rcvd 172.16.3.0/24...duplicate ignored *Mar 1 00:20:35.779: BGP(0): 192.168.100.3 rcv UPDATE w/ attr: nexthop 192.168.100.3, origin i, originator 0.0.0.0, path 1 2, community , extended community *Mar 1 00:20:35.783: BGP(0): 192.168.100.3 rcv UPDATE about 172.16.0.0/24 -- DENIED due to: AS-PATH contains our own AS; <- ループしていると判断します。 *Mar 1 00:20:35.787: BGP(0): 192.168.100.3 rcv UPDATE about 172.16.2.0/24 -- DENIED due to: AS-PATH contains our own AS; <- ループしていると判断します。 ISP10#
添付ファイル