BGP as-path access-list によるフィルタリング



トポロジ


条件
・AS54 から AS400 を透過して AS300 へ向かうルートを広報しないようにしてください。


まず下記設定からスタートです。

R1
interface f0/0
ip address 12.12.12.1 255.255.255.0

interface lo0
ip address 11.11.11.11 255.255.255.0

router ospf 1
network 12.12.12.0 0.0.0.255 area 0

router bgp 300
neighbor 12.12.12.2 remote-as 300
network 11.11.11.0 mask 255.255.255.0

R2
interface f0/0
ip address 12.12.12.2 255.255.255.0

interface f0/1
ip address 23.23.23.2 255.255.255.0

router ospf 1
network 12.12.12.0 0.0.0.255 area 0
network 23.23.23.0 0.0.0.255 area 23

router bgp 300
neighbor 12.12.12.1 remote-as 300
neighbor 12.12.12.1 next-hop-self
neighbor 23.23.23.3 remote-as 400

R3
interface f0/0
ip address 34.34.34.3 255.255.255.0

interface 0/1
ip address 23.23.23.3 255.255.255.0

router ospf 1
network 23.23.23.0 0.0.0.255 area 23

router rip
version 2
network 34.34.34.0
redistribute ospf 1 metric 3

router bgp 400
neighbor 23.23.23.2 remote-as 400
neighbor 34.34.34.4 remote-as 54
redistribute rip subnets

R4
interface f0/0
ip address 34.34.34.4 255.255.255.0

interface lo0
ip address 44.44.44.0 255.255.255.0

router rip
version 2
network 34.34.34.0

router bgp 54
neighbor 34.34.34.3 remote-as 400
network 44.44.44.0 mask 255.255.255.0



梅.2-6と初期設定は同じです。

AS400 を透過するルートなので、R3 にてフィルタリングを設定してやります。
まず、R3 にて AS54 へ広報しているルートを下記コマンドで確認します。


R3#sh ip bgp neighbors 34.34.34.4 advertised-routes
BGP table version is 9, local router ID is 34.34.34.3
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
*> 11.11.11.0/24    23.23.23.2                             0 300 i

Total number of prefixes 1



また、このルートは R4 ではどのように見えているかは R4 で sh ip bgp を見ます。



R4#sh ip bgp
BGP table version is 57, local router ID is 34.34.34.4
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
*> 11.11.11.0/24    34.34.34.3                             0 400 300 i
*> 44.44.44.0/24    0.0.0.0                  0         32768 i



AS400 を透過し、AS300へ向かうルートなので、11.11.11.0/24 へのエントリですね。
これを R3 にてフィルタしてやります。

R3
ip as-path access-list 1 permit _300$

route-map NO_ADV deny 10
match as -path 1

route-map NO_ADV permit 20

router bgp 400
neighbor 34.34.34.4 route-map NO_ADV out

設定内容は、まず as-path access-list にて 経路情報の発生元が AS300 となる
ものを指定。"_" は任意の文字列、"$" は文字列の終わり。

次に route-map にて as-path 1 に当てはまるものを deny している。
route-map NO_ADV permit 20 は何も指定していないが、これを入れないと
暗黙の deny ですべてのルートは拒否されてしまいます。

最後に router bgp にて R4 へのアドバタイズにフィルタリングするように
しています。

as-path access-list の正規表現はこちら
などをご参考ください。

上記設定をして、clear ip bgp * をします。で、R3 にて R4 へのアドバタイズルートを見てみます。



R3#sh ip bgp neighbor 34.34.34.4 advertised-routes

Total number of prefixes 0



ルートが消えちゃいました。しっかりフィルタリングされているということですね。
また R4 でルートを見てみますと、しっかり 11.11.11.0/24 へのルートが消えている
ことがわかります。



R4#sh ip bgp
BGP table version is 64, local router ID is 34.34.34.4
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
*> 44.44.44.0/24    0.0.0.0                  0         32768 i





更新日:2013年4月28日
TOPに戻る