I'm trying to make NAT routing persistent on my Ubuntu 12.04 EC2 instance (for OpenVPN; currently I need to run it every time after boot):
ubuntu@vpn:~$ cat /etc/network/if-up.d/vpn-routing
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
But it's not working:
ubuntu@vpn:~$ sudo iptables -t nat -L POSTROUTING
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Any ideas why? Does it matter that I have ufw
enabled? I didn't see anything interesting/relevant in syslog (though I wasn't sure what to look for). Thanks in advance.
I think it's because the file doesn't have a shebang line. It should be something like:
Also make sure the file has execution permission:
I've had trouble with this myself. One handy way of debugging is to enable the logfile for ppp... sudo touch /var/log/ppp-ipupdown.log
then when I bring up a ppp session I can see how my script is behaving.