RIP フィルタリング(offset-list)




条件
・R2にてR3 の Lo インターフェースの第2オクテットが偶数のアドレスだけフィルタしてください。


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

R1
interface Serial1/0
ip add 12.12.12.1 255.255.255.0

router rip
net 12.12.12.0 0.0.0.255
no auto-summary

R2
interface Serial1/0
ip add 12.12.12.2 255.255.255.0

interface s1/1
ip add 23.23.23.2 255.255.255.0

router rip
net 12.12.12.0 0.0.0.255
net 23.23.23.0 0.0.0.255
no auto-summary

R3
interface s1/1
ip add 23.23.23.3 255.255.255.0

interface lo0
ip add 3.1.1.1 255.255.255.0

interface lo1
ip add 3.2.1.1 255.255.255.0

interface lo2
ip add 3.3.1.1 255.255.255.0

interface lo3
ip add 3.4.1.1 255.255.255.0

router rip
net 23.23.23.0 0.0.0.255
net 3.0.0.0 0.0.0.255
no auto-summary


上記設定して、R1 にて sh ip route を取得してみます。


R1#sh ip route
Gateway of last resort is not set

     3.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
R       3.2.1.0/24 [120/2] via 12.12.12.2, 00:00:05, Serial1/0
R       3.3.1.0/24 [120/2] via 12.12.12.2, 00:00:05, Serial1/0
R       3.1.1.0/24 [120/2] via 12.12.12.2, 00:00:05, Serial1/0
R       3.0.0.0/8 [120/2] via 12.12.12.2, 00:00:05, Serial1/0
R       3.4.1.0/24 [120/2] via 12.12.12.2, 00:00:05, Serial1/0
     23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
R       23.23.23.0/24 [120/1] via 12.12.12.2, 00:00:05, Serial1/0
R       23.0.0.0/8 [120/1] via 12.12.12.2, 00:01:52, Serial1/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, Serial1/0

すべての R3 Loインターフェースがアドバタイズされていることがわかります。
第2オクテットが偶数のネットワークがピンクになってます。


ここで、R2にて offset-list 設定をします。

R2
access-list 1 permit 0.0.0.0 255.254.255.255

router rip
offset-list 1 in 16 s1/1

s1/1 から経路を受信する際メトリックに 16 をプラスする処理となる。


R1#sh ip route
Gateway of last resort is not set

     3.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
R       3.3.1.0/24 [120/2] via 12.12.12.2, 00:00:03, Serial1/0
R       3.1.1.0/24 [120/2] via 12.12.12.2, 00:00:03, Serial1/0
R       3.0.0.0/8 [120/2] via 12.12.12.2, 00:00:03, Serial1/0
     23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
R       23.23.23.0/24 [120/1] via 12.12.12.2, 00:00:03, Serial1/0
R       23.0.0.0/8 [120/1] via 12.12.12.2, 00:02:47, Serial1/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, Serial1/0

R1 にて sh ip route を見るとピンクの経路が消えていますね。


debug ip rip を取得すると下記のような結果が得られます。

*Sep  4 23:38:05.407:      3.1.1.0/24 via 0.0.0.0 in 1 hops
*Sep  4 23:38:05.411:      3.2.1.0/24 via 0.0.0.0 in 17 hops  (inaccessible)
*Sep  4 23:38:05.415:      3.3.1.0/24 via 0.0.0.0 in 1 hops
*Sep  4 23:38:05.419:      3.4.1.0/24 via 0.0.0.0 in 17 hops  (inaccessible)

3.2.1.0 と 3.4.1.0 の経路が inaccessible となっており無効であることがわかります。


では、条件で禁止されている distirbute-list と distance で同じことをやってみたいと思います。

まずは、distribute-list から。

R2
access-list 2 deny 0.0.0.0 255.254.255.255
access-list 2 permit any

router rip
distribute-list 2 out s1/0
もしくは
distribute-list 2 in s1/1



次に distance コマンド。

R2
access-list 1 permit 0.0.0.0 255.254.255.255

router rip
distance 255 0.0.0.0 255.255.255.255 1


更新日:2012年9月4日
TOPに戻る