Created Tue May, 28 2019 at 12:30PM

If you want to run something before or after starting up your network interfaces you can do so with the following scripts. If they don't exist, just create them and they will be called via /etc/sysconfig/network-scripts/ifup and /etc/sysconfig/network-scripts/ifdown scripts.

#Before bringing up interfaces:
#Before shutting down interfaces:

#After bringing up interfaces
#After shutting down interfaces

practical use

I was creating a save iptables & ipset rules on system shutdown and restoring them on system startup.

I used post shutdown network (ifdown-local):

    ipset save > /home/vagrant/ipset_save
    iptables-save > /home/vagrant/iptables_save
    # you may want some rules to be put in place instead, load them here.
    if [ -f /home/vagrant/iptables.downrules ]; then
       iptables-restore < /home/vagrant/iptables.downrules
exit 0

However, I used the pre network up script (ifup-pre-local) to load in the rules prior to getting network access for safety :

if [ ! -f /tmp/.ipset_iptables_loaded ]; then
    ipset restore < /home/vagrant/ipset_save
    iptables-restore < /home/vagrant/iptables_save
    touch /tmp/.ipset_iptables_loaded
exit 0