【OSPF】プレーンテキストでの認証設定

 

OSPF では、不正なルータとネイバーにならないよう、認証を設定できます。認証の方式には、平文(プレーンテキスト)のパスワードを使う認証(タイプ1)と、MD5 を使う認証(タイプ2)があります。この記事では、平文での認証の有効化とキーの設定、設定が合わないときの動きを確かめます。

この記事でわかること
  1. 平文認証の有効化(インターフェース単位とエリア単位)
  2. ip ospf authentication-key でのキーの設定
  3. 認証の種類やキーが合わないときの debug の表示と、キャプチャでのキーの見え方

検証構成

R2 と R3 を 192.168.23.0/24 でつなぎ、エリア0で OSPF のネイバーにします。このネイバーに平文の認証を設定し、キーには CISCO を使います。

Area 0 R2R3 Lo0 2.2.2.2/32Lo0 3.3.3.3/32 .2.3 192.168.23.0/24
図1 検証構成

OSPF の基本設定

R2(config)# router ospf 1
R2(config-router)# network 192.168.23.0 0.0.0.255 area 0
R2(config-router)# network 2.2.2.2 0.0.0.0 area 0

R3(config)# router ospf 1
R3(config-router)# network 192.168.23.0 0.0.0.255 area 0
R3(config-router)# network 3.3.3.3 0.0.0.0 area 0

認証の有効化

認証は、インターフェース単位で有効にする方法と、エリア全体で有効にする方法の2つがあります。両方を設定した場合は、インターフェースの設定が優先されます。

インターフェース単位で有効にする

R2 のインターフェースで認証を有効にします。ip ospf authentication をキーワードなしで設定すると、平文の認証になります。

R2

R2(config)# int fastEthernet 0/0.23
R2(config-subif)# ip ospf authentication

show ip ospf interface を見ると、平文の認証(Simple password authentication)が有効になっています。

R2# show ip ospf interface
Loopback0 is up, line protocol is up
  Internet Address 2.2.2.2/32, Area 0, Attached via Network Statement
  Process ID 1, Router ID 2.2.2.2, Network Type LOOPBACK, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           1         no          no            Base
  Loopback interface is treated as a stub Host
FastEthernet0/0.23 is up, line protocol is up
  Internet Address 192.168.23.2/24, Area 0, Attached via Network Statement
  Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           1         no          no            Base
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 2.2.2.2, Interface address 192.168.23.2
  No backup designated router on this network
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:03
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  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 0, Adjacent neighbor count is 0
  Suppress hello for 0 neighbor(s)
  Simple password authentication enabled

R2 の Hello をキャプチャすると、Auth Type が Simple password(1)になっています。まだキーを設定していないので、Auth Data は空です。

画面イメージについて

この記事の画面は、実際の画面ではなく、検証時の画面から見るポイントを抜き出して描いたイメージです。バージョンによって、項目の並びや表記は変わります。

パケットキャプチャ(Wireshark):キー設定前の R2 の Hello画面イメージ
▸ Internet Protocol Version 4, Src: 192.168.23.2, Dst: 224.0.0.5▾ Open Shortest Path First  ▾ OSPF Header      Version: 2      Message Type: Hello Packet (1)      Packet Length: 48      Source OSPF Router: 2.2.2.2      Area ID: 0.0.0.0 (Backbone)      Checksum: 0x3339 [correct]1      Auth Type: Simple password (1)2      Auth Data (Simple):   ▸ OSPF Hello Packet
図2 平文認証を有効にした Hello(実際の画面ではなく、表示内容のポイントを示したイメージです)
No.表示意味
1Auth Type: Simple password (1)認証の種類がタイプ1(平文)。タイプ0は認証なし、タイプ2は MD5
2Auth Data (Simple):パスワードを入れる欄(8バイト)。キーを設定していないので空

R3 はまだ認証を設定していないので、しばらくすると Dead タイマーが切れてネイバーがダウンします。

*Jun 18 11:54:04.611: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0.23 from 
FULL to DOWN, Neighbor Down: Dead timer expired

R2 で debug ip ospf adj を有効にすると、認証の種類が合っていないことがわかります。受け取ったパケットはタイプ0(認証なし)で、R2 はタイプ1(平文)を使っています。

R2# debug ip ospf adj
OSPF adjacency debugging is on

*Jun 18 11:57:04.983: OSPF-1 ADJ   Fa0/0.23: Rcv pkt from 192.168.23.3 : 
Mismatched Authentication type. Input packet specified type 0, we use type 1

R3 でも認証を有効にすると、ネイバーが FULL に戻ります。

R3

R3(config)# interface fastEthernet 0/0.23
R3(config-subif)# ip ospf authentication
*Jun 18 12:00:43.207: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0.23 
from LOADING to FULL, Loading Done

エリア単位で有効にする

OSPF のインターフェースが多いときは、エリア単位でまとめて認証を有効にできます。R2 のエリア0で認証を有効にします。

R2

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

エリア0のインターフェースで、平文の認証が有効になっています。

R2# show ip ospf interface 
Loopback0 is up, line protocol is up 
  Internet Address 2.2.2.2/32, Area 0, Attached via Network Statement
  Process ID 1, Router ID 2.2.2.2, Network Type LOOPBACK, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           1         no          no            Base
  Loopback interface is treated as a stub Host
FastEthernet0/0.23 is up, line protocol is up 
  Internet Address 192.168.23.2/24, Area 0, Attached via Network Statement
  Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 1
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           1         no          no            Base
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 2.2.2.2, Interface address 192.168.23.2
  No backup designated router on this network
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:08
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  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 0, Adjacent neighbor count is 0 
  Suppress hello for 0 neighbor(s)
  Simple password authentication enabled

しばらくすると、ネイバーがダウンします。

R2#
*Jun 18 12:27:38.015: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0.23 
from FULL to DOWN, Neighbor Down: Dead timer expired

R3 でもエリア0で認証を有効にすると、ネイバーが FULL に戻ります。

R3

R3(config)# router ospf 1
R3(config-router)# area 0 authentication
*Jun 18 12:29:49.867: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0.23 
from LOADING to FULL, Loading Done

認証キーの設定

R2 にキーを設定する

R2 で debug ip ospf adj を有効にし、インターフェースに認証キー CISCO を設定します。平文認証のキーは、最大8文字です。

R2

R2#debug ip ospf adj
OSPF adjacency debugging is on

R2(config)# int fastEthernet 0/0.23
R2(config-subif)# ip ospf authentication-key CISCO

R3 はまだキーを設定していないので、R2 にはキーが合わないというログが出ます。

*Jun 18 12:12:36.423: OSPF-1 ADJ   Fa0/0.23: Rcv pkt from 192.168.23.3,  : 
Mismatched Authentication Key - Clear Text

R3 にも同じキーを設定する

R3

R3(config)# int fastEthernet 0/0.23
R3(config-subif)# ip ospf authentication-key CISCO

キーがそろい、ネイバーが FULL に戻ります。

*Jun 18 12:14:57.315: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0.23 
from LOADING to FULL, Loading Done

Hello をキャプチャすると、Auth Data に CISCO がそのまま入っています。平文の認証なので、キャプチャすればキーを読み取れます。

パケットキャプチャ(Wireshark):キー設定後の Hello画面イメージ
▸ Internet Protocol Version 4, Src: 192.168.23.3, Dst: 224.0.0.5▾ Open Shortest Path First  ▾ OSPF Header      Version: 2      Message Type: Hello Packet (1)      Packet Length: 48      Source OSPF Router: 3.3.3.3      Area ID: 0.0.0.0 (Backbone)      Checksum: 0x3339 [correct]      Auth Type: Simple password (1)1      Auth Data (Simple): CISCO  ▸ OSPF Hello Packet
図3 キーがそのまま載った Hello(実際の画面ではなく、表示内容のポイントを示したイメージです)
No.表示意味
1Auth Data (Simple): CISCO設定したキーの文字列が、暗号化されずにそのまま入っている
R2R3 認証の種類Type 1(平文)キーCISCO 認証の種類Type 1(平文)キーCISCO 一致が必要 一致が必要 キーは Hello にそのまま載る(キャプチャで読める)
図4 平文認証で一致が必要なもの

まとめ

debug のメッセージ原因
Mismatched Authentication type認証の種類(なし/平文/MD5)が合っていない
Mismatched Authentication Key - Clear Text平文認証のキーの文字列が合っていない

平文認証では、認証の種類とキーの文字列を、ネイバーの両側でそろえます。

補足:平文認証の弱点

平文認証では、キーがパケットにそのまま載るので、同じセグメントでキャプチャできればキーがわかります。設定の誤りでネイバーができるのを防ぐ程度の効果と考え、キーを守りたいときは MD5 認証 や、より強い SHA 系の認証(RFC 5709)を使います。使える方式は、機種と OS のバージョンで確認してください。

コメント