はじめに
IPsec の概要については、以下の記事をご参照ください。
IPsec の特徴 IPsec は IP パケット(ネットワーク層)に対して暗号化を行うためのセキュリティ・プロトコルです。IPsec には次のような特徴があります。 アドレス、ヘッダ、データの改竄防止、暗号化 暗号化の枠組みと[…]
想定環境

Cisco IPsec VPN 設定例
Cisco ルータの IPsec で VTI(Virtual Tunnel Interface)を利用した際の設定例です。
VTI はざっくりいうと、GRE Tunnel でカプセル化したトラフィックを IPsec で暗号化するといった感じです。
VTI 以外の方法では、Access-List で指定したトラフィックを IPsec で暗号化する方法があります。
hostname R1
!
crypto isakmp policy 1
encr aes
authentication pre-share
group 2
crypto isakmp key [KEY] address 10.1.1.2
!
crypto ipsec transform-set TFSET esp-aes esp-sha-hmac
mode transport
!
crypto ipsec profile VTI
set transform-set TFSET
set pfs group2
!
interface Tunnel1
ip unnumbered Dialer1
tunnel source Dialer1
tunnel destination 10.1.1.2
tunnel mode ipsec ipv4
tunnel protection ipsec profile VTI
!
interface FastEthernet0
no ip address
pppoe enable group global
pppoe-client dial-pool-number 1
!
interface FastEthernet2
switchport mode access
switchport access vlan 10
!
interface Vlan10
ip address 192.168.1.254 255.255.255.0
ip nat inside
ip virtual-reassembly
!
interface Dialer1
mtu 1454
ip address negotiated
ip nat outside
ip virtual-reassembly
encapsulation ppp
dialer pool 1
ppp authentication chap callin
ppp chap hostname r1@example.com
ppp chap password 0 [PASSWORD]
ppp ipcp dns request
ppp ipcp route default
!
ip route 192.168.2.0 255.255.255.0 Tunnel1
ip route 10.1.1.2 255.255.255.255 Dialer1
!
ip nat inside source list 1 interface Dialer1 overload
!
access-list 1 permit any
!
endhostname R2
!
crypto isakmp policy 1
encr aes
authentication pre-share
group 2
crypto isakmp key [KEY] address 10.1.1.1
!
crypto ipsec transform-set TFSET esp-aes esp-sha-hmac
mode transport
!
crypto ipsec profile VTI
set transform-set TFSET
set pfs group2
!
interface Tunnel1
ip unnumbered Dialer1
tunnel source Dialer1
tunnel destination 10.1.1.1
tunnel mode ipsec ipv4
tunnel protection ipsec profile VTI
!
interface FastEthernet0
no ip address
pppoe enable group global
pppoe-client dial-pool-number 1
!
interface FastEthernet2
switchport mode access
switchport access vlan 10
!
interface Vlan10
ip address 192.168.2.254 255.255.255.0
ip nat inside
ip virtual-reassembly
!
interface Dialer1
mtu 1454
ip address negotiated
ip nat outside
ip virtual-reassembly
encapsulation ppp
dialer pool 1
ppp authentication chap callin
ppp chap hostname r2@example.com
ppp chap password 0 [PASSWORD]
ppp ipcp dns request
ppp ipcp route default
!
ip route 192.168.1.0 255.255.255.0 Tunnel1
ip route 10.1.1.1 255.255.255.255 Dialer1
!
ip nat inside source list 1 interface Dialer1 overload
!
access-list 1 permit any
!
end解説
IKE フェーズ1(ISAKMP SA)の設定
IKE フェーズ1 で使用する暗号化アルゴリズム(encr aes)、認証方式(authentication pre-share)、Diffie-Hellman グループ(group 2)、事前共有キー(isakmp key [KEY])、対向の IP アドレス(address 10.1.1.x)を設定します。
crypto isakmp policy 1
encr aes
authentication pre-share
group 2
crypto isakmp key [KEY] address 10.1.1.2IKE フェーズ2(IPsec SA)の設定
SP 暗号化(esp-aes)、ESP 認証(esp-sha-hmac)、転送モードを定義します。
転送モードは、経験上、Transport Mode を使用することが多いです。
これらを、Cisco はトランスフォームセットと呼んでいます。
crypto ipsec transform-set TFSET esp-aes esp-sha-hmac
mode transport
!
crypto ipsec profile VTI
set transform-set TFSET
set pfs group2Tunnel インターフェースへの紐づけ
最後に、Tunnel インターフェースに、トランスフォーム設定を Profile で紐づけます。
これで、GRE Tunnel でカプセル化されたトラフィックは、IPsec で暗号化されるようになります。
interface Tunnel1
tunnel mode ipsec ipv4
tunnel protection ipsec profile VTI確認コマンド
IKE フェーズ1(ISAKMP SA)の確認
QM_IDLE となっていれば OK です。
R1#show crypto isakmp sa
IPv4 Crypto ISAKMP SA
dst src state conn-id slot status
10.1.1.1 10.1.1.2 QM_IDLE 2001 0 ACTIVEIKE フェーズ2(IPsec SA)の確認
双方向 SA で Encrypt と Decrypt がカウントされていれば OK です。
R1#show crypto engine connection active
Crypto Engine Connections
ID Interface Type Algorithm Encrypt Decrypt IP-Address
3 Di1 IPsec AES+SHA 0 963 10.1.10.1
4 Di1 IPsec AES+SHA 963 0 10.1.10.1
2001 Di1 IKE SHA+AES 0 0 10.1.10.1以上
