WPAD on OpenWRT with SSH tunnel
- Create your PAC file, for example
-
SCP the PAC file to root@openwrt:/www/wpad.dat
-
Go to Luci -> Network -> Hostnames and add wpad as an alias for your OpenWRT router’s IP
-
Install the autossh software package through opkg
-
SSH to the router and edit /etc/config/autossh
-
Use dropbearkey to create an SSH keypair, save the private key in /root/.ssh/id_rsa
-
Append the newly created public key to your server’s ~/.ssh/authorized_keys
-
Enable and start the autossh service through Luci
You can test your setup with curl:
This will have created an SSH tunnel from your router to your remote server, reconnecting as soon as a disconnect happens. Clients on your network will route traffic through the proxy, as determined by your logic in the PAC file. Windows clients use WPAD by default, but for OSX clients this has to be explicitly enabled in Network Settings.