Coder Social home page Coder Social logo

docker-openvpn's Introduction

Customized OpenVPN for Docker for Mac

OpenVPN server in a Docker container complete with an EasyRSA PKI CA. This docker is creating a VPN network between Docker For Mac containers and the host mac itself. It allows you to communicate directly to services running as docker containers running on IPs 172.17.0.0/16.

Quick Start

  • Initialize the ovpn-data container that will hold the configuration files and certificates

      docker volume create --name ovpn-data
      docker run -v ovpn-data:/etc/openvpn --rm luman75/docker-mac-openvpn:3.4.0 ovpn_genconfig -u udp://localhost
    
  • Create CA

You will be asked for password to CA please set something longer then 4 characters and remember it for the next commands

    docker run -v ovpn-data:/etc/openvpn --rm -it luman75/docker-mac-openvpn:3.4.0 ovpn_initpki
  • Start OpenVPN server process

      docker run -v ovpn-data:/etc/openvpn --name docker-mac-openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN luman75/docker-mac-openvpn:3.4.0
    
  • Generate a client certificate without a passphrase

      docker run -v ovpn-data:/etc/openvpn --rm -it luman75/docker-mac-openvpn:3.4.0 easyrsa build-client-full DockerForMac nopass
    
  • Retrieve the client configuration with embedded certificates

      docker run -v ovpn-data:/etc/openvpn --rm luman75/docker-mac-openvpn:3.4.0 ovpn_getclient DockerForMac > DockerForMac.ovpn
    
  • Install OpenVPN Configuration You need to have Tunnelblink installed in your system [https://tunnelblick.net/downloads.html]. Then just run command

      open DockerForMac.ovpn
    

After you that you will have configured Tunnelblink to communicate with your Docker for Mac environment.

How Does It Work?

Initialize the volume container using the luman75/docker-mac-openvpn:3.4.0 image with the included scripts to automatically generate:

  • Diffie-Hellman parameters
  • a private key
  • a self-certificate matching the private key for the OpenVPN server
  • an EasyRSA CA key and certificate
  • a TLS auth key from HMAC security

The OpenVPN server is started with the default run cmd of ovpn_run

The configuration is located in /etc/openvpn, and the Dockerfile declares that directory as a volume. It means that you can start another container with the -v argument, and access the configuration. The volume also holds the PKI keys and certs so that it could be backed up.

To generate a client certificate, luman75/docker-mac-openvpn:3.4.0 uses EasyRSA via the easyrsa command in the container's path. The EASYRSA_* environmental variables place the PKI CA under /etc/openvpn/pki.

Conveniently, luman75/docker-mac-openvpn:3.4.0 comes with a script called ovpn_getclient, which dumps an inline OpenVPN client configuration file. This single file can then be given to a client for access to the VPN.

To enable Two Factor Authentication for clients (a.k.a. OTP) see this document.

Differences from kylemanna/docker-openvpn

  • No logger generate any push for DNS. We assume it should be the same as the dns in OS
  • Push routing to "route 172.17.0.0 255.255.0.0" making routing to internal docker networks
  • There is no "redirect-gateway def1" generated in xx.ovpn so no default route

docker-openvpn's People

Contributors

aviau avatar bambooonedata avatar caerbannog avatar croepha avatar ctawfik avatar dave-burke avatar fabn avatar flecno avatar jpetazzo avatar justone avatar kylemanna avatar maxromanovsky avatar myplacedk avatar nui avatar omriiluz avatar paimpozhil avatar pushrax avatar rgarrigue avatar rudijs avatar ryansch avatar slamont avatar thenotary avatar thomastweets avatar tilosp avatar tuinslak avatar vielmetti avatar wernerb avatar yanndegat avatar ypid avatar zackadams avatar

Watchers

 avatar  avatar

Forkers

onedata

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.