コンフィグレーションガイド Vol.3


23.2.7 BGP4広告経路フィルタリング【OP-BGP】

〈この項の構成〉

(1) 他プロトコルの経路を広告する

直結経路とスタティック経路の中で,宛先ネットワークが自ASのネットワーク(192.168.0.0/16)である経路だけをBGP4へ広告します。

[設定のポイント]

デフォルトでは広告しない経路を広告させるには,redistributeを設定します。redistributeには,広告したいプロトコルを指定します。

redistributeに,経路広告条件のroute-mapを指定します。route-map中の宛先ネットワーク条件の指定にはip prefix-listを使用します。

[コマンドによる設定]

  1. (config)# ip prefix-list PERMIT192168LONGER seq 10 permit 192.168.0.0/16 ge 16 le 32

    192.168.0.0/16に含まれる経路だけpermitになるip prefix-listを設定します。

  2. (config)# route-map PERMIT192168LONGER permit 10

    (config-route-map)# match ip address prefix-list PERMIT192168LONGER

    (config-route-map)# exit

    192.168.0.0/16に含まれる経路だけpermitになるroute-mapを設定します。

  3. (config)# router bgp 65531

    (config-router)# redistribute connected route-map PERMIT192168LONGER

    (config-router)# redistribute static route-map PERMIT192168LONGER

    直結経路とスタティック経路について,route-map PERMIT192168LONGERでフィルタした結果がpermitになる経路だけを広告するように,redistributeを設定します。

  4. (config-router)# end

    # clear ip bgp * out

    広告経路フィルタリング設定の変更を動作に反映します。

(2) ピアごとに広告経路を変更する

外部ピアに広告する経路を,AS100から受信したASパス長が一つのBGP4経路,および自ASのネットワークが宛先である直結経路とスタティック経路(192.168.0.0/16)だけに制限します。広告に当たり,ピア172.18.1.1へはAS_PATHのAS番号を二つ追加します。内部ピアには,BGP4経路だけを広告します。

[設定のポイント]

ピア個別に経路フィルタリングする必要がある場合,neighbor outを設定してください。

今回の場合,次の四つのroute-mapを設定します。

  • 直結経路およびスタティック経路のredistribute用

    192.168.0.0/16に含まれている経路だけpermitになるip prefix-listを設定して,これを参照するroute-mapを設定します。

  • ピア172.18.1.1広告用

    経路プロトコルが直結またはスタティックの場合だけASを二つ追加するroute-mapを設定します。

  • 172.18.1.1以外の外部ピア用

    ASが一つのAS_PATH属性だけpermitになるip as-path access-listを設定して,これを参照するroute-mapを設定します。

  • 内部ピア用

    BGP4経路だけpermit,それ以外はdenyになるroute-mapを設定します。

[コマンドによる設定]

  1. (config)# ip prefix-list PERMIT192168LONGER seq 10 permit 192.168.0.0/16 ge 16 le 32

    (config)# route-map PERMIT192168LONGER permit 10

    (config-route-map)# match ip address prefix-list PERMIT192168LONGER

    (config-route-map)# exit

    192.168.0.0/16に含まれる経路だけpermitになるroute-mapを設定します。直結経路およびスタティック経路のredistributeに使用します。

  2. (config)# ip as-path access-list 1 permit "^[0-9]+$"

    (config)# route-map BGPEXTOUT permit 10

    (config-route-map)# match protocol connected static

    (config-route-map)# exit

    (config)# route-map BGPEXTOUT permit 20

    (config-route-map)# match protocol bgp

    (config-route-map)# match as-path 1

    (config-route-map)# exit

    直結経路,スタティック経路,BGP4経路の中でAS_PATH属性のAS数が一つの経路だけpermitになるroute-mapを設定します。外部ピアへの広告に使用します。

  3. (config)# route-map BGP1721811OUT permit 10

    (config-route-map)# match protocol connected static

    (config-route-map)# set as-path prepend count 2

    (config-route-map)# exit

    (config)# route-map BGP1721811OUT permit 20

    (config-route-map)# match protocol bgp

    (config-route-map)# match as-path 1

    (config-route-map)# set as-path prepend count 2

    (config-route-map)# exit

    直結経路,スタティック経路,BGP4経路の中でAS_PATH属性のAS数が一つの経路だけpermitになり,ASを二つ追加するroute-mapを設定します。ピア172.18.1.1への広告に使用します。

  4. (config)# route-map BGPINTOUT permit 10

    (config-route-map)# match protocol bgp

    (config-route-map)# exit

    BGP4経路だけpermitになるroute-mapを設定します。内部ピアへの広告に使用します。

  5. (config)# router bgp 65531

    (config-router)# redistribute connected route-map PERMIT192168LONGER

    (config-router)# redistribute static route-map PERMIT192168LONGER

    直結経路とスタティック経路について,route-map PERMIT192168LONGERでフィルタした結果がpermitになる経路だけを広告するようにredistributeを設定します。

  6. (config-router)# neighbor 172.17.1.1 remote-as 65532

    (config-router)# neighbor 172.17.1.1 route-map BGPEXTOUT out

    外部ピアへの広告経路のフィルタにBGPEXTOUTを使用します。

  7. (config-router)# neighbor 172.18.1.1 remote-as 65533

    (config-router)# neighbor 172.18.1.1 route-map BGP1721811OUT out

    外部ピア172.18.1.1への広告経路のフィルタにBGP1721811OUTを使用します。

  8. (config-router)# neighbor 192.168.1.1 remote-as 65531

    (config-router)# neighbor 192.168.1.1 route-map BGPINTOUT out

    内部ピアへの広告経路のフィルタにBGPINTOUTを使用します。

  9. (config-router)# end

    # clear ip bgp * out

    広告経路フィルタリング設定の変更を動作に反映します。