open or create iptables script
# vim /etc/network/if-post-down.d/iptableswrite these lines
#!/bin/bash
iptables-save > /etc/iptables.rules
save and make it executeable
# chmod +x /etc/network/if-post-down.d/iptablesopen or create file
# vim /etc/network/if-pre-up.d/iptablessave these lines
#!/bin/bash
iptables-restore < /etc/iptables.rules
make it executable as well
# chmod +x /etc/network/if-pre-up.d/iptables