iptables-save > /etc/iptables/rules.v4
# Debian and Ubuntu: restores them before the interfaces come up
apt-get install -y iptables-persistent
# by hand instead, as a line in /etc/network/interfaces:
# pre-up iptables-restore < /etc/iptables/rules.v4