Since Ubuntu 10.04 LTS (Lucid) and Debian 6.0 (Squeeze) there is a package with the name “iptables-persistent” which takes over the automatic loading of the saved iptables rules. To do this, the rules must be saved in the file /etc/iptables/rules.v4 for IPv4 and /etc/iptables/rules.v6 for IPv6.
To install simply run:
apt-get install iptables-persistent
It will ask if you if you’d like to save your current rules to the /etc/iptables/rules.v4 file. You might as well say yes, and then modify that file if you need to.
Make sure to reboot to test to ensure your rules are correctly loaded upon reboot.