今回やること
前回の構築の引き続きとなります。
R2の設定をしてあげて完了となります。
前回の記事
⇒【前編】ネットワーク構築(IPsec)
⇒【後編①】ネットワーク構築(IPsec)
⇒【後編②】ネットワーク構築(IPsec)
前回の設定まとめ
IKEフェーズ | パラメータ | R1ステータス |
---|---|---|
1 | 事前共有鍵 | kensyo |
2 | 暗号アルゴリズム | esp-aes |
2 | ハッシュアルゴリズム | esp-sha-hmac |
2 | トランスフォームセット名前 | KENSYO |
2 | マップ名 | BENKYO |
ネットワーク構成図
構築
では前回引き続き構築していこうと思います。
R2にコンフィグ投入していきます。
基本的な流れはR1と同じで、前回定義していったものを投入するイメージでいけると思います。
まずはトランスフォームセット定義まで。
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#cry isa poli 1
R2(config-isakmp)#aut pre
R2(config-isakmp)#exit
R2(config)#
R2(config)#cry isa key 0 kensyo add 192.168.12.1
R2(config)#cry ipsec tra
R2(config)#cry ipsec transform-set KENSYO esp-
R2(config)#cry ipsec transform-set KENSYO esp-aes esp-s
R2(config)#cry ipsec transform-set KENSYO esp-aes esp-sha-hmac
R2(cfg-crypto-trans)#exit
R2(config)#
次は拡張ACLの設定からトランスフォームセットの定義まで一気にいきます。
R2(config)#
R2(config)#acc
R2(config)#$ 100 per ip 192.168.20.0 0.0.0.255 192.168.10.0 0.0.0.255
R2(config)#cry map BENKYO 1 ipsec-
R2(config)#cry map BENKYO 1 ipsec-is
R2(config)#cry map BENKYO 1 ipsec-isakmp
% NOTE: This new crypto map will remain disabled until a peer
and a valid access list have been configured.
R2(config-crypto-map)#
R2(config-crypto-map)#mat add 100
R2(config-crypto-map)#set peer 192.168.12.1
R2(config-crypto-map)#set tr
R2(config-crypto-map)#set transform-set KENSYO
R2(config-crypto-map)#exit
R2(config)#
R2(config)#
どこに何をいれるかわからなくなりますが、落ち着いて何回も見直して設定したらいけました。
トランスフォームの名前なんだっけ?マップなんだっけ?そもそもコマンドこれだっけ?
となりながらなんとか・・・笑
では次にインターフェイスの設定してあげます。
デフォルトルートからいれていきます。
R2(config)#
R2(config)#ip route 0.0.0.0 0.0.0.0 192.168.12.1
R2(config)#int f0/1
R2(config-if)#ip add 192.168.20.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#exit
R2(config)#
R2(config)#
R2(config)#
*Mar 1 00:15:24.255: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar 1 00:15:25.256: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config)#int f0/0
R2(config-if)#ip add 192.168.12.2 255.255.255.0
R2(config-if)#cry map BENKYO
R2(config-if)#
*Mar 1 00:16:03.864: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON
R2(config-if)#no sh
R2(config-if)#e
*Mar 1 00:16:14.749: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:16:15.751: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#end
R2#
これでようやく構築完了しました!!!
いやー長かった・・・
問題は正常かどうか。
さて見ていきましょう。
確認コマンド色々ありますね。
とりあえず色々打っていきましょう。
状態確認
早速見ましょう。
R1#show crypto isakmp policy
Global IKE policy
Protection suite of priority 1
encryption algorithm: DES - Data Encryption Standard (56 bit keys).
hash algorithm: Secure Hash Standard
authentication method: Pre-Shared Key
Diffie-Hellman group: #1 (768 bit)
lifetime: 86400 seconds, no volume limit
Default protection suite
encryption algorithm: DES - Data Encryption Standard (56 bit keys).
hash algorithm: Secure Hash Standard
authentication method: Rivest-Shamir-Adleman Signature
Diffie-Hellman group: #1 (768 bit)
lifetime: 86400 seconds, no volume limit
R1#
ISAKMPのポリシーは設定した通りにpre-sharedで入ってますね。
OKそうです。
次!
R1#show crypto isakmp sa
dst src state conn-id slot status
R1#
えー
なんでかSA確立してないっぽい。
他も見てみましょう。
R1#show cry ipsec transform-set
Transform set KENSYO: { esp-aes esp-sha-hmac }
will negotiate = { Tunnel, },
R1#
トランスフォームセットは設定通りに反映してますね。
次!
R1#show crypto map
Crypto Map "BENKYO" 1 ipsec-isakmp
Peer = 192.168.12.2
Extended IP access list 100
access-list 100 permit ip 192.168.10.0 0.0.0.255 192.168.20.0 0.0.0.255
Current peer: 192.168.12.2
Security association lifetime: 4608000 kilobytes/3600 seconds
PFS (Y/N): N
Transform sets={
KENSYO,
}
Interfaces using crypto map BENKYO:
FastEthernet0/0
R1#
よし、マップは反映されていますね。
最後!
R1#
R1#show crypto session
Crypto session current status
Interface: FastEthernet0/0
Session status: DOWN ⇐ これ
Peer: 192.168.12.2 port 500
IPSEC FLOW: permit ip 192.168.10.0/255.255.255.0 192.168.20.0/255.255.255.0
Active SAs: 0, origin: crypto map
R1#
SA自体の設定は問題なさそう。
おや?セッションがDOWNしてますね。
原因これだ!!
でもなぜ落ちているのだろうか。
ポートは開放しているし、コンフィグ見直してもOKっぽいし。
わからーーーん!!!
【調べること1時間・・・】
IPsecでは、生存時間の満了時にSAを解放するらしい。
これは、同じSAを使いつづけるとセキュリティ的にまずいという観点からライフタイムがあって、
何も設定しないと600秒で勝手にセッション切れるっぽい。
これだー!!
ライフタイム設定してないし、これ設定しないと今回みたいなことになるっぽいですねー。
これはかなりの収穫です。
ちなみにコマンド
コマンド | 説明 |
---|---|
set security-associationlifetime seconds [秒] | 60~4294967295秒の間で設定できる。 |
次回からはライフタイムの設定を確実にやらないとですね。
まとめ
IPsecかなり手こずりました。
一通り設定やってみて、なんとなく雰囲気は掴めました。
実際構築してみると新たな気付きが生まれて面白いですね。
今後もセキュリティの勉強をしていきたいと思います。
以上となります。