カテゴリ:

下記の様なBGPテーブルがあります。この中から192.168.2.0と192.168.3.0のルートを抜き出すためにprefix-listを利用します。

R1#show version | include IOS
Cisco IOS Software, 3700 Software (C3725-ADVENTERPRISEK9-M), Version 12.4(15)T12, RELEASE SOFTWARE (fc3)
R1#show ip bgp
BGP table version is 27, local router ID is 17.17.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
*> 192.168.0.0      12.12.12.2               0             0 200 i
*> 192.168.1.0      12.12.12.2               0             0 200 i
*> 192.168.2.0      12.12.12.2               0             0 200 i
*> 192.168.3.0      12.12.12.2               0             0 200 i

R1#show running-config | include LIST1
ip prefix-list LIST1 seq 5 permit 192.168.2.0/24
ip prefix-list LIST1 seq 10 permit 192.168.3.0/24

R1#show ip prefix-list LIST1
ip prefix-list LIST1: 2 entries
   seq 5 permit 192.168.2.0/24
   seq 10 permit 192.168.3.0/24

この設定が有効であるかどうかはshow ip bgp prefix-listを使うと簡単に確認することができます。

R1#show ip bgp ?
〜略〜
  prefix-list        Display routes matching the prefix-list
〜略〜

R1#show ip bgp prefix-list LIST1
BGP table version is 28, local router ID is 17.17.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
*> 192.168.2.0      12.12.12.2               0             0 200 i
*> 192.168.3.0      12.12.12.2               0             0 200 i

さてLIST1は2行で設定してありますが、これを1行で書けという問題がありがちです。LIST2の様に書けば問題ないはずですが、同じ方法で試してみます。

R1#show running-config | include LIST2
ip prefix-list LIST2 seq 5 permit 192.168.2.0/23 le 24

R1#show ip prefix-list LIST2
ip prefix-list LIST2: 1 entries
   seq 5 permit 192.168.2.0/23 le 24

R1#show ip bgp prefix-list LIST2
BGP table version is 28, local router ID is 17.17.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
*> 192.168.2.0      12.12.12.2               0             0 200 i
*> 192.168.3.0      12.12.12.2               0             0 200 i

問題ないようです。試しにこの2つにroute-mapを使いweightを設定してみます。sequence 100はweightを設定しないルートのために必要です。

R1#show running-config | section route-map
route-map WEIGHT permit 10
match ip address prefix-list LIST2
set weight 100
route-map WEIGHT permit 100

R1#show route-map WEIGHT
route-map WEIGHT, permit, sequence 10
  Match clauses:
    ip address prefix-lists: LIST2
  Set clauses:
    weight 100
  Policy routing matches: 0 packets, 0 bytes
route-map WEIGHT, permit, sequence 100
  Match clauses:
  Set clauses:
  Policy routing matches: 0 packets, 0 bytes

R1#show running-config | section bgp
router bgp 100
〜略〜
neighbor 12.12.12.2 route-map WEIGHT in
〜略〜

上記の設定でweightが設定されたことが分かります。このようにshow ip bgp prefix-listを使うことでprefix-listが意図した通りの設定になっているかを確認することができます。

R1#show ip bgp
BGP table version is 36, local router ID is 17.17.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
*> 192.168.0.0      12.12.12.2               0             0 200 i
*> 192.168.1.0      12.12.12.2               0             0 200 i
*> 192.168.2.0      12.12.12.2               0           100 200 i
*> 192.168.3.0      12.12.12.2               0           100 200 i
*> 192.168.4.0      12.12.12.2               0             0 200 i