Linux – When interface receives an IP address, run a shell script

debianlinuxnetworking

I am running a Debian Lenny server with two network interfaces. The first interface eth0 is connected to the LAN and receives an IP-address from the DHCP-server on this LAN. The second interface eth1 is connected directly to a NAS, on this NAS a DHCP server is installed so when the NAS is powered on, eth1 receives an IP-address from this.

I want to run a shell script automatically when eth1 has received an IP-adddress. How can this be done?

Best Answer

Put the shell script in an up argument for eth1's configuration stanza in /etc/network/interfaces.