カテゴリ:

今回はOSPFの認証を確認していきます。まず下記のようにR2とR3のインターフェイスが設定してあります。

R2(config-router)#do sh ip int b
Interface                  IP-Address      OK? Method Status                Protocol
Serial1/2                  23.23.23.2      YES manual up                    up
Loopback0                  17.17.2.2       YES NVRAM  up                    up   

R3(config-router)#do sh ip int b
Interface                  IP-Address      OK? Method Status                Protocol
Serial1/3                  23.23.23.3      YES manual up                    up 
Loopback0                  17.17.3.3       YES NVRAM  up                    up

OSPFでそれぞれのシリアルとループバックアドレスアドレスを有効にしました。

R2(config-router)#do sh run | s ospf
router ospf 1
router-id 17.17.2.2
log-adjacency-changes
network 17.17.2.2 0.0.0.0 area 0
network 23.23.23.2 0.0.0.0 area 0

R3(config-router)#do sh run | s ospf
router ospf 1
router-id 17.17.3.3
log-adjacency-changes
network 17.17.3.3 0.0.0.0 area 0
network 23.23.23.3 0.0.0.0 area 0

ここから認証を設定していきます。まずR3でデバグを有効にして、状態を確認できるようにします。

R3#debug ip ospf adj
OSPF adjacency events debugging is on

R2で平文(Simple password authentication)の認証を有効にします。

R2(config-router)#int s1/2
R2(config-if)#ip ospf authentication

R3にはR2が利用しているのがtype 1であると、表示されることが分かります。

R3#
Mar 21 06:18:16.387: OSPF: Rcv pkt from 23.23.23.2, Serial1/3 : Mismatch Authentication type. Input packet specified type 1, we use type 0

次にR2でパスワードを指定します。ここでは"CISCO"としました。

R2(config-if)#ip ospf authentication-key CISCO

R3でも平文での認証を有効にします。

R3(config-router)#int s1/3
R3(config-if)#ip ospf authentication

デバグの内容が変化することが分かります。

R3(config-if)#
Mar 21 06:20:00.531: OSPF: Rcv pkt from 23.23.23.2, Serial1/3 : Mismatch Authentication Key - Clear Text

R3でパスワードを指定すると認証が有効となり、隣接関係が形成されます。

R3(config-if)#ip ospf authentication-key CISCO

Mar 21 06:20:38.019: OSPF: Synchronized with 17.17.2.2 on Serial1/3, state FULL

R3(config-if)#do sh ip os int s1/3
Serial1/3 is up, line protocol is up
  Internet Address 23.23.23.3/24, Area 0
〜略〜
  Simple password authentication enabled

R2で認証方法をMD5(Cryptographic authentication)に変更してみます。

R2(config-if)#ip ospf authentication message-digest

R3にはR2が利用しているのがtype 2であると、表示されることが分かります。

R3#
Mar 21 06:23:39.491: OSPF: Rcv pkt from 23.23.23.2, Serial1/3 : Mismatch Authentication type. Input packet specified type 2, we use type 1

R3でも認証方法をMD5に変更します。

R3(config-if)#ip ospf authentication message-digest

Mar 21 06:25:56.643: OSPF: Send with youngest Key 0
Mar 21 06:26:02.211: OSPF: Rcv pkt from 23.23.23.2, Serial1/3 : Mismatch Authentication Key - No message digest key 1 on interface

するとこの時点で隣接関係が形成されたことが確認できます。

R3(config-if)#do sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
17.17.2.2         0   FULL/  -        00:00:39    23.23.23.2      Serial1/3

このキーを設定していない状態では、下記のように表示されます。もちろん、設定としてこれは不完全です。

R3(config-if)#do sh ip os int s1/3
Serial1/3 is up, line protocol is up
  Internet Address 23.23.23.3/24, Area 0
〜略〜
  Message digest authentication enabled
      No key configured, using default key id 0

次にキーを設定します。ここでは"CCNA"を利用します。

R2(config-if)#ip ospf message-digest-key 1 md5 CCNA

R3でのデバグです。もちろんこの時点では隣接関係は壊れています。

Mar 21 07:10:50.175: OSPF: Send with youngest Key 0
Mar 21 07:10:53.375: OSPF: Rcv pkt from 23.23.23.2, Serial1/3 : Mismatch Authentication Key - No message digest key 1 on interface

R3にもキーを設定します。

R3(config-if)#ip ospf message-digest-key 1 md5 CCNA

これにより隣接関係が再形成されます。

R3(config-if)#do sh ip os int s1/3
Serial1/3 is up, line protocol is up
  Internet Address 23.23.23.3/24, Area 0
〜略〜
  Message digest authentication enabled
    Youngest key id is 1

今回はインターフェイスでの認証方法を指定しましたが、エリア全体で指定も可能です。まず先程の認証の指定を無効にします。

R2(config-if)#no ip ospf authentication message-digest
R2(config-if)#no ip ospf authentication-key CISCO

R3(config-if)#no ip ospf authentication message-digest
R3(config-if)#no ip ospf authentication-key CISCO

OSPFのプロセスで認証を有効にします。

R2(config-if)#router ospf 1
R2(config-router)#area 0 authentication message-digest

R3(config-if)#router ospf 1
R3(config-router)#area 0 authentication message-digest

確認すると同じように、MD5での認証が有効であることが分かります。

R3(config-router)#do sh ip os int s1/3
Serial1/3 is up, line protocol is up
  Internet Address 23.23.23.3/24, Area 0
〜略〜
  Message digest authentication enabled
    Youngest key id is 1