Linux – running a script after ETH0 comes up.

Leave a comment

June 5, 2013 by aubreykloppers

Ok, this is very easy, but took me a while to figure out.

Once your interface has a static IP, all you have to do is edit /etc/network/interfaces and add the last line:

# 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
address 10.0.0.104
gateway 10.0.0.222
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
post-up /etc/network/if-up.d/<script>

that’s it!  Now, when your server comes up and the network is active, the script will run.  I use this to mount CIFS files (Samba), starting Calibra-server and more…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: