ifwatchd
Watch for addresses added to or deleted from interfaces and call up/down-scripts for them
Syntax:
ifwatchd [-hiPqv] [-A arrival-script] [-c carrier-script]
[-D departure-script] [-d down-script]
[-n no-carrier-script] [-u up-script] ifname(s)
Runs on:
QNX OS
Options:
- -A arrival-script
- Specify the command to invoke when new interfaces (such as PCMCIA cards) arrive.
- -c carrier-script
- Specify the command to invoke when the carrier status changes from no carrier to carrier.
- -D departure-script
- Specify the command to invoke when an interface departs (for example, a PCMCIA card is removed.)
- -d down-script
- Specify the command to invoke on
interface down
events (or on the deletion of an address from an interface). - -h
- Show the synopsis.
- -i
- Inhibit a call to the up-script on startup for all watched interfaces already marked up.
If you don't specify this option, ifwatchd checks all watched
interfaces on startup whether they're already marked up and,
if they are, calls the up-script with appropriate parameters.
Since ifwatchd typically is started late in the system boot sequence, some of the monitored interfaces may already have come up when it finally starts, but their up-scripts haven't been called. By default, ifwatchd calls them on startup to account for this (and make the scripts easier).
- -n no-carrier-script
- Specify the command to invoke when the carrier status transitions from carrier to no carrier.
- -P
- Force ifwatchd to daemonize by calling
procmgr_daemon()
instead of
daemon().
Note:You need to specify -P if you're running ifwatchd under the control of the High Availability Manager (HAM). The HAM can see death messages only from tasks that are running in session 1, and the call to daemon() doesn't put the caller into that session. For more information about HAM, see the High Availability Framework Developer's Guide.
- -q
- Be quiet and don't log non-error messages to slogger2.
- -u up-script
- Specify the command to invoke on
interface up
events (or on the addition of an address to an interface). - -v
- Run in verbose debug mode and don't detach from the controlling terminal. Output verbose progress messages, and flag those errors that are ignored during normal operation. Don't use this option in /etc/rc.conf.
- ifname(s)
- The name of the interface to watch. You can specify multiple interfaces. Events for other interfaces are ignored.
Description:
The ifwatchd utility is used to monitor dynamic interfaces (for example PPP interfaces) for address changes, and to monitor static interfaces for carrier changes. Sometimes these interfaces are accompanied by a daemon program, which can take care of running any necessary scripts (such as isdnd), but sometimes the interfaces run completely autonomously (such as pppoe).
The ifwatchd utility provides a generic way to watch these types of changes. It works by monitoring the routing socket and interpreting RTM_NEWADDR (address added), RTM_DELADDR (address deleted) and RTM_IFINFO (carrier detect or loss of carrier) messages. It doesn't need special privileges to do this. The scripts called for up or down events are run with the same user ID as for ifwatchd.
Examples:
ifwatchd -u /etc/ppp/ip-up -d /etc/ppp/ip-down pppoe0
#! /bin/sh
/sbin/route add default $5
#! /bin/sh
/sbin/route delete default $5
! /sbin/route add default -iface 0.0.0.1
in your /etc/ifconfig.pppoe0 file in the on-demand case.