OSPF コスト計算




検証内容
・コストの加算
・metric-type の違い
・default-information originateについて


下記の状態からスタート。

R1
interface Loopback0
 ip address 10.1.1.1 255.255.255.255
!
interface Serial1/0
 ip address 1.1.1.1 255.255.255.0
 ip ospf cost 100
!
router ospf 1
 network 1.1.1.0 0.0.0.255 area 0
 network 10.1.1.1 0.0.0.0 area 0

R2
interface Loopback0
 ip address 20.2.2.2 255.255.255.255
!
interface Serial1/0
 ip address 1.1.1.2 255.255.255.0
!
interface Serial1/1
 ip address 2.2.2.2 255.255.255.0
 ip ospf cost 100
!
router ospf 1
 network 1.1.1.0 0.0.0.255 area 0
 network 2.2.2.0 0.0.0.255 area 1
 network 20.2.2.2 0.0.0.0 area 0
 area 1 nssa

R3
interface Loopback0
 ip address 30.3.3.3 255.255.255.255
!
interface Loopback1
 ip address 30.3.3.131 255.255.255.255
!
interface Loopback2
 ip address 30.3.3.195 255.255.255.255
!
interface Serial1/0
 ip address 2.2.2.3 255.255.255.0
!
router ospf 1
 network 2.2.2.0 0.0.0.255 area 1
 redistribute connected subnets metric 300 metric-type 2
 ara 1 nssa

R1#show 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
O IA    2.2.2.0 [110/200] via 1.1.1.2, 00:04:30, Serial1/0
     20.0.0.0/32 is subnetted, 1 subnets
O       20.2.2.2 [110/101] via 1.1.1.2, 00:04:30, Serial1/0
     10.0.0.0/32 is subnetted, 3 subnets
C       10.1.1.11 is directly connected, Loopback1
C       10.1.1.1 is directly connected, Loopback0
C       10.1.1.111 is directly connected, Loopback2
     30.0.0.0/32 is subnetted, 3 subnets
O E2    30.3.3.3 [110/300] via 1.1.1.2, 00:00:01, Serial1/0
O E2    30.3.3.131 [110/300] via 1.1.1.2, 00:00:01, Serial1/0
O E2    30.3.3.195 [110/300] via 1.1.1.2, 00:00:02, Serial1/0
R1#
metric-type 2を明示的に指定したが、これがデフォルトです。
タイプ2の場合途中のコストは加算されないのでR1 で見るとmetricは300になってます。


ここでR3にてmetric-typeを2に変更。

R3
router ospf 1
redistribute connected subnets metric 300 metric-type 2

R1#show 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
O IA    2.2.2.0 [110/200] via 1.1.1.2, 00:04:30, Serial1/0
     20.0.0.0/32 is subnetted, 1 subnets
O       20.2.2.2 [110/101] via 1.1.1.2, 00:04:30, Serial1/0
     10.0.0.0/32 is subnetted, 3 subnets
C       10.1.1.11 is directly connected, Loopback1
C       10.1.1.1 is directly connected, Loopback0
C       10.1.1.111 is directly connected, Loopback2
     30.0.0.0/32 is subnetted, 3 subnets
O E1    30.3.3.3 [110/500] via 1.1.1.2, 00:00:01, Serial1/0
O E1    30.3.3.131 [110/500] via 1.1.1.2, 00:00:01, Serial1/0
O E1    30.3.3.195 [110/500] via 1.1.1.2, 00:00:02, Serial1/0

こうすると、途中経路のコスト(in側のインターフェース)を加算するので、
300+100+100 で 500 になりました。。

●default-information originateについて
先ほどのトポロジで R3 に R2 へのデフォルトルートを学ばせたい場合は、R2 にて
下記コマンドを設定します。

R2
router ospf 1
area 1 nssa default-information originate

R3
Gateway of last resort is 2.2.2.2 to network 0.0.0.0

     1.0.0.0/24 is subnetted, 1 subnets
O IA    1.1.1.0 [110/128] via 2.2.2.2, 00:22:15, Serial1/0
     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Serial1/0
     20.0.0.0/32 is subnetted, 1 subnets
O IA    20.2.2.2 [110/65] via 2.2.2.2, 00:24:46, Serial1/0
     10.0.0.0/24 is subnetted, 1 subnets
O IA    10.1.1.0 [110/129] via 2.2.2.2, 00:22:15, Serial1/0
     30.0.0.0/32 is subnetted, 3 subnets
C       30.3.3.3 is directly connected, Loopback0
C       30.3.3.131 is directly connected, Loopback1
C       30.3.3.195 is directly connected, Loopback2
O*N2 0.0.0.0/0 [110/1] via 2.2.2.2, 00:00:05, Serial1/0


そうすると、R3 のルーティングテーブルに R2 へのデフォルトルートがあらわれます。

R2(config-router)#area 1 nssa default-information-originate ?
metric OSPF default metric
metric-type OSPF metric type for default routes
no-redistribution No redistribution into this NSSA area
no-summary Do not send summary LSA into NSSA
translate Translate LSA

↑こんなかんじで、ほかにも設定できますよっ。


あれ、area 1 nssa no-summary との違いって何?って思ったので、no-summary も設定してみました。

R2
router ospf 1
area 1 nssa no-summary

R3
Gateway of last resort is 2.2.2.2 to network 0.0.0.0

     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Serial1/0
     30.0.0.0/32 is subnetted, 3 subnets
C       30.3.3.3 is directly connected, Loopback0
C       30.3.3.131 is directly connected, Loopback1
C       30.3.3.195 is directly connected, Loopback2
O*IA 0.0.0.0/0 [110/65] via 2.2.2.2, 00:00:10, Serial1/0
ふむ。こっちの場合はデフォルトルートのみしかもらえないようになるわけね。
default-infomation originate の場合は OSPFのルートももらえて、加えて
デフォルトルートもまなべると。

んー実際にやってみるとわかりやすいわぁー


更新:2012/07/19(今日はあつい)
PS:最近は大津のいじめ問題で大賑わいですな。