Skip to content

Instantly share code, notes, and snippets.

@1271
Created November 6, 2020 17:58
Show Gist options
  • Save 1271/e2d3895124c234caa93d419a97594850 to your computer and use it in GitHub Desktop.
Save 1271/e2d3895124c234caa93d419a97594850 to your computer and use it in GitHub Desktop.
Simple OpenVpn server

Simple OpenVpn server

source

OVPN_DATA="ovpn-data-example-service"
VPN_SERVERNAME="vpn.example.com"
CLIENTNAME="client1"

docker volume create --name $OVPN_DATA

docker run \
    -v $OVPN_DATA:/etc/openvpn \
    --log-driver=none \
    --rm \
    kylemanna/openvpn \
    ovpn_genconfig \
        -u udp://${VPN_SERVERNAME}
        
docker run \
    -v $OVPN_DATA:/etc/openvpn \
    --log-driver=none \
    --rm \
    -it \
    kylemanna/openvpn \
    ovpn_initpki
    
    
docker run \
    -v $OVPN_DATA:/etc/openvpn \
    -d \
    -p 1194:1194/udp \
    --cap-add=NET_ADMIN \
    kylemanna/openvpn
    
    
docker run \
    -v $OVPN_DATA:/etc/openvpn \
    --log-driver=none \
    --rm \
    -it \
    kylemanna/openvpn \
    easyrsa build-client-full $CLIENTNAME nopass
    
    
docker run \
    -v $OVPN_DATA:/etc/openvpn \
    --log-driver=none \
    --rm \
    kylemanna/openvpn \
    ovpn_getclient $CLIENTNAME > ${CLIENTNAME}.ovpn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment