In this post, I’ll set up and run a temporary VPN server using docker on Azure, it’s an L2TP type VPN, I’m not gonna recommend using this type VPN for your production environment or at work as it is unsafe.
Environment:
CentOS: 7.5 x64
Docker: 19.03.5
Install Docker
Set up the repository
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
$ sudo yum install docker-ce docker-ce-cli containerd.io
Start docker & Check docker version
$ sudo systemctl start docker
$ sudo docker version
Pull VPN image from Docker Hub
$sudo docker pull fcojean/l2tp-ipsec-vpn-server
Declare secret, username and password in vpn.env file.
VPN_IPSEC_PSK=Marvel
VPN_USER=avengers
VPN_PASSWORD=assemble
if you have multiple users, you can declare variables in your vpn.env file.
VPN_IPSEC_PSK=<IPsec pre-shared key>
VPN_USER_CREDENTIAL_LIST=[{"login":"userTest1","password":"test1"},{"login":"userTest2","password":"test2"}]
VPN_NETWORK_INTERFACE=eth0
Start VPN server
$ docker run \
--name ipsec-vpn-server \
--env-file ./vpn.env \
--restart=always \
-p 500:500/udp \
-p 4500:4500/udp \
-d --privileged \
fcojean/ipsec-vpn-server
Check VPN status
$ docker exec -it ipsec-vpn-server ipsec status
To allow the public connection, open port 1701/500/4500 on Azure