This question is an exact duplicate of:
I used pre-up in /etc/network/interfaces. It's strange, I have two Ubuntu server, one a PC and another a VPS. This method works on my PC but not on my VPS.
This is the /etc/network/interfaces on my PC
# ifupdown has been replaced by netplan(5) on this system. See # /etc/netplan for current configuration. # To re-enable ifupdown on this system, you can run: # sudo apt install ifupdown auto dsl-provider iface dsl-provider inet ppp pre-up /bin/ip link set eno1 up # line maintained by pppoeconf provider dsl-provider #auto eno1 #iface eno1 inet manual pre-up iptables-restore < /etc/iptables.rules
This is the /etc/network/interfaces on my VPS
# 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 auto eth0 iface eth0 inet static pre-up iptables-restore < /etc/iptables.rules source /etc/network/interfaces.d/*