第一步、服务端配置
部分仅记录与我们环境相关的服务端部署过程,参考官方文档获取相关细节。
https://docs.netgate.com/pfsense/en/latest/recipes/ipsec-mobile-ikev2-eap-mschapv2.html
IKEv2 Certificate Structure
我们使用 ACME Package | https://docs.netgate.com/pfsense/en/latest/packages/acme/index.html 来创建证书,所以不需要单独创建 CA 及 Certificate 信息。
Mobile Client Settings
按照官方文档提示进行操作即可。该部分的难点在于针对各种客户端(Windows Linux macOS Android iOS)进行 Phase 1 及 Phase 2 的配置。
Mobile IPsec User Creation
按照官方文档提示进行操作即可。
Q:如何通过 LDAP 进行认证?
A:EAP-MSCHAPv2 will not work with LDAP. In essence, your client sends over an MD4 hash of your password, not the actual password itself. See “The Protocol” section: https://www.cloudcracker.com/blog/2012/07/29/cracking-ms-chap-v2/ . LDAP expects a clear-text username and password to look-up, which EAP-MSCHAPv2 cannot provide. EAP-Radius should allow us to authenticate against a Windows NPS server, which is able to perform a hash look-up directly on AD. We already do this on our network for Wi-Fi where we use PEAP-EAP-MSCHAPv2. It appears NPS can also do EAP-MSCHAPv2 directly avoiding the redundant TLS tunnel.
R:https://forum.netgate.com/topic/81377/ikev2-and-active-directory/5
Firewall Rules
按照官方文档提示进行操作即可。
当配置规则时,需要注意网络协议的复杂性,Protocol、Source、Destination、……,都需要正确配置。
第二步、客户端配置
Client Configuration | https://docs.netgate.com/pfsense/en/latest/recipes/ipsec-mobile-ikev2-eap-mschapv2.html#client-configuration
- Windows | https://docs.netgate.com/pfsense/en/latest/recipes/ipsec-mobile-ikev2-client-windows.html
- Ubuntu | https://docs.netgate.com/pfsense/en/latest/recipes/ipsec-mobile-ikev2-client-ubuntu.html
注意 ⚠️ 通常根据官方文档进行配置即可,但是针对特定环境可能存在差异。
Windows 10
针对 Windows 10 系统,配置并不复杂。针对我们的环境,创建 VPN 连接,填写相关信息即可。
官方示例使用自签 CA 及 Certificate 信息,但是我们使用 ACME 证书,所以不需要导入 CA 及 Certificate 信息。
Ubuntu 24.10
https://willbradley.name/connecting-to-ikev2-with-eap-mschapv2-on-ubuntu-24-04
- 依赖安装:apt install network-manager-strongswan libstrongswan-standard-plugins libstrongswan-extra-plugins libcharon-extra-plugins
Q:Local routing loop detected
A:https://github.com/strongswan/strongswan/issues/2230
S:首先,卸载 network-manager-l2tp 组件,以解决循环依赖问题,否则卸载 strongswan-starter 会导致 network-manager-strongswan 被卸载。卸载 strongswan-starter、charon-systemd 组件。
N:注意,由于卸载 network-manager-l2tp 组件,如此以来便无法使用 L2TP VPN 客户端。
排查方法
Wireshark 抓包
pfSense / Status / System Logs
查看当前登陆用户:Status IPsec Overview
ip route get 8.8.8.8
dmest -w
journalctl -f -u NetworkManager
tail -f /var/log/syslog
已知问题
Invalid payload received
问题
分析
- ESP:AES_CBC_256/HMAC_SHA1_96/NO_EXT_SEQ,
- ESP:AES_CBC_128/HMAC_SHA1_96/NO_EXT_SEQ,
- ESP:3DES_CBC/HMAC_SHA1_96/NO_EXT_SEQ,
- ESP:DES_CBC/HMAC_SHA1_96/NO_EXT_SEQ,
- ESP:NULL/HMAC_SHA1_96/NO_EXT_SEQ
方案
参考
Unsuccessful, Not secure
- IKE:AES_CTR_256/AES_CBC_256/AES_CTR_192/AES_CBC_192/AES_CTR_128/AES_CBC_128/HMAC_SHA2_512_256/HMAC_SHA2_384_192/HMAC_SHA2_256_128/AES_XCBC_96/AES_CMAC_96/PRF_HMAC_SHA1/PRF_AES128_XCBC/PRF_HMAC_SHA2_256/PRF_HMAC_SHA2_384/PRF_HMAC_SHA2_512/PRF_AES128_CMAC/MODP_4096/CURVE_25519/MODP_3072/MODP_2048,
- IKE:CHACHA20_POLY1305/AES_GCM_16_256/AES_GCM_12_256/AES_GCM_8_256/AES_GCM_16_192/AES_GCM_12_192/AES_GCM_8_192/AES_GCM_16_128/AES_GCM_12_128/AES_GCM_8_128/PRF_HMAC_SHA1/PRF_AES128_XCBC/PRF_HMAC_SHA2_256/PRF_HMAC_SHA2_384/PRF_HMAC_SHA2_512/PRF_AES128_CMAC/MODP_4096/CURVE_25519/MODP_3072/MODP_2048
MODP 14 2048
SHA1
# 04/27/2025 未解决