strongSwan on Debian で IKEv2 VPN 備忘録

Environment
Photo by hyt.

strongSwan on Debian で IKEv2 VPN 備忘録です.

strongSwan で IKEv2 VPN を使う設定

strongSwan で IKEv2 VPN を使うための設定については,以前の記事

strongSwan で IKEv2 VPN 備忘録
strongSwan で IKEv2 VPN 備忘録です. はじめに これまで長いこと使ってきた Softether VPN ですが,残念なことに IKEv2 に対応していません.しかし,セキュリティ的に L2TP/IPSec をこれ以上使...

をご覧ください.ただし,この設定は Alpine Linux 3.19.0 を前提としています.逆に言うと Ubuntu とかその他のディストリビューションではこの通り設定してもうまくいかないことがあります.実際に DietPi(Raspberry pi などの SBC に最適化された Debian 系のディストリビューション)でやってみたのですが,うまくいかず,かなり長時間ハマってしまいました.

なお,DietPi については,

DietPi インストール備忘録
はじめに 以前御紹介した PINE A64+ ですが,標準的なインストールイメージだと,5回に2回程度は再起動に失敗してしまいます.何回か電源を入れ直せば起動するので,これまでだましだまし使ってきたのですが,色々見てると DietPi の出...

をご覧いただければと思います.

Debian で strongSwan を使う

結論から書くと,

Debian 系のディストリビューションで strongSwan を使うときは,パッケージが細かく分割されていることに注意する必要あり

です.

実際 DietPi だと以下のような感じになっています(多分 Debian でも同じ).

$ sudo apt search strongswan
...
charon-systemd/stable,stable-security 5.9.8-5+deb12u1 arm64
  strongSwan IPsec client, systemd support

libcharon-extauth-plugins/stable,stable-security,now 5.9.8-5+deb12u1 arm64
  strongSwan charon library (extended authentication plugins)

libcharon-extra-plugins/stable,stable-security,now 5.9.8-5+deb12u1 arm64
  strongSwan charon library (extra plugins)

libstrongswan/stable,stable-security,now 5.9.8-5+deb12u1 arm64
  strongSwan utility and crypto library

libstrongswan-extra-plugins/stable,stable-security,now 5.9.8-5+deb12u1 arm64
  strongSwan utility and crypto library (extra plugins)

libstrongswan-standard-plugins/stable,stable-security,now 5.9.8-5+deb12u1 arm64
  strongSwan utility and crypto library (standard plugins)

network-manager-strongswan/stable 1.6.0-1+deb12u1 arm64
  network management framework (strongSwan plugin)

strongswan/stable,stable-security,now 5.9.8-5+deb12u1 all
  IPsec VPN solution metapackage

strongswan-charon/stable,stable-security,now 5.9.8-5+deb12u1 arm64
  strongSwan Internet Key Exchange daemon

strongswan-libcharon/stable,stable-security,now 5.9.8-5+deb12u1 arm64
  strongSwan charon library

strongswan-nm/stable,stable-security 5.9.8-5+deb12u1 arm64
  strongSwan plugin to interact with NetworkManager

strongswan-pki/stable,stable-security 5.9.8-5+deb12u1 arm64
  strongSwan IPsec client, pki command

strongswan-starter/stable,stable-security,now 5.9.8-5+deb12u1 arm64
  strongSwan daemon starter and configuration file parser

strongswan-swanctl/stable,stable-security,now 5.9.8-5+deb12u1 arm64
  strongSwan IPsec client, swanctl command

IKEv2 サーバを立てる場合,Windows 等からの接続を考慮し認証方式として MS-CHAPv2 を使うことが多いと思いますし,上で紹介した記事の設定もそうです.

しかし,Debian 系のディストリビューションだと,

$ sudo apt install strongswan

とするだけでは MS-CHAPv2 を strongSwan で使えるようにする plugin が導入されない.だから設定正しくてもつながらない.さらに,

$ sudo apt install libcharon-extauth-plugins libstrongswan libstrongswan-extra-plugins libstrongswan-standard-plugins strongswan-swanctl

のような感じでパッケージを追加する必要があったということですね.

有効な plugin ほかを調べる

なお,strongSwan で有効化されている plugin ほかの情報は,

$ sudo ipsec statusall
Status of IKE charon daemon (strongSwan 5.9.8, Linux 6.1.21-v8+, aarch64):
  uptime: 74 minutes, since Jan 09 20:57:55 2024
  malloc: sbrk 3342336, mmap 0, used 1639680, free 1702656
  worker threads: 11 of 16 idle, 5/0/0/0 working, job queue: 0/0/0/0, scheduled: 0
  loaded plugins: charon test-vectors ldap pkcs11 aes rc2 sha2 sha1 md5 mgf1 random nonce x509 revocation constraints pubkey pkcs1 pkcs7 pkcs12 pgp dnskey sshkey pem openssl gcrypt pkcs8 af-alg fips-prf gmp curve25519 agent chapoly xcbc cmac hmac kdf ctr ccm gcm drbg curl attr kernel-netlink resolve socket-default connmark forecast farp stroke vici updown eap-identity eap-aka eap-md5 eap-gtc eap-mschapv2 eap-radius eap-tls eap-ttls eap-tnc xauth-generic xauth-eap xauth-pam tnc-tnccs dhcp lookip error-notify certexpire led addrblock unity counters
Listening IP addresses:
  192.168.0.100
Connections:
 IPSec-IKEv2:  %any4...%any4  IKEv2, dpddelay=300s
 IPSec-IKEv2:   local:  [*****************] uses public key authentication
 IPSec-IKEv2:    cert:  "************************************************************"
 IPSec-IKEv2:   remote: uses public key authentication
 IPSec-IKEv2:   child:  0.0.0.0/0 === dynamic TUNNEL, dpdaction=none
IPSec-IKEv2-EAP:  %any4...%any4  IKEv2, dpddelay=300s
IPSec-IKEv2-EAP:   local:  [*****************] uses public key authentication
IPSec-IKEv2-EAP:    cert:  "************************************************************"
IPSec-IKEv2-EAP:   remote: uses EAP_MSCHAPV2 authentication with EAP identity '%any'
IPSec-IKEv2-EAP:   child:  0.0.0.0/0 === dynamic TUNNEL, dpdaction=none
Security Associations (0 up, 0 connecting):
  none

のようにすれば分かります.ちなみに plugin 有効化の設定は,/etc/strongswan.d ディレクトリ以下に各プラグインに対応する設定ファイルが用意されています.あとは公式のドキュメントを参照しながら試行錯誤すれば何とかなるんじゃないかなと思います.

以上!

 

タイトルとURLをコピーしました