A Docker container that dials a PPTP VPN and exposes a SOCKS5 proxy (via Dante). Anything that talks to the proxy egresses through the VPN tunnel.
client ──SOCKS5──▶ dante (in container) ──default route──▶ ppp0 ──GRE/PPTP──▶ VPN server ──▶ internet
Linux Docker hosts only. PPTP's data channel is GRE (IP proto 47), which Docker Desktop for Mac/Windows does not forward — the tunnel never comes up. Details below.
- A real Linux Docker host (bare metal or a VM with a bridged NIC).
/dev/pppand thenf_conntrack_pptp,nf_nat_pptp,ppp_mppekernel modules on the host (all standard in-tree modules —firewall.shloads them).- The container runs
--privileged(pppd needs to createppp0). - Some host-side netfilter setup —
firewall.sh, see below.
PPTP's data channel is GRE (IP protocol 47). Docker Desktop routes container
traffic through a userspace proxy that only forwards TCP/UDP. The PPTP control
channel connects, but GRE never passes (decaps_gre: Protocol not available),
so the tunnel never comes up. Use a real Linux host — build the image there, or
point docker context / DOCKER_HOST at it from your workstation.
cp .env.example .env
$EDITOR .env # set VPN_SERVER / VPN_USER / VPN_PASS
set -a; . ./.env; set +a # load .env into this shell
sudo -E ./firewall.sh # host netfilter (see "Host firewall" below)
docker compose up -d --build
Verify:
docker compose logs -f
curl -x socks5h://127.0.0.1:1080 https://ipinfo.io/ip # should show the VPN exit IP
socks5h (not socks5) makes the client resolve DNS through the proxy too.
One file, .env (compose reads it; firewall.sh reads it when you source it):
| Var | Default | |
|---|---|---|
VPN_SERVER |
— | required — PPTP server hostname or IP |
VPN_USER |
— | required |
VPN_PASS |
— | required |
SOCKS_PORT |
1080 |
SOCKS5 listen / publish port |
DOCKER_SUBNET |
172.17.0.0/16 |
firewall.sh only — your docker bridge subnet |
PROXY_ALLOW_IP |
(empty) | firewall.sh only — space-separated source-IP allowlist for the SOCKS port; empty leaves it open |
Credentials are not baked into the image; entrypoint.sh exits if any of
VPN_SERVER / VPN_USER / VPN_PASS is unset.
firewall.sh applies (idempotently) the netfilter rules the container needs.
Nothing it does touches the host IP, routes, /etc/netplan/*, or DNS.
-
PPTP behind Docker NAT. PPTP carries data over GRE (proto 47) and both peers pick call IDs independently, so plain conntrack can't match the server's GRE replies back to the outbound flow — the packets get dropped. The script attaches the in-kernel PPTP ALG to the control channel (port 1723) so it learns the call-ID mapping, and adds
DOCKER-USERrules letting GRE forward between the NIC anddocker0(needed when the host drops forwarded traffic by default, e.g.ufw). -
SOCKS port source allowlist (optional). Docker's published ports bypass
ufw, so any allowlist has to live inDOCKER-USER. SetPROXY_ALLOW_IPand the script adds an ACCEPT per IP plus a DROP for everyone else. Empty (the default) leaves the port open to anything that can route to the host.
These are runtime rules, not saved to iptables-persistent. Docker rebuilds
the DOCKER-USER chain on every daemon restart, wiping rules 1b/2, so re-run
firewall.sh after systemctl restart docker or a reboot.
pptp-proxy-firewall.service re-applies the rules on boot and whenever Docker
restarts:
printf 'VPN_SERVER=vpn.example.com\nSOCKS_PORT=1080\nPROXY_ALLOW_IP=\n' | sudo tee /etc/pptp-proxy.env
sudo install -m744 firewall.sh /usr/local/sbin/pptp-proxy-firewall.sh
sudo install -m644 pptp-proxy-firewall.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now pptp-proxy-firewall.service
sudo systemctl disable --now pptp-proxy-firewall.service # if installed
sudo rm -f /etc/systemd/system/pptp-proxy-firewall.service \
/usr/local/sbin/pptp-proxy-firewall.sh /etc/pptp-proxy.env
sudo systemctl daemon-reload
sudo iptables -t raw -D PREROUTING -i docker0 -p tcp -d "$VPN_SERVER" --dport 1723 -j CT --helper pptp
sudo iptables -D DOCKER-USER -p 47 -s 172.17.0.0/16 -j ACCEPT
sudo iptables -D DOCKER-USER -p 47 -d 172.17.0.0/16 -j ACCEPT
Or just reboot after disabling the unit — the rules are not persisted.
- The proxy has no authentication. Anything that can reach the published
port can use it and its VPN exit. Restrict it with
PROXY_ALLOW_IP(above) and/or add SOCKS auth: setsocksmethod: usernameinentrypoint.sh's generateddanted.confand create a system user for it in theDockerfile. - PPTP/MPPE is cryptographically weak (MS-CHAPv2 + RC4). Anyone who can capture the traffic between the host and the VPN server can potentially break it. Don't treat the tunnel as confidential.
- If
pppdordanteddies the container exits;restart: unless-stoppedbrings it back, and theip-uphook re-establishes routing on every (re)connect.
| Path | Purpose |
|---|---|
Dockerfile |
Debian + pptp-linux + dante-server |
entrypoint.sh |
dials PPTP, waits for ppp0, moves the default route onto the tunnel, policy-routes inbound-connection replies back out the bridge, writes danted.conf, runs Dante, supervises both |
compose.yml |
run it with docker compose |
.env.example |
config template |
firewall.sh |
idempotent host netfilter the container needs |
pptp-proxy-firewall.service |
systemd unit that re-applies it on boot / docker restart |