OSPF 基本の基本




検証内容
・R1,R2でospf area 0 を作成し、show コマンドにて出力を確認する。
・reference-bandwidth を変更した場合の変化。



まずは基本設定でどのようなパラメータとなるか確認します。

R1
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface Serial1/0
 ip address 192.168.0.1 255.255.255.252
!
router ospf 1
 network 1.1.1.1 0.0.0.0 area 0
 network 192.168.0.0 0.0.0.3 area 0

R2
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface Serial1/0
 ip address 192.168.0.2 255.255.255.252
!
router ospf 1
 network 2.2.2.2 0.0.0.0 area 0
 network 192.168.0.0 0.0.0.3 area 0

設定時のデバッグ(debug ip ospf event) をとりあえず。

R2(config)#
R2(config)#router ospf 1
R2(config-router)#
R2(config-router)#net 192.168.0.0 0.0.0.3 area 0
R2(config-router)#
*Jul  1 10:45:02.287: OSPF: Interface Serial1/0 going Up
*Jul  1 10:45:02.291: OSPF: Send hello to 224.0.0.5 area 0 on Serial1/0 from 192.168.0.2
*Jul  1 10:45:02.495: OSPF: Rcv hello from 1.1.1.1 area 0 from Serial1/0 192.168.0.1
*Jul  1 10:45:02.499: OSPF: 2 Way Communication to 1.1.1.1 on Serial1/0, state 2WAY
*Jul  1 10:45:02.503: OSPF: Send DBD to 1.1.1.1 on Serial1/0 seq 0x1006 opt 0x52 flag 0x7 len 32
*Jul  1 10:45:02.507: OSPF: Send immediate hello to nbr 1.1.1.1, src address 192.168.0.1, on Serial1/0
*Jul  1 10:45:02.507: OSPF: Send hello to 224.0.0.5 area 0 on Serial1/0 from 192.168.0.2
*Jul  1 10:45:02.511: OSPF: End of hello processing
*Jul  1 10:45:02.559: OSPF: Rcv DBD from 1.1.1.1 on Serial1/0 seq 0x17B9 opt 0x52 flag 0x7 len 32  mtu 1500 state EXSTART
*Jul  1 10:45:02.563: OSPF: First DBD and we are not SLAVE
*Jul  1 10:45:02.667: OSPF: Rcv DBD from 1.1.1.1 on Serial1/0 seq 0x1006 opt 0x52 flag 0x2 len 52  mtu 1500 state EXSTART
*Jul  1 10:45:02.671: OSPF:net  NBR Negotiation Done. We are the MASTER
*Jul  1 10:45:02.675: OSPF: Send DBD to 1.1.1.1 on Serial1/0 seq 0x1007 opt 0x52 flag 0x1 len 32
*Jul  1 10:45:02.683: OSPF: Rcv DBD from 1.1.1.1 on Serial1/0 seq 0x1007 opt 0x52 flag 0x0 len 32  mtu 1500 state EXCHANGE
*Jul  1 10:45:02.687: OSPF: Exchange Done with 1.1.1.1 on Serial1/0
*Jul  1 10:45:02.691: OSPF: Send LS REQ to 1.1.1.1 length 12 LSA count 1
*Jul  1 10:45:02.803: OSPF: Rcv LS UPD from 1.1.1.1 on Serial1/0 length 88 LSA count 1
*Jul  1 10:45:02.807: OSPF: Synchronized with 1.1.1.1 on Serial1/0, state FULL
*Jul  1 10:45:02.807: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on Serial1/0 from LOADING to FULL, Loading Done
*Jul  1 10:45:03.899: OSPF: Rcv hello from 1.1.1.1 area 0 from Serial1/0 192.168.0.1
*Jul  1 10:45:03.903: OSPF: End of hello processing
*Jul  1 10:45:10.811: OSPF: Interface Loopback0 going Up
*Jul  1 10:45:12.295: OSPF: Send hello to 224.0.0.5 area 0 on Serial1/0 from 192.168.0.2
*Jul  1 10:45:13.903: OSPF: Rcv hello from 1.1.1.1 area 0 from Serial1/0 192.168.0.1
*Jul  1 10:45:13.907: OSPF: End of hello processing
*Jul  1 10:45:22.299: OSPF: Send hello to 224.0.0.5 area 0 on Serial1/0 from 192.168.0.2
*Jul  1 10:45:23.787: OSPF: Rcv hello from 1.1.1.1 area 0 from Serial1/0 192.168.0.1
*Jul  1 10:45:23.791: OSPF: End of hello processing

Hello が 224.0.0.5 のマルチキャストアドレスに送られていることがわかりますね。
2WAY - EXSTART - EXCHANGE - FULL の順で変移していることがわかる。
また DBD 送信は R2 が MASTERになっていることがわかりますね。

ip route確認
それぞれお互いの lo0 をOSPFで学んでいることがわかる。
AD値はお決まりの110、なぜ metric が 65 になっているかというと、、、
OSPF のコスト値計算 reference bandwidth はデフォルト 100M となり、コストの計算は
100M / インターフェースの帯域

今回はシリアルインターフェースなので、デフォルト 1.544M。(show int で確認してちょ)
よって 100M / 1.544M = 64.76..... (切捨てで64)
で lo0 のインターフェースのmetricが 1 なので(なんでだろ)、64+1=65。



R1#sh ip route

Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 192.168.0.2, 00:08:29, Serial1/0
     192.168.0.0/30 is subnetted, 1 subnets
C       192.168.0.0 is directly connected, Serial1/0

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

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/65] via 192.168.0.1, 00:08:41, Serial1/0
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
     192.168.0.0/30 is subnetted, 1 subnets
C       192.168.0.0 is directly connected, Serial1/0
R2#

●auto-cost reference-bandwidth 1000 を設定するとどうなるか。
metric が 648 にかわった。(1000 / 1.544 = 648.....)

このコマンドのメリットとして例えばreference-bandwidth が 100 の場合、
1G インターフェースと 100M インターフェースのコスト値が一緒になってしまう。
100 / 100 = 1
100 / 1000(1G) = 1 (小数点なし)

そうすると、下記のようなネットワークで最適な経路が選ばれなかったりする。。
上通ったほうがはやいはずですよね。。



R1(config-router)#auto-cost reference-bandwidth 1000

show ip route
O       2.2.2.2 [110/648] via 192.168.0.2, 00:02:16, Serial1/0

R2(config-router)#auto-cost reference-bandwidth 1000

show ip route
O       1.1.1.1 [110/648] via 192.168.0.1, 00:00:01, Serial1/0
なので、下記のように refernce-bandwidth を変更し 100M と 1G の価値を区別してやる。
1000 / 100 = 10
1000 / 1000(1G) = 1 (小数点なし)

またコスト値を制御する方法としては、reference-bandwidth を設定する方法と直接インターフェースの
bandwidth を変える方法がある。reference-bandwidth 100 の状態で、インターフェースの帯域を
100M に変更してみると、、、

R1(config)#int s1/0
R1(config-if)#bandwidth 100000

O       2.2.2.2 [110/2] via 192.168.0.2, 00:00:03, Serial1/0

R2(config)#int s1/0
R2(config-if)#bandwidth 100000

sh ip route
O       1.1.1.1 [110/2] via 192.168.0.1, 00:02:04, Serial1/0
100 / 100 = 1 で 1(s1/0)+1(lo0) =2 となる。


show ip protocols の確認。
ここで Reference bandwidth の値が確認できますね。
あと AD値と 所属しているネットワークの確認と。
filter設定した場合も適用有無がここで確認できますね。

R1#sh ip protocols
Routing Protocol is "ospf 1"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Router ID 1.1.1.1
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
    1.1.1.1 0.0.0.0 area 0
    192.168.0.0 0.0.0.3 area 0
 Reference bandwidth unit is 1000 mbps
  Routing Information Sources:
    Gateway         Distance      Last Update
    2.2.2.2              110      00:16:58
  Distance: (default is 110)
show ip ospf interface の確認。
ここで ネットワークタイプの確認、コスト値、タイマーの確認ができる。 LSA の細かいタイマーは show ip ospf で確認か。

R1#sh ip ospf interface
Loopback0 is up, line protocol is up
  Internet Address 1.1.1.1/32, Area 0
  Process ID 1, Router ID 1.1.1.1, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
Serial1/0 is up, line protocol is up
  Internet Address 192.168.0.1/30, Area 0
  Process ID 1, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 64
  Transmit Delay is 1 sec, State POINT_TO_POINT,
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:04
  Supports Link-local Signaling (LLS)
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 2.2.2.2
  Suppress hello for 0 neighbor(s)
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#exit

R1 側のネットワークタイプをnon-broadcastに変えてみるとどうなるか。

R1(config-if)#ip ospf network non-broadcast
R1(config-if)#
*Jul  1 12:01:42.335: OSPF: Rcv hello from 2.2.2.2 area 0 from Serial1/0 192.168.0.2
*Jul  1 12:01:42.339: OSPF: End of hello processing
*Jul  1 12:01:42.771: OSPF: Interface Serial1/0 going Down
*Jul  1 12:01:42.771: OSPF: Neighbor change Event on interface Serial1/0
*Jul  1 12:01:42.775: OSPF: DR/BDR election on Serial1/0
*Jul  1 12:01:42.775: OSPF: Elect BDR 2.2.2.2
*Jul  1 12:01:42.779: OSPF: Elect DR 2.2.2.2
*Jul  1 12:01:42.779:        DR: 2.2.2.2 (Id)   BDR: 2.2.2.2 (Id)
*Jul  1 12:01:42.783: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Serial1/0 from FULL to DOWN, Neighbor Down: Interface down or detached
*Jul  1 12:01:42.787: OSPF: Neighbor change Event on interface Serial1/0
*Jul  1 12:01:42.791: OSPF: DR/BDR election on Serial1/0
*Jul  1 12:01:42.791: OSPF: Elect BDR 0.0.0.0
*Jul  1 12:01:42.795: OSPF: Elect DR 0.0.0.0
*Jul  1 12:01:42.795:        DR: none    BDR: none
*Jul  1 12:01:42.799: OSPF: Remember old DR 2.2.2.2 (id)
*Jul  1 12:01:42.803: OSPF: Interface Serial1/0 going Up
*Jul  1 12:01:52.231: OSPF: Rcv hello from 2.2.2.2 area 0 from Serial1/0 192.168.0.2
*Jul  1 12:01:52.235: OSPF: Mismatched hello parameters from 192.168.0.2
*Jul  1 12:01:52.235: OSPF: Dead R 40 C 120, Hello R 10 C 30  Mask R 255.255.255
.252 C 255.255.255.252
.0.2
インターフェースがダウンし、DR選出のプロセスとなるが、相手が point-to-point でありDR選出に参加しないため
自分をDRとしている(show ip ospf interface )にて確認。
また最後から2番目のログで Hello parameter が相手とミスマッチとなっていることがわかる。

point-to-point のタイマーは、、、
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5

non-broadcast のタイマーは、、、
Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5

そのためネイバーにはなれないようだ。

ここで、R2 (point-to-point)側のタイマーを無理やり相手に合わせてやるとどうなるか。

R2(config-if)#ip ospf hello-interval 30

R1#sh ip ospf nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/BDR        00:01:54    192.168.0.2     Serial1/0

R2#sh ip ospf nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           0   FULL/  -        00:01:59    192.168.0.1     Serial1/0
どちらも一応FULL状態にはなったが、、、


R1
Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     192.168.0.0/30 is subnetted, 1 subnets
C       192.168.0.0 is directly connected, Serial1/0

R2
Gateway of last resort is not set

     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
     192.168.0.0/30 is subnetted, 1 subnets
C       192.168.0.0 is directly connected, Serial1/0
経路の交換ができていないようだ。R2 側が DR制御になっていないためうまくいっていないものと思われる。

ちなみにネイバーになるための条件はジーンさんのページをご確認ください。
http://www.n-study.com/network/2004/12/ospf_hello.html

今日はここまで、、次回は、frame-relayネットワークでDR,BDR選出をやりたいかな、、 更新日:2012/7/1