On my 16.04 servers I use the /etc/network/interfaces
file method:
$ cat /etc/network/interfaces
# interfaces file for smythies.com 2016.01.30
# attempt to set local DNS herein, as the method
# used with the old 12.04 server no longer works.
#
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
pre-up /home/doug/init/doug_firewall
dns-nameservers 127.0.0.1
# The primary interface (d-link PCI card)
auto enp4s0
iface enp4s0 inet dhcp
# Local network interface (uses built in ethernet port)
auto enp2s0
iface enp2s0 inet static
address 192.168.111.1
network 192.168.111.0
netmask 255.255.255.0
broadcast 192.168.111.255
Where you see I use a pre-up
directive in the local interface definition to execute my (mainly) iptables script.
NOTE: this method will not work with later releases that use netplan instead of ifup ifdown.
netfilter-persistent
is for? see for example Where does netfilter-persistent save the iptables rules?