OSPFネイバー認証の設定

handshaking CCIE

CiscoルータでのOSPF ネイバー認証についてまとめてみました。

OSPFネイバー認証とは

OSPFネイバー認証機能を有効とすることにより、管理外の不正なルータとネイバーとなることを防ぐことが出来ます。Ciscoルータはデフォルトではネイバー認証を行いません。

OSPFネイバー認証設定の流れ

  1. 認証機能の有効化
  2. 認証キーの設定

このうち、1.認証機能の有効化 については以下2つの設定方法があります。

  1. router ospf配下にてエリアで宣言する
  2. インタフェースで宣言する

上記の設定方法は、ネイバー認証に使用する認証キー(パスワード)の暗号化方式によって異なります。Ciscoルータで利用可能な暗号化方式は以下3つです。

  • クリアテキスト(暗号化しない)
  • MD5による暗号化
  • SHAによる暗号化

次のセクションから各暗号化方式ごとに設定例を見ていきます。

クリアテキスト

認証機能の有効化

クリアテキストによるネイバー認証では、認証機能の有効化は以下2つの方法で行うことができます。

1. エリア単位で有効化

router ospf セクションでエリア単位で有効化を行うことが出来ます。これにより、そのエリアに属するインタフェース全てでクリアテキスト認証が行われることになります。

<設定例>

R7(config)#router ospf 1
R7(config-router)#area 2 authentication

<確認方法>

R7#show ip ospf | begin Area 2
Area 2
Number of interfaces in this area is 5 (1 loopback)
Area has simple password authentication
SPF algorithm last executed 00:12:07.493 ago
SPF algorithm executed 5 times
Area ranges are
Number of LSA 28. Checksum Sum 0x0E7652
Number of opaque link LSA 0. Checksum Sum 0x000000
Number of DCbitless LSA 0
Number of indication LSA 0
Number of DoNotAge LSA 0
Flood list length 0

2.インタフェースでの有効化

インタフェース単位で有効化を行うことも可能です。この場合は認証を有効にしたいインタフェース全てに対して設定を行う必要があります。

<設定例>

R3(config)#int ethernet 0/1.37
R3(config-subif)#ip ospf authentication

<確認方法>

R3#show ip ospf interface ethernet 0/1.37
Ethernet0/1.37 is up, line protocol is up
Internet Address 155.1.37.3/24, Area 2, Attached via Network Statement
Process ID 1, Router ID 150.1.3.3, Network Type BROADCAST, Cost: 10
Topology-MTID Cost Disabled Shutdown Topology Name 0 10 no no Base
Transmit Delay is 1 sec, State BDR, Priority 1
Designated Router (ID) 150.1.7.7, Interface address 155.1.37.7
Backup Designated router (ID) 150.1.3.3, Interface address 155.1.37.3
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 oob-resync timeout 40
Hello due in 00:00:02
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/5, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 3, maximum is 3
Last flood scan time is 0 msec, maximum is 1 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 150.1.7.7 (Designated Router)
Suppress hello for 0 neighbor(s)
Simple password authentication enabled

認証キーの設定

パスワードに相当する認証キーは認証機能の有効化をどちらで行ったかによらず、インタフェース単位で行う必要があります。

<設定例>

R3(config)#interface ethernet 0/1.37
R3(config-subif)#ip ospf authentication-key CLEARKEY

MD5による暗号化

認証機能の有効化

MD5によるネイバー認証も、認証機能の有効化は以下2つの方法で行うことができます。

1. エリア単位で有効化

<設定例>

R7(config)#router ospf 1
R7(config-router)#area 2 authentication message-digest

<確認方法>

R7#show ip ospf | begin Area 2
Area 2
Number of interfaces in this area is 5 (1 loopback)
Area has message digest authentication
SPF algorithm last executed 00:39:14.091 ago
SPF algorithm executed 5 times
Area ranges are
Number of LSA 28. Checksum Sum 0x0E446B
Number of opaque link LSA 0. Checksum Sum 0x000000
Number of DCbitless LSA 0
Number of indication LSA 0
Number of DoNotAge LSA 0
Flood list length 0

2.インタフェースでの有効化

クリアテキスト同様インタフェース単位で有効化を行うことも可能です。この場合は認証を有効にしたいインタフェース全てに対して設定を行う必要がある点もクリアテキスト認証と同様です。

<設定例>

R3(config)#int ethernet 0/1.37
R3(config-subif)#ip ospf authentication message-digest

<確認方法>

R3#show ip ospf interface ethernet 0/1.37
Ethernet0/1.37 is up, line protocol is up
Internet Address 155.1.37.3/24, Area 2, Attached via Network Statement
Process ID 1, Router ID 150.1.3.3, Network Type BROADCAST, Cost: 10
Topology-MTID Cost Disabled Shutdown Topology Name
0 10 no no Base
Transmit Delay is 1 sec, State BDR, Priority 1
Designated Router (ID) 150.1.7.7, Interface address 155.1.37.7
Backup Designated router (ID) 150.1.3.3, Interface address 155.1.37.3
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:02
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/5, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 3, maximum is 3
Last flood scan time is 0 msec, maximum is 1 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 150.1.7.7 (Designated Router)
Suppress hello for 0 neighbor(s)
Cryptographic authentication enabled
No key configured, using default key id 0

上記のshow ip ospf interface出力例の最終行で”No key configured”というメッセージが出力されているのは、このあと実施する認証キーの設定がなされていないためです。

認証キーの設定

クリアテキスト認証同様、パスワードに相当する認証キーは認証機能の有効化をどちらで行ったかによらず、インタフェース単位で行う必要があります。

<設定例>

R3(config)#interface ethernet 0/1.37
R3(config-subif)#ip ospf message-digest-key 1 md5 MD5KEY

認証キーを設定したことにより、show ip ospf interfaceの出力例が変化したことを確認します。

R3#show ip ospf interface ethernet 0/1.37
Ethernet0/1.37 is up, line protocol is up
Internet Address 155.1.37.3/24, Area 2, Attached via Network Statement
Process ID 1, Router ID 150.1.3.3, Network Type BROADCAST, Cost: 10
Topology-MTID Cost Disabled Shutdown Topology Name
0 10 no no Base
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 150.1.3.3, Interface address 155.1.37.3
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:06
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/5, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 17
Last flood scan time is 0 msec, maximum is 1 msec
Neighbor Count is 0, Adjacent neighbor count is 0
Suppress hello for 0 neighbor(s)
Cryptographic authentication enabled
Youngest key id is 1

SHAによる暗号化

SHAによるネイバー認証は前述2方式と異なり、key chainにて認証方式(SHA)と認証キーを設定し、それを認証を有効にしたいインタフェースに適用する流れになります。

key chainの設定

<設定例>

R7(config)#key chain TEST
R7(config-keychain)#key 1
R7(config-keychain-key)#key-string TESTKEY ※認証キーの設定
R7(config-keychain-key)#cryptographic-algorithm hmac-sha-256 ※暗号化方式の設定

<設定例>

R7(config)#int ethernet 0/1.37
R7(config-subif)#ip ospf authentication key-chain TEST

<確認方法>

R7#show ip ospf interface ethernet 0/1.37
Ethernet0/1.37 is up, line protocol is up
Internet Address 155.1.37.7/24, Area 2, Attached via Network Statement
Process ID 1, Router ID 150.1.7.7, Network Type BROADCAST, Cost: 10
Topology-MTID Cost Disabled Shutdown Topology Name
0 10 no no Base
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 150.1.7.7, Interface address 155.1.37.7
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 3/3, 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)
Cryptographic authentication enabled
Sending SA: Key 1, Algorithm HMAC-SHA-256 – key chain TEST

SHA方式は前述二方式とはかなり設定の手順が異なりますね。ちなみに暗号化アルゴリズムは以下の方式を選択することが可能なようです(IOS 15.4(1)Tで確認)。

R7(config-keychain-key)#cryptographic-algorithm ?
hmac-sha-1 HMAC-SHA-1 authentication algorithm
hmac-sha-256 HMAC-SHA-256 authentication algorithm
hmac-sha-384 HMAC-SHA-384 authentication algorithm
hmac-sha-512 HMAC-SHA-512 authentication algorithm
md5 MD5 authentication algorithm

なんとMD5も選べるのですね。ですので、MD5認証もこのSHA認証と同じく、key chainでの設定も可能ということです。

まとめ

最後に各認証方式と認証機能有効化、認証キーの設定方法について表にまとめてみました。表の○☓は設定方式の使用可否を示しています。MD5が唯一ここまでご紹介してきた設定方式全てが使えます。

OSPFネイバー認証の設定方法まとめ

コメント