OSPF 優先経路の選択





条件
・R1が、R2-R3のイーサネットセグメントと通信するときは、R1-R3間のリンクを通るようにしてください。
・この設定は、R1のみで設定してください。
・cost,bandwidth コマンドは使用しないでください。



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

R1
interface Serial1/0
encap frame-relay
ip add 123.123.123.1 255.255.255.0
frame-relay map ip 123.123.123.2 102 broadcast
frame-relay map ip 123.123.123.3 103 broadcast
ip ospf network point-to-multipoint
no shut

router ospf 1
net 123.123.123.0 0.0.0.255 area 0

R2
interface Serial1/0
encap frame-relay
ip add 123.123.123.2 255.255.255.0
frame-relay map ip 123.123.123.1 201 broadcast
frame-relay map ip 123.123.123.3 203 broadcast
ip ospf network point-to-multipoint
no shut

interface F0/0
ip add 23.23.23.2 255.255.255.0
no shut

router ospf 1
net 123.123.123.0 0.0.0.255 area 0
net 23.23.23.0 0.0.0.255 area 0

R3
interface Serial1/0
encap frame-relay
ip add 123.123.123.3 255.255.255.0
frame-relay map ip 123.123.123.1 301 broadcast
frame-relay map ip 123.123.123.2 302 broadcast
ip ospf network point-to-multipoint
no shut

interface F0/0
ip add 23.23.23.3 255.255.255.0
no shut

router ospf 1
net 123.123.123.0 0.0.0.255 area 0
net 23.23.23.0 0.0.0.255 area 0




上記状態で、R1 にて sh ip route をみてみます。


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

     20.0.0.0/32 is subnetted, 1 subnets
C       20.20.20.20 is directly connected, Loopback0
     23.0.0.0/24 is subnetted, 1 subnets
O       23.23.23.0 [110/65] via 123.123.123.3, 00:00:05, Serial1/0
                   [110/65] via 123.123.123.2, 00:00:05, Serial1/0
     123.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
O       123.123.123.3/32 [110/64] via 123.123.123.3, 00:00:05, Serial1/0
O       123.123.123.2/32 [110/64] via 123.123.123.2, 00:00:05, Serial1/0
C       123.123.123.0/24 is directly connected, Serial1/0


23.23.23.0 への経路は、R2,R3 へのロードバランスになっていることがわかりますね。
これをR3 経由のみにするというのか今回の課題です。cost,bandwidth を使っちゃダメで、
R1のみにて設定するということですね。

答えとしては、distribute-list を使うものとなります。

R1
access-list 1 permit 23.23.23.0 0.0.0.255
access-list 2 permit 123.123.123.2 0.0.0.0

route-map DIST deny 10
match ip add 1
match ip next-hop 2

route-map DIST permit 20

router ospf 1
distribute-list route-map DIST in

match ip add 1 であて先セグメントを指定、match ip next-hop 2 でネクストホップとなる
アドレスを指定しています。この定義を R1 のin向け distribute でフィルタしてますね。

deny なので、23.23.23.0 向けの経路で、next-hop が 123.123.123.2 となるものは deny とする。

なので、R3 からの 23.23.23.0 向け経路だけ学ぶことになり、23.23.23.0へ行くには、R3 経由となります。


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

     20.0.0.0/32 is subnetted, 1 subnets
C       20.20.20.20 is directly connected, Loopback0
     23.0.0.0/24 is subnetted, 1 subnets
O       23.23.23.0 [110/65] via 123.123.123.3, 00:00:01, Serial1/0
     123.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
O       123.123.123.3/32 [110/64] via 123.123.123.3, 00:00:01, Serial1/0
O       123.123.123.2/32 [110/64] via 123.123.123.2, 00:00:01, Serial1/0
C       123.123.123.0/24 is directly connected, Serial1/0



条件にて禁止されていた、cost,bandwidth を使った方法ですが s1/0 でどちらの経路も
同じインターフェースなので ip ospf cost, bandwidth では優先経路は指定できないと、、、
思われます。 distance コマンドも無理っぽいですね。発信もとで何か振り分けるコマンド
ありますかね?

2012年8月31日追記
と思ったらありました。

出力ポートが一緒でも neighbor コマンドを指定する際に cost を設定できます。

R1
int s1/0
ip ospf network point-to-multipoint non-broadcast

router ospf 1
neighbor 123.123.123.2 cost 200
neighbor 123.123.123.3 cost 100

R2
int s1/0
ip ospf network point-to-multipoint non-broadcast

R3
int s1/0
ip ospf network point-to-multipoint non-broadcast



neighbor を設定するため、point-to-multipoint non-broadcast を設定しています。

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

     23.0.0.0/24 is subnetted, 1 subnets
O       23.23.23.0 [110/101] via 123.123.123.3, 00:06:28, Serial1/0
     123.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
O       123.123.123.3/32 [110/101] via 123.123.123.2, 00:06:28, Serial1/0
O       123.123.123.2/32 [110/100] via 123.123.123.2, 00:06:28, Serial1/0
C       123.123.123.0/24 is directly connected, Serial1/0


上記 sh ip route を見るとロードバランスされず cost 100 が設定された R3 を優先経路として
選択されていることがわかります。
また、R3 の s1/0 を shut することにより R2 の経路が cost 200 で浮かび上がってくることがわかります。


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

     23.0.0.0/24 is subnetted, 1 subnets
O       23.23.23.0 [110/201] via 123.123.123.2, 00:00:00, Serial1/0
     123.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O       123.123.123.3/32 [110/200] via 123.123.123.3, 00:00:00, Serial1/0
C       123.123.123.0/24 is directly connected, Serial1/0

更新日:2012年8月31日
TOPに戻る