Skip to content

Commit

Permalink
Merge branch 'AlekseySpiridonov-master-origin'
Browse files Browse the repository at this point in the history
  • Loading branch information
jpetazzo committed Nov 6, 2023
2 parents 6e9c6ea + 06bef41 commit 853e196
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,18 @@ The topology used is `net30`, because it works on the widest range of OS.
`p2p`, for instance, does not work on Windows.

The TCP server uses `192.168.255.0/25` and the UDP server uses
`192.168.255.128/25`.
`192.168.255.128/25`. However, you can change these subnets by
setting the `SUBNET` environment variable. Note that at the moment,
you can only specify the first three octets of the subnet, and
the TCP and UDP servers will use the lower /25 and upper /25
subnets respectively.

For instance, you can do:

```bash
docker run -d --privileged -p 1194:1194/udp -p 443:443/tcp \
-e SUBNET=192.168.13 jpetazzo/dockvpn
```

The client profile specifies `redirect-gateway def1`, meaning that after
establishing the VPN connection, all traffic will go through the VPN.
Expand Down
12 changes: 9 additions & 3 deletions bin/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh

# The subnet can be overridden with an environment variable
VPN_SUBNET="${SUBNET:-192.168.255}"

set -e

[ -d /dev/net ] ||
Expand All @@ -20,7 +24,7 @@ chmod 600 key.pem
openssl x509 -req -in csr.pem -out cert.pem -signkey key.pem -days 24855

[ -f tcp443.conf ] || cat >tcp443.conf <<EOF
server 192.168.255.0 255.255.255.128
server ${VPN_SUBNET}.0 255.255.255.128
verb 3
duplicate-cn
key key.pem
Expand All @@ -40,7 +44,7 @@ status openvpn-status-443.log
EOF

[ -f udp1194.conf ] || cat >udp1194.conf <<EOF
server 192.168.255.128 255.255.255.128
server ${VPN_SUBNET}.128 255.255.255.128
verb 3
duplicate-cn
key key.pem
Expand Down Expand Up @@ -102,7 +106,9 @@ Content-Length: `wc -c client.ovpn`
`cat client.ovpn`
EOF

iptables -t nat -A POSTROUTING -s 192.168.255.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s ${VPN_SUBNET}.0/24 -o eth0 -j MASQUERADE

echo "VPN subnet is ${VPN_SUBNET}.0/24."

touch tcp443.log udp1194.log http8080.log
while true ; do openvpn tcp443.conf ; done >> tcp443.log &
Expand Down

0 comments on commit 853e196

Please sign in to comment.