Armbian使用Docker安装IPsec VPN 服务器
项目地址:https://github.com/hwdsl2/setup-ipsec-vpn
首先获取镜像
docker pull hwdsl2/ipsec-vpn-server
创建配置文件config.env
# Note: All the variables to this image are optional.
# See README for more information.
# To use, uncomment and replace with your own values.
# Define IPsec PSK, VPN username and password
# - DO NOT put "" or '' around values, or add space around =
# - DO NOT use these special characters within values: \ " '
VPN_IPSEC_PSK=密钥
VPN_USER=账号
VPN_PASSWORD=密码
# Define additional VPN users
# - DO NOT put "" or '' around values, or add space around =
# - DO NOT use these special characters within values: \ " '
# - Usernames and passwords must be separated by spaces
# VPN_ADDL_USERS=additional_username_1 additional_username_2
# VPN_ADDL_PASSWORDS=additional_password_1 additional_password_2
# Use a DNS name for the VPN server
# - The DNS name must be a fully qualified domain name (FQDN)
# VPN_DNS_NAME=vpn.example.com
# Specify a name for the first IKEv2 client
# - Use one word only, no special characters except '-' and '_'
# - The default is 'vpnclient' if not specified
# VPN_CLIENT_NAME=your_client_name
# Use alternative DNS servers
# - By default, clients are set to use Google Public DNS
# - Example below shows Cloudflare's DNS service
# VPN_DNS_SRV1=1.1.1.1
# VPN_DNS_SRV2=1.0.0.1
# Protect IKEv2 client config files using a password
# - By default, no password is required when importing IKEv2 client configuration
# - Uncomment if you want to protect these files using a random password
# VPN_PROTECT_CONFIG=yes
运行镜像
docker run -d \
-p 500:500/udp \
-p 4500:4500/udp \
--privileged=true \ # 特权模式运行
--restart=always \ # 开启自启动
--name ipsec-vpn-server \
--env-file /home/iuu/Software/Docker/ipsec-vpn-server/config.env \ # 加载配置文件
-v /home/iuu/Software/Docker/ipsec-vpn-server/ikev2-vpn-data:/etc/ipsec.d \
-v /lib/modules:/lib/modules:ro \ # 挂载运行库目录 但是只有只读权限
hwdsl2/ipsec-vpn-server
启动容器后查看容器状态
防火墙开4500 500 UDP端口
如果是内网穿透,路由器也得做对应的端口转发