Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have written a program that transparently logs in to captive portals. As such, I'd like to run this any time that any wireless connection comes up using netcfg. It is possible to do this per-connection in the configuration file by using POST_UP, but this would require adding it to every connection that currently exists, and any connection that may be created in future, which is not feasible in my situation. I also do not wish to poll for network connections as a daemon. I don't see any information about doing this in man netcfg-profiles.

How should I approach this? Does netcfg have any built-in configuration that allows a POST_UP to apply to multiple connections?

It is acceptable for it to also apply to all connections (including wired), but if possible I'd like to avoid it.

share|improve this question
up vote 1 down vote accepted

Interface-specific {PRE,POST}_{UP,DOWN} commands can be defined in /etc/network.d/interfaces/$DEVICE, where $DEVICE is your network device name. So, although you need a hook per interface (which is actually what you indicate that you want), you do not need one per connection.

For example, my interfaces folder has the following files:


notify() {
/usr/local/sbin/xuserrun /usr/local/sbin/network_notification "$dev" "$state"
return 0

/etc/network.d/interfaces/{wlan0,eth0} (both with same contents):

source /etc/network.d/interfaces/_functions
POST_UP="notify ${INTERFACE} up"
PRE_DOWN="notify ${INTERFACE} down"

This runs a script to send a pop-up notification telling me when a connection has been made/lost. Note that these hooks run as the root user. The xuserrun command is available on github and determines the current X username and switches to that user before running the subsequent command.

share|improve this answer
That's the ticket, thanks! – Chris Down Jan 22 '13 at 11:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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