Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable routes for PPTP client #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pptp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ pptp:
- TUNNEL=vps
- USERNAME=username
- PASSWORD=password
- ROUTES=0.0.0.0/1 128.0.0.0/1
net: host
privileged: yes
restart: unless-stopped
```

## available parameters (passed as environment variables)

* `SERVER`: IP or hostname of the VPN server
* `TUNNEL`: name of the tunnel
* `USERNAME` / `PASSWORD`: auth info for the server
* `ROUTES`: space separated list of routes that should be routed through the VPN. By default all traffic is routed

## up and running

```
Expand Down
20 changes: 10 additions & 10 deletions pptp/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

ROUTES=${ROUTES:-0.0.0.0/1 128.0.0.0/1}

cat > /etc/ppp/peers/${TUNNEL} <<_EOF_
pty "pptp ${SERVER} --nolaunchpppd"
name "${USERNAME}"
Expand All @@ -10,16 +12,14 @@ file /etc/ppp/options.pptp
ipparam "${TUNNEL}"
_EOF_

cat > /etc/ppp/ip-up <<"_EOF_"
#!/bin/sh
ip route add 0.0.0.0/1 dev $1
ip route add 128.0.0.0/1 dev $1
_EOF_
echo "#!/bin/sh" > /etc/ppp/ip-up
for route in $ROUTES; do
echo "ip route add ${route} dev \$1" >> /etc/ppp/ip-up
done

cat > /etc/ppp/ip-down <<"_EOF_"
#!/bin/sh
ip route del 0.0.0.0/1 dev $1
ip route del 128.0.0.0/1 dev $1
_EOF_
echo "#!/bin/sh" > /etc/ppp/ip-down
for route in $ROUTES; do
echo "ip route del ${route} dev \$1" >> /etc/ppp/ip-down
done

exec pon ${TUNNEL} debug dump logfd 2 nodetach persist "$@"