default-information originate always の route-map で条件付き広報




条件
・OSPFエリアの各ルータにて最長一致の経路がない場合はR2にパケットを送るようにしてください。
・パケットを無駄にdropさせないためにR2はR3のLo0、R4noLo0に到達性が確認できない場合は、 デフォルトルートをOSPFエリアに広報しないようにしてください。


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

R1
interface Serial1/0
ip address 1.1.1.1 255.255.255.0
!
router ospf 1
 network 1.1.1.1 0.0.0.0 area 0

R2
interface Serial1/0
ip address 1.1.1.2 255.255.255.0
!
interface F0/0
ip address 2.2.2.2 255.255.255.0
!
router rip
version 2
net 2.2.2.0
redistribute ospf 1 metric 1
!
router ospf 1
 network 1.1.1.2 0.0.0.0 area 0
 default-information originate always

R3
interface fa0/0
ip address 2.2.2.3 255.255.255.0
!
Interface lo0
ip address 30.30.30.30 255.255.255.255
!
router rip
version 2
net 2.2.2.0
redistribute connected metric 1

R4
interface fa0/0
ip address 2.2.2.4 255.255.255.0
!
Interface lo0
ip address 40.40.40.40 255.255.255.255
!
router rip
version 2
net 2.2.2.0
redistribute connected metric 1


・OSPFエリアの各ルータにて最長一致の経路がない場合はR2にパケットを送るようにしてください。
一個目の条件についてはR2へのデフォルトルートを作成せよ。ということなので、
R2から default-information originate always を指定してやればオッケーです。
always オプションを入れない場合は、ip route 0.0.0.0 0.0.0.0 fa0/0
を指定してやらないとデフォルトルートが作られないです。

参考
http://www.infraexpert.com/study/rp4ospf8.htm
上記設定ではすでに default-information が入っているので、R1にてデフォルトルートが
作成されていることがわかります。


R1#sh ip route
Gateway of last resort is 1.1.1.2 to network 0.0.0.0

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Serial1/0
O*E2 0.0.0.0/0 [110/1] via 1.1.1.2, 00:10:14, Serial1/0


・パケットを無駄にdropさせないためにR2はR3のLo0、R4noLo0に到達性が確認できない場合は、
デフォルトルートをOSPFエリアに広報しないようにしてください。
次に2つめの条件ですが、default-information originate に route-mapオプションを加える
ころで、自身のルーティングテーブルに該当のルートがあるときだけデフォルトルートを広報
するということができます。

追加設定としては下記のとおり。

R3
router ospf 1
default-information originate always route-map CONDITION

ip prefix-list R3 permit 30.0.0.0/8
ip prefix-list R4 permit 40.0.0.0/8

route-map CONDITION permit 10
match ip address prefix-list R3

route-map CONDITION permit 20
match ip address prefix-list R4


この設定をいれたあと、R3のLo0、R4のLo0を shutdownしたらどうなるか
確認します。



R1#sh ip route
Gateway of last resort is 1.1.1.2 to network 0.0.0.0

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Serial1/0
O*E2 0.0.0.0/0 [110/1] via 1.1.1.2, 00:10:14, Serial1/0

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

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Serial1/0
     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, FastEthernet0/0
R    40.0.0.0/8 [120/1] via 2.2.2.4, 00:00:02, FastEthernet0/0
R    30.0.0.0/8 [120/1] via 2.2.2.3, 00:00:00, FastEthernet0/0

R3(config)#interface Lo0
R3(config-if)#shut

R4(config)#interface Lo0
R4(config-if)#shut

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

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Serial1/0
     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, FastEthernet0/0

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

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Serial1/0




ちなみに上記設定だとR3かR4どちらかのルートが生きていれば、
デフォルトルートは広報されるようです。どちらのルートも生きていないと
広報されないようにするには、、、

あーーちょっとわからないです。。class-map の match-all みたいなのないのかよ。。

route-map CONDITION permit 10
match ip address prefix-list R3
match ip address prefix-list R4

↑こんな感じにすればいくかなと思ったけど、

route-map CONDITION permit 10
match ip address prefix-list R3 R4

↑sh run 見るとこんな感じで合体しちゃって同じ動きになっちゃうっす。

誰か教えて。。

更新日:2012年8月11日