This question already has an answer here:
- iptables resets when server reboots 2 answers
I create the rules to iptables. But, when I restart the computer, the rules don't work! How to save the rules on Ubuntu ?
The was problem solved!
After of the write the commands iptables, do:
1. sudo su 2. iptables-save > /etc/iptables.rules 3. In /etc/network/if-pre-up.d/iptables,put: #!/bin/sh iptables-restore < /etc/iptables.rules exit 0 4. After, in /etc/network/if-post-down.d/iptables,put: #!/bin/sh iptables-save -c > /etc/iptables.rules if [ -f /etc/iptables.rules ]; then iptables-restore < /etc/iptables.rules fi exit 0 5. After, give permission to the scripts: sudo chmod +x /etc/network/if-post-down.d/iptables sudo chmod +x /etc/network/if-pre-up.d/iptables
More information: https://help.ubuntu.com/community/IptablesHowTo#Saving_iptables Good luck!