GithubHelp home page GithubHelp logo

yanghongchen / l2tp-ipsec-vpn-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fcojean/l2tp-ipsec-vpn-server

0.0 0.0 0.0 43 KB

Docker image to run an IPsec VPN server, with IPsec/L2TP and Cisco IPsec

Home Page: https://hub.docker.com/r/hwdsl2/ipsec-vpn-server

License: Other

Shell 86.99% Dockerfile 13.01%

l2tp-ipsec-vpn-server's Introduction

IPsec VPN Server on Docker

Docker Stars Docker Pulls

Docker image to run an IPsec VPN server, with support for both IPsec/L2TP and IPsec/XAuth ("Cisco IPsec").

Based on Debian Jessie with Libreswan (IPsec VPN software) and xl2tpd (L2TP daemon).

This docker image is based on Lin Song work and adds those features:

  • Multiple VPN users declaration support
  • Native NAT Transversal support
  • No waiting time before a user can reconnect in case of disconnection support
  • Custom network interface support

Install Docker

Follow these instructions to get Docker running on your server.

Download

Get the trusted build from the Docker Hub registry:

docker pull fcojean/l2tp-ipsec-vpn-server

or download and compile the source yourself from GitHub:

git clone https://github.com/fcojean/l2tp-ipsec-vpn-server.git
cd l2tp-ipsec-vpn-server
docker build -t fcojean/l2tp-ipsec-vpn-server .

How to use this image

Environment variables

This Docker image uses the following two environment variables, that can be declared in an env file (see vpn.env.example file):

VPN_IPSEC_PSK=<IPsec pre-shared key>
VPN_USER_CREDENTIAL_LIST=[{"login":"userTest1","password":"test1"},{"login":"userTest2","password":"test2"}]
VPN_NETWORK_INTERFACE=eth0
  • VPN_IPSEC_PSK : The IPsec PSK (pre-shared key).
  • VPN_USER_CREDENTIAL_LIST : Multiple users VPN credentials list. Users login and password must be defined in a json format array. Each user should be define with a "login" and a "password" attribute.
  • VPN_NETWORK_INTERFACE : The network interface name (eth0 by default).

Note: In your env file, DO NOT put single or double quotes around values, or add space around =. Also, DO NOT use these characters within values: \ " '

All the variables to this image are optional, which means you don't have to type in any environment variable, and you can have an IPsec VPN server out of the box! Read the sections below for details.

Start the IPsec VPN server

VERY IMPORTANT ! First, run this command on the Docker host to load the IPsec NETKEY kernel module:

sudo modprobe af_key

Start a new Docker container with the following command (replace ./vpn.env with your own env file) :

docker run \
    --name l2tp-ipsec-vpn-server \
    --env-file ./vpn.env \
    -p 500:500/udp \
    -p 4500:4500/udp \
    -v /lib/modules:/lib/modules:ro \
    -d --privileged \
    fcojean/l2tp-ipsec-vpn-server

Retrieve VPN login details

If you did not set environment variables via an env file, a vpn user login will default to vpnuser and both VPN_IPSEC_PSK and vpn user password will be randomly generated. To retrieve them, show the logs of the running container:

docker logs l2tp-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>
Users credentials :
Login : <vpn user_login_1> Password : <vpn user_password_1>
...
Login : <vpn user_login_N> Password : <vpn user_password_N>

Check server status

To check the status of your IPsec VPN server, you can pass ipsec status to your container like this:

docker exec -it l2tp-ipsec-vpn-server ipsec status

Scaleway user information

Scaleway © use own modified kernel version 4.4 by default. This kernel isn't compatible with IPsec. If you want to use IPsec VPN server on Scaleway © VPS you should switch version of kernel (version 4.8 or higher).

Next Steps

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! ✨🎉🚀✨

Technical Details

There are two services running: Libreswan (pluto) for the IPsec VPN, and xl2tpd for L2TP support.

Clients are configured to use Google Public DNS when the VPN connection is active.

The default IPsec configuration supports:

  • IKEv1 with PSK and XAuth ("Cisco IPsec")
  • IPsec/L2TP with PSK

The ports that are exposed for this container to work are:

  • 4500/udp and 500/udp for IPsec

Author

Copyright (C) 2016 François COJEAN

License

Based on the work of Lin Song (Copyright 2016)
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 !

l2tp-ipsec-vpn-server's People

Contributors

hwdsl2 avatar fcojean avatar kirill-zak avatar jasonkoon avatar yangzhangling avatar 1allen avatar emirati avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.