https://makezine.com/projects/browse-an ... or-router/
When I manually setup the routing with the "iptables", it works fine. But after a reboot, things don't work. What I believe is happening is that the routing is being setup before OpenVPN has created the tunnel.
Per the instructions, I've setup automatic iptables at boot (or at least when the networks come up) with iptables-sav and iptables-restore. I've tried this from the /etc/network/interfaces file and tried making a script in /etc/network/if-up.d. Neither work.
But THIS HACK does work: I made a script in /etc/network/if-up.d:
So, basically, I take a long pause (presumably while the tunnel is established) and THEN clear out the iptables, then make the new rules for the router.
Code: Select all
#!/bin/sh sleep 10 iptables -F iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE iptables -A FORWARD -i wlan0 -o tun0 -j ACCEPT iptables -A FORWARD -i tun0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT exit 0
So, something is up here... It seems like I should be able to make the router rules even if the tunnel (tun0) or some other network is not up yet. Or, there should be some way to make the rules only AFTER the tunnel is ready. (That sort of implies a security risk though...)
Any ideas? Thanks!