搭建IPSec服务
by Randall · 14 Jan 2026·vpn / tutorial
← /u/randall/blog
by Randall · 14 Jan 2026·vpn / tutorial
wget https://get.vpnsetup.net -O vpn.sh && sudo sh vpn.sh
wget https://get.vpnsetup.net -O vpn.sh
nano -w vpn.sh
[替换为你自己的值: YOUR_IPSEC_PSK, YOUR_USERNAME 和 YOUR_PASSWORD]
sudo sh vpn.sh
# 所有变量值必须用 '单引号' 括起来
# *不要* 在值中使用这些字符: \ " '
/etc/ipsec/ipsec.env#VPN_IPSEC_PSK=your_ipsec_pre_shared_key
VPN_USER=your_vpn_username
VPN_PASSWORD=your_vpn_password
## 多用户(空格隔开)
VPN_ADDL_USERS=xxxx1 xxxxx2
VPN_ADDL_PASSWORDS=xxxx1 xxxxx2
## 默认的是谷歌的DNS
VPN_DNS_SRV1=8.8.8.8
VPN_DNS_SRV2=8.8.4.4
mkdir -p /data/ikev2-vpn-data
docker run --name ipsec-vpn-server --env-file /etc/ipsec/ipsec.env --restart=always -v /data/ikev2-vpn-data:/etc/ipsec.d
最少需要放行500和4500端口的UDP数据包
控制面板设置属性——安全——允许使用这些协议
管理员终端运行:
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PolicyAgent" /v AssumeUDPEncapsulationContextOnSendRule /t REG_DWORD /d 2 /f
重启电脑后生效
改用IKEv2登录,下载strongswan后导入后缀.sswan的配置文件
Android配置文件:http://startpage.zhuanjie.ltd/download/vpn/vpnclient.sswan
Windows & Linux配置文件:http://startpage.zhuanjie.ltd/download/vpn/vpnclient.p12
iOS & macOS配置文件:http://startpage.zhuanjie.ltd/download/vpn/vpnclient.mobileconfig