L2TP-IPsec (VPN)搭建
系统版本:Centos 7.6 AlibabaCloud
下载 docker 及 镜像
1 2 3 4 5 6 7 8 9 10 11
| # 添加 docker yum 源 curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装 docker yum install -y docker-ce-cli-19.03.9-3.el7 docker-ce-19.03.9-3.el7
# 下载镜像 docker pull hwdsl2/ipsec-vpn-server # 上面的镜像源在 docker hub,如果很慢可以从 Quay.io 下载: docker pull quay.io/hwdsl2/ipsec-vpn-server docker image tag quay.io/hwdsl2/ipsec-vpn-server hwdsl2/ipsec-vpn-server
|
配置环境变量
1 2 3 4 5 6 7 8 9
| vim vpn.env
VPN_IPSEC_PSK=your_ipsec_pre_shared_key VPN_USER=your_vpn_username VPN_PASSWORD=your_vpn_password
# 添加用户 VPN_ADDL_USERS=additional_username_1 additional_username_2 VPN_ADDL_PASSWORDS=additional_password_1 additional_password_2
|
启动 IPsec VPN服务器
1 2 3 4 5 6 7 8 9 10
| docker run \ --name ipsec-vpn-server \ --env-file ./vpn.env \ --restart=always \ -v ikev2-vpn-data:/etc/ipsec.d \ -v /lib/modules:/lib/modules:ro \ -p 500:500/udp \ -p 4500:4500/udp \ -d --privileged \ hwdsl2/ipsec-vpn-server
|
检查 VPN 登录详细信息
1 2 3 4 5 6 7 8 9
| docker logs ipsec-vpn-server
# 可以看到如下登录内容 Connect to your new VPN with these details:
Server IP: your_vpn_server_ip IPsec PSK: your_ipsec_pre_shared_key Username: your_vpn_username Password: your_vpn_password
|