Restore iptables on system boot

Os: Ubuntu 17.04

Assuming you have the firewall rules in:

/etc/iptables.up.rules

Perhaps the most obvious answer will be to create a file called iptables in:

/etc/network/if-pre-up.d

with the content:

#!/bin/bash
/sbin/iptables-restore < /etc/iptables.up.rules

and make it executable using

sudo chmod +x /etc/network/if-pre-up.d/iptables

This way before your network interface is activated your rules will be loaded.