there is a package named “iptables-persistent” that will automatically load firewall rules on startup, these rules must be saved in a File, /etc/iptables/rules.v4 for IPv4 and /etc/iptables/rules.v6 for IPv6.
Installation
apt-get install iptables-persistent
if the installation fails, check if there systemd had failures before installation of iptables-persistent, systemd error can cause the installation of iptables-persistent to fail
Usage
iptables-save > /etc/iptables/rules.v4
save rules, these will automatically be loaded at boot next time
iptables-restore > /etc/iptables/rules.v4
restore/load previously saved rules