hwdsl2 / docker-ipsec-vpn-server
- вторник, 24 мая 2016 г. в 03:12:03
Shell
IPsec VPN server on Docker, with both IPsec/L2TP and Cisco IPsec
Set up your own IPsec VPN server on Docker, with support for both IPsec/L2TP
and IPsec/XAuth ("Cisco IPsec")
.
Based on Debian Jessie with Libreswan (IPsec VPN software) and xl2tpd (L2TP daemon).
Available on Docker Hub.
docker pull hwdsl2/ipsec-vpn-server
This Docker image uses the following three environment variables, that can be declared in an env
file:
VPN_IPSEC_PSK=<IPsec pre-shared key>
VPN_USER=<VPN Username>
VPN_PASSWORD=<VPN Password>
This will create a single user account for VPN login. The IPsec PSK (pre-shared key) is specified by the VPN_IPSEC_PSK
environment variable. The VPN username is defined in VPN_USER
, and VPN password is specified by VPN_PASSWORD
.
Note: In your env
file, DO NOT put single or double quotes around values, or add space around =
.
All the variables to this image are optional, which means you don't have to type in any environment variables, and you can have an IPsec VPN server out of the box! Read the sections below for details.
First, run sudo modprobe af_key
on the host to load the IPsec NETKEY
kernel module.
Start your Docker container with the following command (replace ./vpn.env
with your own env
file) :
docker run \
--name docker-ipsec-vpn-server \
--env-file ./vpn.env \
-p 500:500/udp \
-p 4500:4500/udp \
-v /lib/modules:/lib/modules:ro \
-d --privileged \
hwdsl2/ipsec-vpn-server
If you did not set environment variables via an env
file, VPN_USER
will default to vpnuser
and both VPN_IPSEC_PSK
and VPN_PASSWORD
will be randomly generated. To retrieve them, show the logs of the running container:
docker logs docker-ipsec-vpn-server
Search for these lines in the output:
Connect to your new VPN with these details:
Server IP: <VPN Server IP>
IPsec PSK: <IPsec pre-shared key>
Username: <VPN Username>
Password: <VPN Password>
To check the status of your IPsec VPN server, you can pass ipsec status
to your container like this :
docker exec -it docker-ipsec-vpn-server ipsec status
Get your computer or device to use the VPN. Please refer to:
Configure IPsec/L2TP VPN Clients
Configure IPsec/XAuth VPN Clients
Enjoy your very own VPN!
There are two services running: Libreswan (pluto)
for the IPsec VPN, and xl2tpd
for L2TP support.
The default IPsec configuration supports:
The ports that are exposed for this container to work are:
Copyright (C) 2016 Lin Song
Based on the work of Thomas Sarlandie (Copyright 2012)
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License
Attribution required: please include my name in any derivative and let me know how you have improved it!