Or you could add a line to the interface definition in /etc/network/interfaces.
Here's one of mine
Code: Select all
iface wlan0 inet dhcp
Don't worry that my interface is set to dhcp on that system.
The "post-up" and "pre-down" means that it runs the script /usr/loca/sbin/netmount after the interface has been brought up and got its IP address and is run again before the interface is closed down.
There are various environment variables passed to the script:
MODE: This contain "start" or "stop" to say what is happening to the interface.
PHASE: This contains the value "post-up" or "pre-down" to tell the script at what stage it is being called.
IFACE: Is the interface name.
There are others, but those are the important ones.