Skip to content

Commit

Permalink
Merge branch 'master' into add-credentials-commandline
Browse files Browse the repository at this point in the history
  • Loading branch information
StudioEtrange authored Apr 17, 2020
2 parents 0e86745 + 97ae576 commit 5814e93
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Running the following on your docker host should give you the correct network:

**NOTE**: if you don't use the `-v` to configure your VPN, then you'll have to
make sure that `redirect-gateway def1` is set, otherwise routing may not work.
Or you could use -o option to pass it : `-o '--redirect-gateway def1'`

**NOTE 2**: if you have a port you want to make available, you have to add the
docker `-p` option to the VPN container. The network stack will be reused by
Expand All @@ -116,6 +117,10 @@ the second container (that's what `--net=container:vpn` does).
optional arg: [port] to use, instead of default
-m '<mss>' Maximum Segment Size <mss>
required arg: '<mss>'
-o '<args>' Allow to pass any arguments directly to openvpn
required arg: '<args>'
<args> could be any string matching openvpn arguments
i.e '--arg1 value --arg2 value'
-p '<port>[;protocol]' Forward port <port>
required arg: '<port>'
optional arg: [protocol] to use instead of default (tcp)
Expand All @@ -138,16 +143,19 @@ the second container (that's what `--net=container:vpn` does).

ENVIRONMENT VARIABLES

* `CERT_AUTH` - As above, provide authentication to access certificate
* `DNS` - As above, Use the VPN provider's DNS resolvers
* `FIREWALL` - As above, setup firewall to disallow net access w/o the VPN
* `MSS` - As above, set Maximum Segment Size
* `ROUTE6` - As above, add a route to allow replies to your internal network
* `ROUTE` - As above, add a route to allow replies to your private network
* `CERT_AUTH` - As above (-c) provide authentication to access certificate
* `DNS` - As above (-d) use the VPN provider's DNS resolvers
* `FIREWALL` - As above (-f) setup firewall to disallow net access w/o the VPN
* `CIPHER` - Set openvpn cipher option when generating conf file with -v
* `AUTH` - Set openvpn auth option when generating conf file with -v
* `MSS` - As above (-m) set Maximum Segment Size
* `OTHER_ARGS` - As above (-o) pass arguments directly to openvpn
* `ROUTE6` - As above (-R) add a route to allow replies to your private network
* `ROUTE` - As above (-r) add a route to allow replies to your private network
* `TZ` - Set a timezone, IE `EST5EDT`
* `VPN` - As above, setup a VPN connection
* `VPN_AUTH` - As above, provide authentication to vpn server
* `VPNPORT` - As above, setup port forwarding (See NOTE below)
* `VPN` - As above (-v) setup a VPN connection
* `VPN_AUTH` - As above (-a) provide authentication to vpn server
* `VPNPORT` - As above (-p) setup port forwarding (See NOTE below)
* `GROUPID` - Set the GID for the vpn

**NOTE**: optionally supports additional variables starting with the same name,
Expand All @@ -167,6 +175,8 @@ Any of the commands can be run at creation with `docker run` or later with

### VPN configuration

**NOTE**: When using `-v` a vpn configuration is generated.

In order to work you must provide VPN configuration and the certificate. You can
use external storage for `/vpn`:

Expand Down
9 changes: 7 additions & 2 deletions openvpn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ Options (fields in '[]' are optional, '<>' are required):
optional arg: [port] to use, instead of default
-m '<mss>' Maximum Segment Size <mss>
required arg: '<mss>'
-o '<args>' Allow to pass any arguments directly to openvpn
required arg: '<args>'
<args> could be any string matching openvpn arguments
i.e '--arg1 value --arg2 value'
-p '<port>[;protocol]' Forward port <port>
required arg: '<port>'
optional arg: [protocol] to use instead of default (tcp)
Expand Down Expand Up @@ -287,7 +291,7 @@ while read i; do
eval vpnportforward $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $i)
done < <(env | awk '/^VPNPORT[0-9=_]/ {sub (/^[^=]*=/, "", $0); print}')

while getopts ":hc:df:a:m:p:R:r:v:" opt; do
while getopts ":hc:df:a:m:o:p:R:r:v:" opt; do
case "$opt" in
h) usage ;;
a) eval vpn_auth $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $OPTARG)
Expand All @@ -296,6 +300,7 @@ while getopts ":hc:df:a:m:p:R:r:v:" opt; do
d) dns ;;
f) firewall "$OPTARG"; touch $route $route6 ;;
m) MSS="$OPTARG" ;;
o) OTHER_ARGS="$OPTARG" ;;
p) eval vpnportforward $(sed 's/^/"/; s/$/"/; s/;/" "/g' <<< $OPTARG) ;;
R) return_route6 "$OPTARG" ;;
r) return_route "$OPTARG" ;;
Expand All @@ -320,5 +325,5 @@ else
[[ -e $cert ]] || grep -Eq '^ *(<ca>|ca +)' $conf ||
{ echo "ERROR: VPN CA cert missing!"; sleep 120; }
exec sg vpn -c "openvpn --cd $dir --config $conf ${AUTH_COMMAND:-} \
${MSS:+--fragment $MSS --mssfix}"
${OTHER_ARGS:-} ${MSS:+--fragment $MSS --mssfix}"
fi

0 comments on commit 5814e93

Please sign in to comment.