There is no iptables service avilable in Ubuntu like service iptables start and service iptables stop. Because of this we can’t start iptables boot.
There is small hack to start iptables on boot in Ubuntu/Debian. I will be explaining it here.
First write all you iptables rules in your Ubuntu machine.
Then save you need to save iptables rules in a text file with iptables-save command.
$ sudo iptables-save > iptables_rules
Copy or move iptables_rules file in to some directory (H ere I am using /etc/sysconfig/).
Now open /etc/network/interfaces to edit and add following line below iface lo inet loopback, then save and exit.
pre-up iptables-restore /etc/sysconfig/iptables_rules
Now reboot and test for iptables rules.
To test run sudo iptables -L command, and you should see the rules you added.