Cisco IOS ルーティング – BGP MEDの設定

スポンサーリンク

BGPにおけるMED値の取り扱いについてまとめます。deterministic-med, always-compare-medなどのMED比較方法に影響を与えるコマンドについての考察です。

コマンド一覧

このシナリオで重要なコマンド一覧は以下の通りです。

Router(config)# router bgp <as>
Router(config-router)# bgp deterministic-med
Router(config-router)# bgp always-compare-med
Router(config-router)# bgp bestpath med confed
Router(config-router)# bgp bestpath med missing-as-worst

構成図

以下の構成で動作確認を行います。

                        e0/0     e0/1
                       .2+--------+.2
                 ┌------+   R2   +------┐
                 │      +--------+      │
                 │          AS65024     │
         e0/0    │     e0/0     e0/1    │
 +--------+.1    │    .3+--------+.3    │
 |   R1   +------┼------+   R3   +------┤
 +--------+      │      +--------+      │
     AS65001     │          AS65003     │
                 │    e0/0      e0/1    │
                 │    .4+--------+.4    │
                 └------+   R4   +------┘
                         +--------+
                             AS65024
          192.168.0.0/24            192.168.234.0/24

 R1 Loopback0      R2 Loopback0      R3 Loopback0      R4 Loopback0
 10.1.1.1/32       10.2.2.2/32       10.3.3.3/32       10.4.4.4/32
 [R1]
router bgp 65001
 no synchronization
 bgp log-neighbor-changes
 neighbor EBGP peer-group
 neighbor EBGP ebgp-multihop 255
 neighbor EBGP update-source Loopback0
 neighbor 10.2.2.2 remote-as 65024
 neighbor 10.2.2.2 peer-group EBGP
 neighbor 10.3.3.3 remote-as 65003
 neighbor 10.3.3.3 peer-group EBGP
 neighbor 10.4.4.4 remote-as 65024
 neighbor 10.4.4.4 peer-group EBGP
 no auto-summary

 [R2]
router eigrp 1
 offset-list 0 out 2000000 Ethernet0/0
 network 10.2.2.2 0.0.0.0
 network 192.168.0.2 0.0.0.0
 no auto-summary
!
router bgp 65024
 no synchronization
 bgp log-neighbor-changes
 network 192.168.234.0
 neighbor 10.1.1.1 remote-as 65001
 neighbor 10.1.1.1 ebgp-multihop 255
 neighbor 10.1.1.1 update-source Loopback0
 neighbor 10.1.1.1 route-map RMAP_MED500 out
 neighbor 192.168.234.4 remote-as 65024
 no auto-summary
!
route-map RMAP_MED500 permit 10
 set metric 500

 [R3]
router eigrp 1
 offset-list 0 out 3000000 Ethernet0/0
 network 10.3.3.3 0.0.0.0
 network 192.168.0.3 0.0.0.0
 no auto-summary
!
router bgp 65003
 no synchronization
 bgp log-neighbor-changes
 network 192.168.234.0
 neighbor 10.1.1.1 remote-as 65001
 neighbor 10.1.1.1 ebgp-multihop 255
 neighbor 10.1.1.1 update-source Loopback0
 neighbor 10.1.1.1 route-map RMAP_MED300 out
 no auto-summary
!
route-map RMAP_MED300 permit 10
 set metric 300

 [R4]
router eigrp 1
 offset-list 0 out 5000000 Ethernet0/0
 network 10.4.4.4 0.0.0.0
 network 192.168.0.4 0.0.0.0
 no auto-summary
!
router bgp 65024
 no synchronization
 bgp log-neighbor-changes
 network 192.168.234.0
 neighbor 10.1.1.1 remote-as 65001
 neighbor 10.1.1.1 ebgp-multihop 255
 neighbor 10.1.1.1 update-source Loopback0
 neighbor 10.1.1.1 route-map RMAP_MED200 out
 neighbor 192.168.234.2 remote-as 65024
 no auto-summary
!
route-map RMAP_MED200 permit 10
 set metric 200

設定全文は下記ファイルです。詳細設定は下記を参照ください。

R1
!
version 12.4
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
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 10.1.1.1 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.0.1 255.255.255.0
 half-duplex
!
interface Ethernet0/1
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/2
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/3
 no ip address
 shutdown
 half-duplex
!
!
router eigrp 1
 network 10.1.1.1 0.0.0.0
 network 192.168.0.1 0.0.0.0
 no auto-summary
!
router bgp 65001
 no synchronization
 bgp log-neighbor-changes
 neighbor EBGP peer-group
 neighbor EBGP ebgp-multihop 255
 neighbor EBGP update-source Loopback0
 neighbor 10.2.2.2 remote-as 65024
 neighbor 10.2.2.2 peer-group EBGP
 neighbor 10.3.3.3 remote-as 65003
 neighbor 10.3.3.3 peer-group EBGP
 neighbor 10.4.4.4 remote-as 65024
 neighbor 10.4.4.4 peer-group EBGP
 no auto-summary
!
ip http server
ip forward-protocol nd
!
!
!
!
!
!
control-plane
!
!
!
!
mgcp behavior g729-variants static-pt
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
 login
!
!
end
R2
!
version 12.4
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
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 10.2.2.2 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.0.2 255.255.255.0
 half-duplex
!
interface Ethernet0/1
 ip address 192.168.234.2 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
 offset-list 0 out 2000000 Ethernet0/0
 network 10.2.2.2 0.0.0.0
 network 192.168.0.2 0.0.0.0
 no auto-summary
!
router bgp 65024
 no synchronization
 bgp log-neighbor-changes
 network 192.168.234.0
 neighbor 10.1.1.1 remote-as 65001
 neighbor 10.1.1.1 ebgp-multihop 255
 neighbor 10.1.1.1 update-source Loopback0
 neighbor 10.1.1.1 route-map RMAP_MED500 out
 neighbor 192.168.234.4 remote-as 65024
 no auto-summary
!
ip http server
ip forward-protocol nd
!
!
!
!
route-map RMAP_MED500 permit 10
 set metric 500
!
!
!
control-plane
!
!
!
!
mgcp behavior g729-variants static-pt
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
 login
!
!
end
R3
!
version 12.4
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
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 10.3.3.3 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.0.3 255.255.255.0
 half-duplex
!
interface Ethernet0/1
 ip address 192.168.234.3 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
 offset-list 0 out 3000000 Ethernet0/0
 network 10.3.3.3 0.0.0.0
 network 192.168.0.3 0.0.0.0
 no auto-summary
!
router bgp 65003
 no synchronization
 bgp log-neighbor-changes
 network 192.168.234.0
 neighbor 10.1.1.1 remote-as 65001
 neighbor 10.1.1.1 ebgp-multihop 255
 neighbor 10.1.1.1 update-source Loopback0
 neighbor 10.1.1.1 route-map RMAP_MED300 out
 no auto-summary
!
ip http server
ip forward-protocol nd
!
!
!
!
route-map RMAP_MED300 permit 10
 set metric 300
!
!
!
control-plane
!
!
!
!
mgcp behavior g729-variants static-pt
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
 login
!
!
end
R4
!
version 12.4
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
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 10.4.4.4 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.0.4 255.255.255.0
 half-duplex
!
interface Ethernet0/1
 ip address 192.168.234.4 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
 offset-list 0 out 5000000 Ethernet0/0
 network 10.4.4.4 0.0.0.0
 network 192.168.0.4 0.0.0.0
 no auto-summary
!
router bgp 65024
 no synchronization
 bgp log-neighbor-changes
 network 192.168.234.0
 neighbor 10.1.1.1 remote-as 65001
 neighbor 10.1.1.1 ebgp-multihop 255
 neighbor 10.1.1.1 update-source Loopback0
 neighbor 10.1.1.1 route-map RMAP_MED200 out
 neighbor 192.168.234.2 remote-as 65024
 no auto-summary
!
ip http server
ip forward-protocol nd
!
!
!
!
route-map RMAP_MED200 permit 10
 set metric 200
!
!
!
control-plane
!
!
!
!
mgcp behavior g729-variants static-pt
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
 login
!
!
end

仕様説明

デフォルト設定

BGP bestpath決定は、デフォルトの状態ではBGP tableに新しく載った順に評価されますこの2つpathが同一のASから経路であればMED値を用いて比較し、異なるASからの経路であればMED値は無視されます

bgp deterministic-med

以下のコマンドを投入すると、BGP tableに新しく載った順に評価するのではなく、まず同一ASからのpathを比較し、その後に残りのpathを比較するようになります。

Router(config)# router bgp <as>
Router(config-router)# bgp deterministic-med

bgp always-compare-med

以下のコマンドを投入すると、ASに関わらず常にMED値が比較されるようになります。

Router(config)# router bgp <as>
Router(config-router)# bgp always-compare-med

bgp bestpath med confed

以下のコマンドを投入すると、サブAS内についてMED値が比較されるようになります。

Router(config)# router bgp <as>
Router(config-router)# bgp bestpath med confed

bgp bestpath med missing-as-worst

MED値が付与されていないprefixの取り扱いはベンダー毎に異なります。Ciscoの場合は、MED値が付与されていないprefixはMED=0として取り扱います。また、RFC4277 “7.1.3. MED of Zero Versus No MED”によると、MED=0として取り扱うように書かれています。しかし、多くのベンダーはMED値が付与されていない場合はMED値と最大として扱う事が多いです。

多くのベンダーと同じようにMED値が付与されていない場合はMED値を最大として扱いたいならば、以下のコマンドを投入して下さい。

Router(config)# router bgp <as>
Router(config-router)# bgp bestpath med missing-as-worst

デフォルト設定

起動順序 1

R2, R3, R4の順番でBGP再起動を行います。

 [R2]
clear ip bgp *

 [R3]
clear ip bgp *

 [R4]
clear ip bgp *

動作確認 1

R1のBGP table上に存在する192.168.234.0/24のattributeをまとめると以下の通りです。

neighbor AS Path BGP MED IGP Metric
R4(10.4.4.4) 65024 200 5409600
R3(10.3.3.3) 65003 300 3409600
R2(10.2.2.2) 65024 500 2409600

デフォルトのBGP bestpathの決定アルゴリズムは、新しくBGP tableに載った順に評価します。

まず、R4, R3の経路を比較します。R4, R3のAS Pathは異なるのでMEDは無視されます。最終的にIGP Metricによって比較され、IGPで近いR3が優先されます。

次に、R3(前回の比較の勝者)とR2が比較されます。R3, R2のAS Pathが異なりますのでMEDは無視されます。最終的にIGP Metricによって比較され、IGPで近いR2が優先されます。

showコマンドによる確認は以下の通りです。このようにMED値が大きいものが優先されてしまう事もあります。

 [R1]
R1#show ip bgp 192.168.234.0
BGP routing table entry for 192.168.234.0/24, version 4
Paths: (3 available, best #3, table Default-IP-Routing-Table)
  Advertised to update-groups:
     1
  65024
    10.4.4.4 (metric 5409600) from 10.4.4.4 (10.4.4.4)
      Origin IGP, metric 200, localpref 100, valid, external
  65003
    10.3.3.3 (metric 3409600) from 10.3.3.3 (10.3.3.3)
      Origin IGP, metric 300, localpref 100, valid, external
  65024
    10.2.2.2 (metric 2409600) from 10.2.2.2 (10.2.2.2)
      Origin IGP, metric 500, localpref 100, valid, external, best
R1#

起動順序 2

R3, R4, R2の順番でBGP再起動を行います。

 [R3]
clear ip bgp *

 [R4]
clear ip bgp *

 [R2]
clear ip bgp *

動作確認 2

R1のBGP tableを確認します。先ほどはR2がbest pathでしたが、現在はR3がbest pathになっています。このように、デフォルト設定では起動順によってbest pathが変わる事もあります。

 [R1]
R1#show ip bgp 192.168.234.0
BGP routing table entry for 192.168.234.0/24, version 5
Paths: (3 available, best #3, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
     1
  65024
    10.2.2.2 (metric 2409600) from 10.2.2.2 (10.2.2.2)
      Origin IGP, metric 500, localpref 100, valid, external
  65024
    10.4.4.4 (metric 5409600) from 10.4.4.4 (10.4.4.4)
      Origin IGP, metric 200, localpref 100, valid, external
  65003
    10.3.3.3 (metric 3409600) from 10.3.3.3 (10.3.3.3)
      Origin IGP, metric 300, localpref 100, valid, external, best
R1#

bgp deterministic-med

起動順序

R2, R3, R4の順番でBGP再起動を行います。

 [R2]
clear ip bgp *

 [R3]
clear ip bgp *

 [R4]
clear ip bgp *

設定投入

R1に以下設定を投入します。

 [R1]
router bgp 65001
 bgp deterministic-med

動作確認

bgp deterministic-medコマンドにより、まず同一ASが比較されるようになります。同じAS65024に所属するR2とR4が比較され、MED値で優れているR4が勝者になります。次にR3とR4が比較され、IGP metricで優れているR3が勝者となります。

 [R1]
R1#show ip bgp 192.168.234.0
BGP routing table entry for 192.168.234.0/24, version 8
Paths: (3 available, best #1, table Default-IP-Routing-Table)
Flag: 0x4920
  Advertised to update-groups:
     1
  65003
    10.3.3.3 (metric 3409600) from 10.3.3.3 (10.3.3.3)
      Origin IGP, metric 300, localpref 100, valid, external, best
  65024
    10.4.4.4 (metric 5409600) from 10.4.4.4 (10.4.4.4)
      Origin IGP, metric 200, localpref 100, valid, external
  65024
    10.2.2.2 (metric 2409600) from 10.2.2.2 (10.2.2.2)
      Origin IGP, metric 500, localpref 100, valid, external
R1#

bgp always-compare-med

設定投入

R1に以下設定を投入します。

 [R1]
router bgp 65001
 bgp always-compare-med

動作確認

AS_PATHに関わらずMED値が最小の経路が選ばれるようになった事を確認します。なお、上記設定が反映されるまで60秒(BGP scan timer)かかります。

 [R1]
R1#show ip bgp 192.168.234.0
BGP routing table entry for 192.168.234.0/24, version 9
Paths: (3 available, best #2, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
     1
  65003
    10.3.3.3 (metric 3409600) from 10.3.3.3 (10.3.3.3)
      Origin IGP, metric 300, localpref 100, valid, external
  65024
    10.4.4.4 (metric 5409600) from 10.4.4.4 (10.4.4.4)
      Origin IGP, metric 200, localpref 100, valid, external, best
  65024
    10.2.2.2 (metric 2409600) from 10.2.2.2 (10.2.2.2)
      Origin IGP, metric 500, localpref 100, valid, external
R1#

bgp bestpath med-confed

設定変更

bgp bestpath med-confedの動作確認のため、R1, R2, R3, R4の設定をconfederationに変更します。

 [R1]
router bgp 65001
 bgp confederation identifier 100
 bgp confederation peers 65024 65003
 no bgp deterministic-med
 no bgp always-compare-med

 [R2, R4]
router bgp 65024
 bgp confederation identifier 100
 bgp confederation peers 65001

 [R3]
router bgp 65003
 bgp confederation identifier 100
 bgp confederation peers 65001

念のため、R2, R3, R4の順番でBGP再起動を行います。

 [R2]
clear ip bgp *

 [R3]
clear ip bgp *

 [R4]
clear ip bgp *

動作確認 1

MED値に基づく制御が行われておらず、MED値が大きいR5が優先されています。

 [R1]
R1#show ip bgp 192.168.234.0
BGP routing table entry for 192.168.234.0/24, version 7
Paths: (3 available, best #3, table Default-IP-Routing-Table)
Flag: 0x4920
  Advertised to update-groups:
     1
  (65024)
    10.4.4.4 (metric 5409600) from 10.4.4.4 (10.4.4.4)
      Origin IGP, metric 200, localpref 100, valid, confed-external
  (65003)
    10.3.3.3 (metric 3409600) from 10.3.3.3 (10.3.3.3)
      Origin IGP, metric 300, localpref 100, valid, confed-external
  (65024)
    10.2.2.2 (metric 2409600) from 10.2.2.2 (10.2.2.2)
      Origin IGP, metric 500, localpref 100, valid, confed-external, best
R1#

設定投入

confederation内からのprefixについて、MED比較するようにします。

 [R1]
router bgp 65001
 bgp bestpath med confed

動作確認 2

MED値に基づく制御が行われ、MEDが小さいR4が優先されています。

 [R1]
R1#show ip bgp 192.168.234.0
BGP routing table entry for 192.168.234.0/24, version 8
Paths: (3 available, best #1, table Default-IP-Routing-Table)
Flag: 0x4900
  Advertised to update-groups:
     1
  (65024)
    10.4.4.4 (metric 5409600) from 10.4.4.4 (10.4.4.4)
      Origin IGP, metric 200, localpref 100, valid, confed-external, best
  (65003)
    10.3.3.3 (metric 3409600) from 10.3.3.3 (10.3.3.3)
      Origin IGP, metric 300, localpref 100, valid, confed-external
  (65024)
    10.2.2.2 (metric 2409600) from 10.2.2.2 (10.2.2.2)
      Origin IGP, metric 500, localpref 100, valid, confed-external
R1#
タイトルとURLをコピーしました