Raspberry Pi – Running Script on Network change

Opennetworking configuration file /etc/network/interfaces:

sudo nano /etc/network/interfaces

Setup post-up option, append following line to eth0 configuration section:

post-up /etc/network/if-up.d/fw.dsl.start

To run command After bringing the interface up, enter:

post-up command

To run command before bringing the interface up, enter:

pre-up /scripts/networking.accounting_on

To run command before taking the interface down, enter:

pre-down command

To run command or script after taking the interface down, enter:

post-down /path/to/script.sh