22.2. IPSec による Point to Point VPN(IPsec-Tools)

IPSec とは、IETF(Internet Engineering Task)の IPsec ワーキンググループにより標準化が進められている IP パケットの認証と暗号化に関するプロトコル群です。IP パケットを保護することで、その上位のアプリケーションでやりとりされるデータを守ります。IPSec の通信では通信の暗号化に使用する鍵をあらかじめ相手と交換しておくか、通信を開始する際に行うネゴシエーション(事前の取り決め)で生成し決定します。このようにネゴシエーションの結果、使用する暗号化アルゴリズムや鍵が決定されます。そして、この得られた合意は SA(Security Association)といいます。また、同時に複数の相手と通信を行う場合には、それぞれに使用する暗号化アルゴリズムや鍵を取り決めるので、これを識別するために SPI(Security Pointer Index)という数値が使用されます。以下は、IPSec で使用する主なプロトコルです。

表 22-1.

AH(Authentication Header:認証ヘッダ)IP パケットに認証ヘッダを付加し、改竄やなりすましを検知するためのパケット認証を行うプロトコルです。
ESP(Encapsulating Security Payload:暗号ペイロード)認証だけでなく、IP パケットのデータを暗号化し改竄や偽造の無いことを保証するプロトコルです。
IKE(Internet Key Exchange)以降の暗号化通信のための鍵交換プロトコルです。

IPSec による通信は、主に以下の設定を行なうことで実現します。

表 22-2.

SA(Security Association)拠点間で行う暗号化通信の暗号鍵情報や暗号・認証方法の情報です。それぞれの SA にはユニークな SPI(Security Parameters Index)が割り振られ、SAD(Security Association Database)に保持されます。通常は IKE プロトコルにより自動で設定/管理されますが、手動で指定することも可能です。
Security Policy(SP)拠点間を流れるパケットに対してどのような IPSec ルールを適用するかを定めた情報です。それぞれの SP は SPD(Security Policy Database)に保持されます。

Turbolinux 10 Server では、カーネル 2.6 に組み込まれている機能と ipsec-tools というユーティリティを使用し IPSec を実現しています。

IPsec-Tools

http://ipsec-tools.sourceforge.net/

22.2.1. ipsec-tools の関連ファイル

Turbolinux 10 Server における ipsec-tools の関連ファイルは以下の通りです。

表 22-3. 関連ファイル

 ファイル名備考
バージョンipsec-tools-0.4rc1 
デーモン/usr/sbin/racoon 
起動スクリプト/etc/init.d/racoon 
設定ファイル/etc/racoon/racoon.confracoon デーモンの設定ファイル
/etc/racoon/spd.confSPD の設定ファイル
ログ/var/log/messages 
ログロテートファイル/etc/logrotate.d/syslog 
SPD および SAD の管理ユーティリティ/usr/sbin/setkey 

22.2.2. racoon の設定ファイル

22.2.2.1. /etc/racoon/racoon.conf

IKE デーモンである racoon は、設定ファイル /etc/racoon/racoon.conf の記述にしたがって各ゲートウェイ間の SA 情報のやりとりを行います。IKE は、主に 2 つのフェーズの処理を行うことで拠点間の SA 情報をやりとりします。フェーズ 1 では、IKE 同士で折衝を行い、認証/鍵交換を行なます。次のフェーズ 2 では、フェーズ 1 で確立された暗号経路のもとで拠点間の SA 情報をやりとりを行ないます。/etc/racoon/racoon.conf には以下のように remote と sainof というディレクティブがありますが、それぞれがフェーズ 1 、フェーズ 2 の設定に該当しています。

設定ファイルはディレクティブとステートメントで構成され、ステートメントは、{ と } とで囲まれています。# 以降の記述はコメントとして扱われます。

path include "/etc/racoon";
path pre_shared_key "/etc/racoon/psk.txt";
path certificate "/etc/racoon/certs";

remote anonymous
{
        exchange_mode aggressive,main;
        doi ipsec_doi;
        situation identity_only;
        my_identifier address;

        lifetime time 2 min; # sec,min,hour
        initial_contact on;
        proposal_check obey;    # obey, strict or claim

        proposal {
                encryption_algorithm 3des;
                hash_algorithm sha1;
                authentication_method pre_shared_key;
                dh_group 2;
        }
}

sainfo anonymous
{
        pfs_group 2;
        lifetime time 1 hour;
        encryption_algorithm 3des, blowfish 448, rijndael ;
        authentication_algorithm hmac_sha1, hmac_md5 ;
        compression_algorithm deflate ;
}

主な設定項目を以下に解説します。

path include path

Include するファイルのパスを指定します。

path pre_shared_key file

共有シークレット(Pre-shared key)の設定ファイルのパスを指定します。共有シークレットについて詳細は、項22.2.3.1を参照してください。

path certificate path

X.509 形式の証明書や秘密鍵などを格納するディレクトリパスの指定です。証明書による認証については、項22.2.3.2を参照してください。

remote address | anonymous [port] [inherit parent] {statements}

各 remort ノードの IKE のフェーズ 1 に関する設定です。address には、接続先のリモートホストの IP アドレスを指定します。anonymous と指定した場合にはデフォルトの設定になります。デフォルトのポート番号は 500 です。inherit parent は、parentaddress または、anonymous を指定し、設定を引き継ぎます。statements には以下の表のように非常に多くの設定項目があります。

表 22-4.

exchange_mode aggressive | main | base ; racoon がイニシエータ(発呼側)の場合は、フェーズ 1 で利用する鍵交換モードの指定です。 main、aggressive、base から指定します。racoon がレスポンダー(着呼側)の場合には、受理可能なモードの指定になります。1 モード以上を指定するには、,(カンマ)で区切ります。
doi ipsec_doi;Domain Of Interpretation(DOI)を使用する指定です。変更の必要はありません。
situation identity_only;SIT_IDENTITY_ONLY(レスポンダーが 受け取ったSA要求の処理方法)を使用する指定です。変更の必要はありません。
my_identifier idtype;リモートホストに送る自分の ID の指定です。idtype には、address [address](自分の IP アドレス、デフォルトです。)、user_fqdn [user_FQDN](user@FQDN のような値)、fqdn [FQDN]、keyid [file]、asn1dn [ASN.1](ASN.1 形式)の指定が可能です。
lifetime time number timeunit;フェーズ 1 のライフタイムを指定します。timeunitには、sec(秒)、min(分)、hour(時)を選択可能です。
initial_contact on | off ;INITIAL-CONTACT メッセージの送信可(on)、不可(off)の指定です。デフォルトは on です。
proposal_check level;ライフタイムの長さとフェーズ 2 のレスポンダー側の選択に関する設定です。level には、obey(レスポンダーはイニシエータの要求に従います。)、strict(レスポンダーの方が、イニシエーターより長いライフタイムを要求したときはレスポンダーはイニシエーターの要求通りとします。それ以外は、要求は認めません。レスポンダーが PFS(Perfect Forward Secrecy)を要求していないときには、イニシエーターに従います。双方が要求していて、グループが等しくない場合は要求を拒否します。)、claim(レスポンダーの方が、イニシエーターより長いライフタイムを要求したときはレスポンダーはイニシエーターの要求通りとします。逆は、警告を送り、レスポンダーの指定通りのライフタイムを使用します。)、exact(イニシエーターとレスポンダーの要求が異なる場合は、拒否します PFS はグループが等しくない場合は要求を拒否します。)から指定します。
proposal { sub-substatements } sub-substatements には、フェーズ 1 で折衝する際の自ホストの要求項目を指定します。主な指定項目は以下表の通りです。

表 22-5. sub-substatements の項目

encryption_algorithm algorithm;フェーズ 1 で使用する暗号化アルゴリズムの指定です。必須項目です。des、 3des、 blowfish、 cast128 から指定します。
hash_algorith algorithm;フェーズ 1 で使用するハッシュアルゴリズムの指定です。必須項目です。md5、sha1 から指定します。
authentication_method type;フェーズ 1 で使用する認証メソッドの指定です。必須項目です。pre_shared_key(共有シークレット)、rsasig(X.509 認証)、gssapi_krb(Kerberos 認証)から指定します。
dh_group group;Diffie-Hellman exponentiations で使用する グループの指定です。必須指定項目です。modp768、modp1024、modp1536、modp2048、modp3072、modp4096、modp6144、modp8192、または、DH グループとして 1、2、5、14、15、16、17、18 の指定が可能です。aggressive モードを使用する場合は、通信相手と等しい DH グループを要求します。

sainfo source_id destination_id | anonymous [from idtype [string]] {statements }

フェーズ 2 で折衝する際の設定項目を記述します。設定する主な項目は以下の通りです。source_id destination_id には、address IP address [/ prefix] [[port]] ul_proto のように指定をします。port には、ポート番号を、ul_proto にはプロトコル(any はすべて)を指定します。例えば、192.168.0.0/24 と 192.168.1.0/24 のネットワークの場合は sainfo address 192.168.0.0/24 any address 192.168.1.0/24 any ...略 のように指定することができます。anonymous は、デフォルトの指定です。または、 idtype [string]]に完全に一致する ID ペイロードを指定することもできます。statements には以下の表のように非常に多くの設定項目があります。

表 22-6.

pfs_group group;PFS(Perfect Forward Secrecy)の設定です。modp768、modp1024、modp1536、modp2048、modp3072、modp4096、modp6144、modp8192、または、DH グループとして 1、2、5、14、15、16、17、18 の指定が可能です。
lifetime time number timeunit;SA のライフタイムを指定します。timeunitには、sec(秒)、min(分)、hour(時)を選択可能です。
encryption_algorithm algorithm;フェーズ 2 で使用する暗号化アルゴリズムの指定です。des、3des、des_iv64、 des_iv32、rc5、rc4、cast128、blowfish、null_enc、twofish、rijndael から指定します。
authentication_algorithm algorithm;フェーズ 2 で使用する認証アルゴリズムの指定です。des、3des、des_iv64、des_iv32、hmac_md5、hmac_sha1、non_auth から指定します。
compression_algorithm algorithms;フェーズ 2 で使用する圧縮方法の指定です。deflate を指定します。
hash_algorith algorithms;フェーズ 2 で使用するハッシュアルゴリズムの指定です。des、3des、des_iv64、des_iv32、hmac_md5、hmac_sha1、non_authから指定します。

22.2.2.2. /etc/racoon/spd.conf

/etc/racoon/spd.conf には、SPD(Security Policy Database)に追加するルールを記述します。この設定ファイルは racoon の起動時に読み込まれ、setkey コマンドの spdadd オペレータにより SPD に設定が反映されます。書式は以下の通りです。

spdadd [src_range] [dst_range] [upperspec] [policy] ;

src_range

IPSec で接続をするローカルの IP アドレス、または IP アドレスの範囲を指定します。接続方法には、LAN 同士を接続する tunnel モードと、2台のホスト間を 接続する transport モードがあります。tunnel モードの場合は、ローカルなネットワークで使用している IP アドレス範囲を指定し、transport モードでは、IP アドレスを指定します。 IP アドレスは、192.168.1.1 、192.168.1.0/24 のような形式で指定します。また IP アドレスに続けてポート番号の指定も可能です。

dst_range

IPSec で接続をするリモートの IP アドレス、または IP アドレスの範囲を指定します。tunnel モードの場合は、リモートネットワークで使用している IP アドレス範囲を指定し、transport モードでは、IP アドレスを指定します。

upperspec

/etc/protocols に指定のあるプロトコル、プロトコル番号の指定が可能です。

policy

以下のフォーマットで指定します。

-P direction [priority specification] discard protocol/mode/src-dst/level [...]
-P direction [priority specification] none protocol/mode/src-dst/level [...]
-P direction [priority specification] ipsec protocol/mode/src-dst/level [...]

表 22-7.

direction方向を in (ローカルからリモート)または、out(リモートからローカル)から指定します。
priority specificationポリシーのプライオリティを指定します。
protocol使用するプロトコルを、ah、esp、ipcomp から指定します。
mode接続方法を transport、tunnel から指定します。
src-dsttunnel モードの場合のみ有効です。SA の使用する IP アドレスの始点(ローカルのゲートウェイ)と終点(リモートのゲートウェイ)を -(ハイフン)で区切って指定します。
levelレベルを default、use、require、unique から指定します。

22.2.2.3. modporbe.conf の設定

以下のように必要なカーネルモジュールを /etc/modporbe.conf に記述します。

alias xfrm-type-2-50    esp4
alias xfrm-type-2-51    ah4
alias xfrm-type-2-108   ipcomp
alias xfrm-type-10-50   esp6
alias xfrm-type-10-51   ah6
alias xfrm-type-10-108  ipcomp6

22.2.2.4. ファイアウォールの設定

racoon デーモンは、デフォルトで UDP の 500 番ポートを使用します。ファイアウォールで、このパケットを通すように設定を行っておいてください。

22.2.3. 認証に関する設定

22.2.3.1. 共有シークレットによる認証の設定

racoon では、ネゴシエーションのフェーズ 1 でリモートのゲートウェイと相互に認証を行います。共有シークレット方式(PSK :Preshared Key)、デジタル証明書(X.509)による認証、ケロベロス認証などの指定が可能です。本マニュアルでは、共有シークレットと X.509 方式の証明書による認証の設定について解説します。証明書による認証では、秘密鍵と公開鍵という鍵ペアを使用した認証を行い、あらかじめリモート側の公開鍵を入手しておく必要があります(詳細は 項22.2.3.2)。共有シークレット方式では、あらかじめ双方で決めた任意のキーワードを使用した認証を行います。

Turbolinux 10 Server の racoon.conf ファイルには初期状態で以下の記述があり、共有シークレットを使用した認証が有効に設定されています。以下は、共有シークレットの格納ファイル(/etc/racoon/psk.txt)のパス指定です。

path pre_shared_key "/etc/racoon/psk.txt";

proposal { } 内には以下の記述があり、認証メソッドに pre_shared_key の使用が指定されています。

authentication_method pre_shared_key;

/etc/racoon/psk.txt に、あらかじめ拠点間で取り決めをした共有シークレットを以下の書式で格納します。identifier には、通信相手を識別する ID を IP アドレスや FQDN で指定します。 key には使用する共有シークレットを指定します。

identifier    key

例は、9.8.7.6 の通信相手と turbo_secret という共有シークレットを使用する場合です。

9.8.7.6      turbo_secret

設定ファイルを変更した場合は、変更を反映するために racoon を再起動します。

# /etc/init.d/racoon restart

22.2.3.2. X.509 形式証明書を使用した認証

Turbolinux 10 Server の racoon では、X.509 に準拠したデジタル認証書を用いた認証を行うことが可能です。秘密鍵と公開鍵という鍵ペアを使用した認証を行います。通常は、通信相手の正当性と公開鍵を保証するために CA により証明を受けたデジタル証明書を使用します。ここでは、動作検証用に自己署名を行った電子証明書を使用します。また、あらかじめ通信相手(リモート側)の公開鍵を入手しておく必要があります。以下のような手順で準備を行います。

鍵ペア生成

X.509 認証方式を利用する場合、秘密鍵と証明書署名要求(公開鍵を含む)を以下のように生成します。1024 bit 長の秘密鍵と公開鍵のペアを、cakey.key と careq.pem というファイル名で出力しています。

$ openssl req -new -nodes -newkey rsa:1024 -sha1 -keyform PEM -keyout cakey.key -outform PEM -out careq.pem
Generating a 1024 bit RSA private key
.......................++++++
........................................................................++++++
writing new private key to 'cakey.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:JP
State or Province Name (full name) [Some-State]:Tokyo
Locality Name (eg, city) []:Shibuya
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Mycompany
Organizational Unit Name (eg, section) []:Doc
Common Name (eg, YOUR name) []:example.com
Email Address []:taro@example.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

作成をした証明書署名要求に自己署名を行い証明書 cacert.pem を出力します。-in には、作成をした証明書署名要求(例は careq.pem)、-sigkey は、作成をした秘密鍵ファイル(例は cakey.key)を指定します。

$ openssl x509 -req -in careq.pem -signkey cakey.key -out cert.pem
Signature ok
subject=/C=JP/ST=Tokyo/L=Shibuya/O=Mycompany/OU=Doc/CN=example.com/emailAddress=taro@example.com
Getting Private key

カレントディレクトリに出力された証明書、秘密鍵を racoon.conf の path certificate で指定をしたディレクトリ以下にコピーします。ディレクトリは、root の所有で パーミッションを 700 に設定してください。Turbolinux 10 Server の初期設定は、/etc/racoon/certs/ であらかじめディレクトリが用意されています。

# cp cacert.pem /etc/racoon/certs/
# cp cakey.key /etc/racoon/certs/

リモート側でも同様に生成し、証明書ファイルを入手し、同じディレクトリ下に、racoon.conf の peers_certfile で指定をしたファイル名で格納します。また、ローカル側の証明書ファイル(上記例は cacert.pem )を通信相手に安全な方法で渡しておきます。

racoon.conf ファイルの編集

X.509 認証を行う場合、racoon.conf ファイルに以下のディレクティブを記述します。

my_identifier asn1dn;

リモートホストに送る自分の ID の指定です。asn1dn は、公開鍵から取り出したデータを使用する指定です。

peers_identifier asn1dn;

リモートホストの ID 指定です。asn1dn は、公開鍵から取り出したデータを使用する指定です。

certificate_type x509 certfile privkeyfile;

certfile には、ローカルの証明書ファイル名、privkeyfile にはローカルの秘密鍵ファイル名を指定します。格納先のディレクトリは、path certificate ディレクティブで指定されているディレクトリ以下です。(Turbolinux 10 Server の初期状態では、/etc/racoon/certs )

peers_certfile x509 dnssec |certfile;

dnssec を指定した場合には、通信相手の CERT ペイロードを無視し、DNS から証明書を入手します。certfile に 通信相手の証明書のファイル名を指定した場合は、その証明書を使用します。格納先のディレクトリは、path certificate ディレクティブで指定されているディレクトリ以下です。(Turbolinux 10 Server の初期状態では、/etc/racoon/certs )

authentication_method type;

proposal { } 内の authentication_method に認証方式を指定します。X.509 の場合は、type に rsasig を指定します。

ローカルの証明書が cacert.pem、秘密鍵が cakey.key 、通信相手の証明書が remort-cacert.pem の場合には以下のように指定します。各ファイルは、/etc/racoon/certs 以下に格納しておきます。

path include "/etc/racoon";
path pre_shared_key "/etc/racoon/psk.txt";
path certificate "/etc/racoon/certs";

remote 1.2.3.4
{
        exchange_mode aggressive,main;
        doi ipsec_doi;
        situation identity_only;

        my_identifier asn1dn;
        peers_identifier asn1dn;

        certificate_type x509 "cacert.pem" "cakey.key";
        peers_certificate x509 "remort-cacert.pem";
        lifetime time 2 min; # sec,min,hour
        initial_contact on;
        proposal_check obey;    # obey, strict or claim

        proposal {
                encryption_algorithm 3des;
                hash_algorithm sha1;
                authentication_method rsasig;

                dh_group 2;
        }
省略...

設定ファイルを変更した場合は、変更を反映するために racoon を再起動します。

# /etc/init.d/racoon restart

22.2.4. racoon の設定例

22.2.4.1. LAN 間接続(tunnel モード)

インターネットを介した 2 つのオフィスのネットワークなど遠隔地にある LAN 同士を VPN で接続する場合を、Turbolinux 10 Server のインストールされたゲートウェイマシン(SG1 と SG2)を各ネットワークに設置している構成例で解説します。

ゲートウェイには、それぞれ 2 枚の NIC が搭載され、一方の eth1 は LAN 側にもう一方の eth0 はインターネット側に接続されており、eth0 にはグローバルアドレス、eth1 にはプライベートアドレスが設定されています。また、ゲートウェイはファイアウォールマシンとしても利用するためパケットのフォワードを許可し、IP マスカレードの設定が行われています。racoon では、UDP の 500 番ポートを利用するためこれらのパケットも必ず許可してください。

以下は構成例のネットワークに関する設定情報です。

表 22-8. 構成

ゲートウェイeth0(外向)eth1(内向)LAN
SG11.2.3.4192.168.0.1192.168.0.0/24
SG29.8.7.6192.168.1.1192.168.1.0/24

SG1 セキュリティゲートウェイ側の設定

上記構成の SG1 の/etc/racoon/racoon.conf の設定例は以下のようになります。

path include "/etc/racoon";
path pre_shared_key "/etc/racoon/psk.txt";
path certificate "/etc/racoon/certs";

remote 9.8.7.6
{
        exchange_mode aggressive,main;
        doi ipsec_doi;
        situation identity_only;

        my_identifier address;

        lifetime time 2 min; # sec,min,hour
        initial_contact on;
        proposal_check obey;    # obey, strict or claim

        proposal {
                encryption_algorithm 3des;
                hash_algorithm sha1;
                authentication_method pre_shared_key;
                dh_group 2;
        }
}

sainfo address 192.168.0.0/24 any address 192.168.1.0/24 any
{
        pfs_group 2;
        lifetime time 1 hour;
        encryption_algorithm 3des, blowfish 448, rijndael ;
        authentication_algorithm hmac_sha1, hmac_md5 ;
        compression_algorithm deflate ;
}

SG1 の /etc/racoon/spd.conf の設定例は以下のようになります。

spdadd 192.168.0.0/24 192.168.1.0/24 any -P out ipsec esp/tunnel/1.2.3.4-9.8.7.6/require;
spdadd 192.168.1.0/24 192.168.0.0/24 any -P in ipsec esp/tunnel/9.8.7.6-1.2.3.4/require;

SG1 の /etc/racoon/psk.txt の設定例(パスフレーズは turbo_secret)は以下のようになります。

9.8.7.6      turbo_secret
SG2 セキュリティゲートウェイ側の設定

上記構成の SG2 の/etc/racoon/racoon.conf の設定例は以下のようになります。

path include "/etc/racoon";
path pre_shared_key "/etc/racoon/psk.txt";
path certificate "/etc/racoon/certs";

remote 1.2.3.4
{
        exchange_mode aggressive,main;
        doi ipsec_doi;
        situation identity_only;

        my_identifier address;

        lifetime time 2 min; # sec,min,hour
        initial_contact on;
        proposal_check obey;    # obey, strict or claim

        proposal {
                encryption_algorithm 3des;
                hash_algorithm sha1;
                authentication_method pre_shared_key;
                dh_group 2;
        }
}

sainfo address 192.168.1.0/24 any address 192.168.0.0/24 any
{
        pfs_group 2;
        lifetime time 1 hour;
        encryption_algorithm 3des, blowfish 448, rijndael ;
        authentication_algorithm hmac_sha1, hmac_md5 ;
        compression_algorithm deflate ;
}

SG2 の /etc/racoon/spd.conf の設定例は以下のようになります。

spdadd 192.168.1.0/24 192.168.0.0/24 any -P out ipsec esp/tunnel/9.8.7.6-1.2.3.4/require;
spdadd 192.168.0.0/24 192.168.1.0/24 any -P in ipsec esp/tunnel/1.2.3.4-9.8.7.6/require;

SG2 の /etc/racoon/psk.txt の設定例(パスフレーズは turbo_secret)は以下のようになります。

1.2.3.4      turbo_secret

22.2.4.2. ホスト間接続(transport モード)

インターネットを介し遠隔地にある Turbolinux 10 Server のインストールされた 2 台のホスト同士を VPN で接続する場合の設定について以下の構成例で解説します。racoon では、UDP の 500 番ポートを利用するため、ファイアーウォールの設定でこのパケットを許可してください。

以下は構成例のネットワークに関する設定情報です。

表 22-9. 構成

ホストIP アドレス
SV11.2.3.4
SV29.8.7.6

SV1 ホストの設定

上記構成の SV1 の/etc/racoon/racoon.conf の設定例は以下のようになります。

path include "/etc/racoon";
path pre_shared_key "/etc/racoon/psk.txt";
path certificate "/etc/racoon/certs";

remote 9.8.7.6
{
        exchange_mode aggressive,main;
        doi ipsec_doi;
        situation identity_only;

        my_identifier address;

        lifetime time 2 min; # sec,min,hour
        initial_contact on;
        proposal_check obey;    # obey, strict or claim

        proposal {
                encryption_algorithm 3des;
                hash_algorithm sha1;
                authentication_method pre_shared_key;
                dh_group 2;
        }
}

sainfo address 1.2.3.4 any address 9.8.7.6 any
{
        pfs_group 2;
        lifetime time 1 hour;
        encryption_algorithm 3des, blowfish 448, rijndael ;
        authentication_algorithm hmac_sha1, hmac_md5 ;
        compression_algorithm deflate ;
}

SV1 の /etc/racoon/spd.conf の設定例は以下のようになります。

spdadd 1.2.3.4 9.8.7.6 any -P out ipsec esp/transport//require;
spdadd 9.8.7.6 1.2.3.4 any -P in ipsec esp/transport//require;

SG1 の /etc/racoon/psk.txt の設定例(パスフレーズは turbo_secret)は以下のようになります。

9.8.7.6      turbo_secret
SV2 ホストの設定

上記構成の SV2 の/etc/racoon/racoon.conf の設定例は以下のようになります。

path include "/etc/racoon";
path pre_shared_key "/etc/racoon/psk.txt";
path certificate "/etc/racoon/certs";

remote 1.2.3.4
{
        exchange_mode aggressive,main;
        doi ipsec_doi;
        situation identity_only;

        my_identifier address;

        lifetime time 2 min; # sec,min,hour
        initial_contact on;
        proposal_check obey;    # obey, strict or claim

        proposal {
                encryption_algorithm 3des;
                hash_algorithm sha1;
                authentication_method pre_shared_key;
                dh_group 2;
        }
}

sainfo address 9.8.7.6 any address 1.2.3.4 any
{
        pfs_group 2;
        lifetime time 1 hour;
        encryption_algorithm 3des, blowfish 448, rijndael ;
        authentication_algorithm hmac_sha1, hmac_md5 ;
        compression_algorithm deflate ;
}

SV2 の /etc/racoon/spd.conf の設定例は以下のようになります。

spdadd 9.8.7.6 1.2.3.4 any -P out ipsec esp/transport//require;
spdadd 1.2.3.4 9.8.7.6 any -P in ipsec esp/transport//require;

SG2 の /etc/racoon/psk.txt の設定例(パスフレーズは turbo_secret)は以下のようになります。

1.2.3.4      turbo_secret

22.2.5. racoon の起動と停止

Turbolinux 10 Server で racoon の起動や停止を行うには、/etc/init.d/racoon スクリプトに以下のオプションを指定して実行します。

表 22-10. /etc/init.d/racoon

オプション操作
startracoon デーモンを起動します。SPD 設定ファイル(spd.conf)の記述に従って暗号化通信のためのルールが追加されます。
stopracoon デーモンを停止し、すべての暗号化通信を終了します。SPD、SAD エントリはすべて削除されます。
restartracoon デーモンを再起動します。stop のあとに、start を実行します。
reload設定ファイルを再読み込みします。
statusracoon デーモンの起動状況を確認します。
condrestartracoon デーモンが動作しているかを確認後、再起動します。(/var/run/racoon.pid が存在するとき再起動します。)

設定完了後、racoon を起動するには、以下のコマンドを実行します。

# /etc/init.d/racoon start

racoon を停止するには、以下のコマンドを実行します。

# /etc/init.d/racoon stop

Turbolinux 10 Server 起動時に racoon を自動的に開始するには、以下のように chkconfig コマンドを実行しておきます。

# chkconfig racoon on

設定ファイルを変更した場合は、変更を反映するために racoon を再起動します。

# /etc/init.d/racoon restart

22.2.6. 動作確認

ローカルとリモートの設定が完了したら、racoon を起動し telnet などのなんらかの通信を開始します。自動的にネゴシエーションが開始され接続が確立されます。確立するまでのいくつかのパケットは失敗することもあります。接続が確立された後の通信は暗号化されます。

以下のように tcpdump コマンドを実行してパケットを確認することも可能です。以下の例では、192.168.0.1 と 192.168.1.1 のホスト間のパケットをダンプしています。セキュリティプロトコル ESP(Encapsulating Security Payload)で暗号化されていることが分かります。

# tcpdump -x host 192.168.0.1 and 192.168.1.1
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 68 bytes
16:33:11.138380 IP 192.168.0.1 > 192.168.1.1: ESP(spi=0x0013e9d2,seq=0x106)
        0x0000:  4500 0078 0097 4000 4032 b569 c0a8 0102  E..x..@.@2.i....
        0x0010:  c0a8 0201 0013 e9d2 0000 0106 067b c576  .............{.v
        0x0020:  4eac 3302 4311 eef7 7730 9fd7 3fef 6d5b  N.3.C...w0..?.m[
        0x0030:  89a9 e1bd 63c0                           ....c.
16:33:11.140041 IP 192.168.1.1 > 192.168.0.1: ESP(spi=0x057eec2c,seq=0x117)
        0x0000:  4500 0078 34c6 0000 4032 c13a c0a8 0201  E..x4...@2.:....
        0x0010:  c0a8 0102 057e ec2c 0000 0117 bd95 863e  .....~.,.......>
        0x0020:  38b4 635a c013 bf6b ba18 0f2a 2275 23b9  8.cZ...k...*"u#.
        0x0030:  63f1 2e36 4e2a                           c..6N*
省略...