iptables resets when server reboots

Solution 1:

This is the default behavior.

You may want to take a look at the package iptables-persistent to automatically set iptables rules at startup from a configuration file.

Solution 2:

On Ubuntu 16.04:
sudo apt-get install iptables-persistent

After that, run next commands every time you want save iptables changes permanently:
sudo netfilter-persistent save
sudo netfilter-persistent reload