DynagenでCCIEを目指す
20100609 BGP ポリシーベースルーティング LocPrf
最終更新:
it_certification
-
view
目的
- LOCAL_PREFERNCE属性によって経路を制御する方法を確認します。
構成
- 設定概要
- R1, R2, R3の間でフルメッシュiBGP neighborを確立します。
- R1, R2, R3はEIGRPを用いて、Loopback I/Fへのルーティングを定義します。
- 構成図

- 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 = R3 e0/1 [[ROUTER R2]] e0/2 = R3 e0/2 e0/3 = LAN 1 [[ROUTER R3]] e0/3 = LAN 1 [[ROUTER ISP10]] 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.0 half-duplex ! interface Ethernet0/1 ip address 192.168.13.1 255.255.255.0 half-duplex ! interface Ethernet0/2 no ip address shutdown half-duplex ! interface Ethernet0/3 no ip address shutdown half-duplex ! router eigrp 1 network 1.1.1.1 0.0.0.0 network 192.168.12.1 0.0.0.0 network 192.168.13.1 0.0.0.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 Ethernet0/0 ip address 192.168.12.2 255.255.255.0 half-duplex ! interface Ethernet0/1 no ip address shutdown half-duplex ! interface Ethernet0/2 ip address 192.168.23.2 255.255.255.0 half-duplex ! interface Ethernet0/3 ip address 192.168.100.2 255.255.255.0 half-duplex ! router eigrp 1 network 2.2.2.2 0.0.0.0 network 192.168.12.2 0.0.0.0 network 192.168.23.2 0.0.0.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 Ethernet0/0 no ip address shutdown half-duplex ! interface Ethernet0/1 ip address 192.168.13.3 255.255.255.0 half-duplex ! interface Ethernet0/2 ip address 192.168.23.3 255.255.255.0 half-duplex ! interface Ethernet0/3 ip address 192.168.100.3 255.255.255.0 half-duplex ! router eigrp 1 network 3.3.3.3 0.0.0.0 network 192.168.13.3 0.0.0.0 network 192.168.23.3 0.0.0.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 Ethernet0/0 no ip address shutdown half-duplex ! interface Ethernet0/1 no ip address shutdown half-duplex ! interface Ethernet0/2 no ip address shutdown half-duplex ! interface Ethernet0/3 ip address 192.168.100.10 255.255.255.0 half-duplex ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
検証1 環境構築
- eBGP neighborの設定
R1, R2, R3でフルメッシュのiBGP neighborを確立させます。また、AS 1, AS 2間でeBGP neighborを確立されます。
R1(config)#router bgp 1 R1(config-router)#neighbor 2.2.2.2 remote-as 1 R1(config-router)#neighbor 2.2.2.2 update-source Loopback 0 R1(config-router)#neighbor 3.3.3.3 remote-as 1 R1(config-router)#neighbor 3.3.3.3 update-source Loopback 0 R2(config)#router bgp 1 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 next-hop-self R2(config-router)#neighbor 3.3.3.3 remote-as 1 R2(config-router)#neighbor 3.3.3.3 update-source Loopback 0 R2(config-router)#neighbor 3.3.3.3 next-hop-self R2(config-router)#neighbor 192.168.100.10 remote-as 2 R3(config)#router bgp 1 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 next-hop-self R3(config-router)#neighbor 2.2.2.2 remote-as 1 R3(config-router)#neighbor 2.2.2.2 update-source Loopback 0 R3(config-router)#neighbor 2.2.2.2 next-hop-self R3(config-router)#neighbor 192.168.100.10 remote-as 2 ISP10(config)#router bgp 2 ISP10(config-router)#neighbor 192.168.100.2 remote-as 1 ISP10(config-router)#neighbor 192.168.100.3 remote-as 1 ISP10(config-router)#network 10.10.10.10 mask 255.255.255.255 ISP10(config-router)#network 192.168.100.0 mask 255.255.255.0
- ネットワークの生成
ISP10に接続されているネットワークを再現します。以下のように、secondaryアドレスを使用して生成します。
設定が完了したら、clear ip bgpコマンドでルートを明示的に送信します。
設定が完了したら、clear ip bgpコマンドでルートを明示的に送信します。
ISP10(config)#interface Loopback 0 ISP10(config-if)#ip address 172.16.0.10 255.255.255.0 secondary ISP10(config-if)#ip address 172.16.1.10 255.255.255.0 secondary ISP10(config-if)#ip address 172.16.2.10 255.255.255.0 secondary ISP10(config-if)#ip address 172.16.3.10 255.255.255.0 secondary ISP10(config-if)#exit ISP10(config)# ISP10(config)# ISP10(config)# ISP10(config)#router bgp 2 ISP10(config-router)#network 172.16.0.0 mask 255.255.255.0 ISP10(config-router)#network 172.16.1.0 mask 255.255.255.0 ISP10(config-router)#network 172.16.2.0 mask 255.255.255.0 ISP10(config-router)#network 172.16.3.0 mask 255.255.255.0 ISP10(config-router)#^Z ISP10# *Mar 1 00:13:18.279: %SYS-5-CONFIG_I: Configured from console by console ISP10# ISP10# ISP10#clear ip bgp * out
- ベストパスの確認
R1のベストパスを確認します。Weightなど殆どパラメータが同じです。この場合は、Next HopのルータIDが小さい方が優先されるので、R2経由のルートがベストパスになります。
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 * i10.10.10.10/32 3.3.3.3 0 100 0 2 i *>i 2.2.2.2 0 100 0 2 i *>i172.16.0.0/24 2.2.2.2 0 100 0 2 i * i 3.3.3.3 0 100 0 2 i *>i172.16.1.0/24 2.2.2.2 0 100 0 2 i * i 3.3.3.3 0 100 0 2 i *>i172.16.2.0/24 2.2.2.2 0 100 0 2 i * i 3.3.3.3 0 100 0 2 i * i192.168.100.0 3.3.3.3 0 100 0 2 i *>i 2.2.2.2 0 100 0 2 i R1#
検証2 ルータに対するLocPrf設定
- LocPrf設定
R3から送信されるルートのLocPrfを200にします。
R3(config)#router bgp 1 R3(config-router)#bgp default local-preference 200 R3(config-router)#^Z R3# *Mar 1 00:26:23.007: %SYS-5-CONFIG_I: Configured from console by console R3# R3#clear ip bgp * out
- ベストパスの確認
R1のBGPテーブルを確認します。LocPrfの値が200になった事が確認できます。また、R2経由, R3経由の2種類あったルートが1種類になっています。これはスプリットホライズンによる影響ですが、詳細は検証3で確認します。
R1#show ip bgp BGP table version is 16, 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 200 0 2 i *>i172.16.0.0/24 3.3.3.3 0 200 0 2 i *>i172.16.1.0/24 3.3.3.3 0 200 0 2 i *>i172.16.2.0/24 3.3.3.3 0 200 0 2 i *>i172.16.3.0/24 3.3.3.3 0 200 0 2 i *>i192.168.100.0 3.3.3.3 0 200 0 2 i R1#
検証3 route-mapによるLocPrf設定 (失敗例)
- LocPrfの設定
R2から送信される一部のルートに対してLocPrfの設定を行います。
R2(config)#ip prefix-list LIST_LOCPRF seq 10 permit 172.16.0.0/23 ge 24 le 24 R2(config)# R2(config)# R2(config)#route-map MAP_LOCPRF permit 10 R2(config-route-map)#match ip address prefix-list LIST_LOCPRF R2(config-route-map)#set local-preference 300 R2(config-route-map)#exit R2(config)#route-map MAP_LOCPRF permit 20 R2(config-route-map)#exit R2(config)# R2(config)# R2(config)#router bgp 1 R2(config-router)#neighbor 1.1.1.1 route-map MAP_LOCPRF out R2(config-router)#^Z R2# *Mar 1 00:42:14.655: %SYS-5-CONFIG_I: Configured from console by console R2# R2# R2#clear ip bgp 1.1.1.1 out
- ベストパスの確認
R1のBGPテーブルを確認します。先ほど設定したLocPrfが全く反映されていない事が分かります。
R1#show ip bgp BGP table version is 32, 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 200 0 2 i *>i172.16.0.0/24 3.3.3.3 0 200 0 2 i *>i172.16.1.0/24 3.3.3.3 0 200 0 2 i *>i172.16.2.0/24 3.3.3.3 0 200 0 2 i *>i172.16.3.0/24 3.3.3.3 0 200 0 2 i *>i192.168.100.0 3.3.3.3 0 200 0 2 i R1#
- スプリットホライズンの確認
LocPrfが反映されない原因を確かめるために、R2を調査します。まず、R2からR1に送信されたルートを確認しようとすると、R1に対して何も送信していなかった事が分かります。
R2#show ip bgp neighbors 1.1.1.1 advertised-routes R2#
さらにR2のBGPテーブルを見ると、R3経由であるルートがベストパスになっています。R3経由のルートはスプリットホライズンのルールによるR1には送信されません。従って、LocPrfの設定が反映されるルートは何もないという事が分かります。
R2#show ip bgp BGP table version is 32, 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 200 0 2 i * 192.168.100.10 0 0 2 i *>i172.16.0.0/24 3.3.3.3 0 200 0 2 i * 192.168.100.10 0 0 2 i *>i172.16.1.0/24 3.3.3.3 0 200 0 2 i * 192.168.100.10 0 0 2 i *>i172.16.2.0/24 3.3.3.3 0 200 0 2 i * 192.168.100.10 0 0 2 i *>i172.16.3.0/24 3.3.3.3 0 200 0 2 i * 192.168.100.10 0 0 2 i r>i192.168.100.0 3.3.3.3 0 200 0 2 i r 192.168.100.10 0 0 2 i R2#
検証4 route-mapによるLocPrf設定
- LocPrfの設定
R2から送信されるルートではなく、R2が受信するルートに対してLocPrfの設定を行います。
R2(config)#router bgp 1 R2(config-router)#no neighbor 1.1.1.1 route-map MAP_LOCPRF out R2(config-router)#neighbor 192.168.100.10 route-map MAP_LOCPRF in R2(config-router)#^Z R2# *Mar 1 00:48:05.375: %SYS-5-CONFIG_I: Configured from console by console R2# R2# R2#clear ip bgp 192.168.100.10 in R2#
- ベストパスの確認
R1のBGPテーブルを確認します。一部のルートの経由とLocPrfが変化した事が分かります。
R1#show ip bgp BGP table version is 34, 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 200 0 2 i *>i172.16.0.0/24 2.2.2.2 0 300 0 2 i <- LocPrfが変化 *>i172.16.1.0/24 2.2.2.2 0 300 0 2 i <- LocPrfが変化 *>i172.16.2.0/24 3.3.3.3 0 200 0 2 i *>i172.16.3.0/24 3.3.3.3 0 200 0 2 i *>i192.168.100.0 3.3.3.3 0 200 0 2 i R1#
- スプリットホライズンの確認
R2の設定を再確認します。R1へは全てのルートが送信されているわけではなく、172.16.2.0/24, 172.16.3.0/24にはスプリットホライズンのルールが働いている事が分かります。
R2#show ip bgp neighbors 1.1.1.1 advertised-routes BGP table version is 34, 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 *> 172.16.0.0/24 192.168.100.10 0 300 0 2 i *> 172.16.1.0/24 192.168.100.10 0 300 0 2 i R2#
ルーティングテーブルを見ても、172.16.2.0/24, 172,16.3.0/24はR3から受信したルートがベストパスとなるため、スプリットホライズンのルールが適用される事が分かります。また、172.16.0.0/24, 172.16.1.0/24はISP10からのルートがベストパスになるため、スプリットホライズンは働きません。
R2#show ip bgp BGP table version is 34, 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 200 0 2 i * 192.168.100.10 0 0 2 i *> 172.16.0.0/24 192.168.100.10 0 300 0 2 i *> 172.16.1.0/24 192.168.100.10 0 300 0 2 i *>i172.16.2.0/24 3.3.3.3 0 200 0 2 i * 192.168.100.10 0 0 2 i *>i172.16.3.0/24 3.3.3.3 0 200 0 2 i * 192.168.100.10 0 0 2 i r>i192.168.100.0 3.3.3.3 0 200 0 2 i r 192.168.100.10 0 0 2 i R2#
添付ファイル