BGP WEIGHT - Cisco Config



 ◆ Cisco独自のBGPアトリビュート - WEIGHT

 WEIGHTアトリビュートは、
シスコ独自のBGPアトリビュートであり、ベストパス選択のアルゴリズム比較
 の最初に使用されるアトリビュートです。WEIGHTアトリビュート値はローカルルータにのみ適用されます。
 つまり、EBGPネイバーにもIBGPネイバーにもWEIGHT値は伝わりません。

 WEIGHT値のデフォルトはローカルルータで生成したルートは「
32768 」であり、BGPピアから受け取る
 るルートは「
0 」です。WEIGHT値が最大のルートが優先されます。このWEIGHTアトリビュートが使用
 されるケースは、1台のBGPルータがASから出口に複数のパスがある場合などです。


    


 上図のように、AS40にあるネットワークをAS20とAS30の両方から受け取るとします。A10のR1の設定で
 AS20のR2から受信する全てのBGPルートを「200」として、R3から受信する全てのBGPルートを「100」
 とした場合、AS40から「40.0.0.0/16」宛てにパケットを送信する場合、AS20のR2経由で通信をします。


 ◆ WEIGHTアトリビュート - 設定

 WEIGHTアトリビュートはのコマンドの設定は、以下の4パターンのコンフィグで設定することができます。

 1. ネイバー単位でWEIGHT値を割り当てる設定
 2. ルートマップで指定したルートにWEIGHT値を割り当てる設定( match ip address or Prefix )
 3. ルートマップで指定したルートにWEIGHT値を割り当てる設定( match as-path )
 4. Filter-listでWEIGHT値を割り当てる設定

 下図のトラフィックフローを実現するためのコンフィグを以下に紹介します。


     


 ◆ ネイバー単位でWEIGHT値を割り当てる設定

 R1(config)# router bgp 10
 R1(config-router)# neighbor 2.1.1.254 remote-as 20
 R1(config-router)# neighbor 2.1.1.254 weight 200
 R1(config-router)# neighbor 3.1.1.254 remote-as 30
 R1(config-router)# neighbor 3.1.1.254 weight 100


 ◆ ルートマップで指定したルートにWEIGHT値を割り当てる設定( match ip address )

 R1(config)# access-list 1 permit 40.0.0.0 0.0.255.255

 R1(config)# route-map R-WEIGHT-R2 permit 10
 R1(config-route-map)# match ip address 1
 R1(config-route-map)# set weight 200

 R1(config)# route-map R-WEIGHT-R2 permit 20

 R1(config)# route-map R-WEIGHT-R3 permit 10
 R1(config-route-map)# match ip address 1
 R1(config-route-map)# set weight 100

 R1(config)# route-map R-WEIGHT-R3 permit 20


 R1(config)# router bgp 10
 R1(config-router)# neighbor 2.1.1.254 remote-as 20
 R1(config-router)# neighbor 2.1.1.254 route-map R-WEIGHT-R2 in
 R1(config-router)# neighbor 3.1.1.254 remote-as 30
 R1(config-router)# neighbor 3.1.1.254 route-map R-WEIGHT-R3 in


 ◆ ルートマップで指定したルートにWEIGHT値を割り当てる設定( match as-path )

 R1(config)# ip as-path access-list 1 permit ^20_
 R1(config)# ip as-path access-list 2 permit ^30_

 R1(config)# route-map R-WEIGHT-R2 permit 10
 R1(config-route-map)# match as-path 1
 R1(config-route-map)# set weight 200

 R1(config)# route-map R-WEIGHT-R2 permit 20

 R1(config)# route-map R-WEIGHT-R3 permit 10
 R1(config-route-map)# match as-path 2
 R1(config-route-map)# set weight 100

 R1(config)# route-map R-WEIGHT-R3 permit 20


 R1(config)# router bgp 10
 R1(config-router)# neighbor 2.1.1.254 remote-as 20
 R1(config-router)# neighbor 2.1.1.254 route-map R-WEIGHT-R2 in
 R1(config-router)# neighbor 3.1.1.254 remote-as 30
 R1(config-router)# neighbor 3.1.1.254 route-map R-WEIGHT-R3 in


 ◆ Filter-listでWEIGHT値を割り当てる設定

 R1(config)# ip as-path access-list 1 permit ^20_
 R1(config)# ip as-path access-list 2 permit ^30_

 R1(config)# router bgp 10
 R1(config-router)# neighbor 2.1.1.254 remote-as 20
 R1(config-router)# neighbor 2.1.1.254 filter-list 1 weight 200
 R1(config-router)# neighbor 3.1.1.254 remote-as 30
 
R1(config-router)# neighbor 3.1.1.254 filter-list 2 weight 100




BGP(Border Gateway Protocol)

ネットワークエンジニアとして

Copyright (C) 2002-2024 ネットワークエンジニアとして All Rights Reserved.