8000 GitHub - mdminhazulhaque/pptp-proxy: 🔒 PPTP VPN client with SOCKS5 proxy egress · GitHub
[go: up one dir, main page]

Skip to content

About

🔒 PPTP VPN client with SOCKS5 proxy egress

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

pptp-proxy

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.

Requirements

  • A real Linux Docker host (bare metal or a VM with a bridged NIC).
  • /dev/ppp and the nf_conntrack_pptp, nf_nat_pptp, ppp_mppe kernel modules on the host (all standard in-tree modules — firewall.sh loads them).
  • The container runs --privileged (pppd needs to create ppp0).
  • Some host-side netfilter setup — firewall.sh, see below.

Why it does not work on Docker Desktop for Mac/Windows

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.

Quick start

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.

Configuration

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.

Host firewall

firewall.sh applies (idempotently) the netfilter rules the container needs. Nothing it does touches the host IP, routes, /etc/netplan/*, or DNS.

  1. 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-USER rules letting GRE forward between the NIC and docker0 (needed when the host drops forwarded traffic by default, e.g. ufw).

  2. SOCKS port source allowlist (optional). Docker's published ports bypass ufw, so any allowlist has to live in DOCKER-USER. Set PROXY_ALLOW_IP and 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.

Persisting it (optional systemd unit)

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

Undo

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.

Security

  • 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: set socksmethod: username in entrypoint.sh's generated danted.conf and create a system user for it in the Dockerfile.
  • 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 pppd or danted dies the container exits; restart: unless-stopped brings it back, and the ip-up hook re-establishes routing on every (re)connect.

Files

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

About

🔒 PPTP VPN client with SOCKS5 proxy egress

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0