I'm trying to start a service that depends on networking being started, whenever the computer is rebooted. I have a few questions:

  1. Is this easily possible from an /etc/init.d script? I have tried creating a script here (conforming to the standards), but I'm really doubtful that it's even running on boot, let alone working. When I test it manually, it works.

  2. I've seen the new Upstart service, but as far as how that actually works, I'm completely in the dark.

How can I make a script that runs on boot which runs after networking has been started? If I could run it after connected to wireless network, even better :)


You can use files in /etc/init as models. For example, this is /etc/init/mountall-net.conf:

# mountall-net - Mount network filesystems
# Send mountall the USR1 signal to inform it to try network filesystems
# again.

description     "Mount network filesystems"

start on net-device-up


    PID=$(status mountall 2>/dev/null | sed -e '/,/{s/.*,[^0-9]*//;q};d')
    [ -n "$PID" ] && kill -USR1 $PID || true
end script

and this is '/etc/init/ufw.conf`:

# ufw - Uncomplicated Firewall
# The Uncomplicated Firewall is a front-end for iptables, to make managing a
# Netfilter firewall easier.

description     "Uncomplicated firewall"

start on net-device-added INTERFACE=lo
stop on runlevel [!023456]

console output

pre-start exec /lib/ufw/ufw-init start quiet
post-stop exec /lib/ufw/ufw-init stop

The latter file has a symlink in /etc/init.d:

$ ls -l /etc/init.d/ufw
lrwxrwxrwx 1 root root 21 2009-11-05 00:14 /etc/init.d/ufw -> /lib/init/upstart-job
  • Should I start on net-device-up or on net-device-added? I'm using this script to start a DLNA server serving over wlan0. Thanks for the tip, I'll have to find a good guide on all of the options available for Upstart, seems like it's years ahead of system v. – Naftuli Kay Feb 21 '11 at 23:28
  • 1
    @TKKocheran: Since you probably need communication to be available, net-device-up would probably be the way to go. Here's the reference. Look particularly at the wiki. – Paused until further notice. Feb 22 '11 at 0:05

look at this: http://www.cyberciti.biz/tips/how-do-i-run-firewall-script-as-soon-as-eth0-interface-brings-up.html the post-up command is what you are looking for i guess.

Here is more info on the files in /etc/network: https://serverfault.com/questions/81494/is-every-script-located-in-etc-network-if-up-d-when-an-interface-is-brought-up

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.