# ifwatchd -u /etc/ppp/ip-up -d /etc/ppp/ip-down pppoe0
If your pppoe0 interface is your main connection to the internet, the typical use of the up/down scripts is to add and remove a default route. This is an example for an up script doing this:
#! /bin/sh
/sbin/route add default $5
/sbin/route add -inet6 default fe80::2 -iface ifp $1
As described below the fifth command line parameter will contain the peer address of the pppoe link. The corresponding ip-down script is:
#! /bin/sh
/sbin/route delete default $5
/sbin/route delete -inet6 default fe80::2
Note that this is not a good idea if you have pppoe0 configured to connect only on demand (via the link1 flag), but works well for all permanent connected cases. Use
! /sbin/route add default -iface 0.0.0.1
in your
/etc/ifconfig.pppoe0 file in the on-demand case.
The next example is for dhclient users.
# ifwatchd -i -c /etc/dhcp/carrier-detect tlp0
With the above command, the carrier-detect script will be invoked when a carrier is detected on the interface
tlp0. Note that the
-i flag prevents any action based on the initial state. A script like the following should work for most users, although it will not work for machines with multiple interfaces running
dhclient.
#! /bin/sh
# Arguments: ifname tty speed address destination
# If there is a dhclient already running, kill it.
# (This step could be put in a distinct no-carrier script,
# if desired.)
if [ -f /var/run/dhclient.pid ]; then
/bin/kill `/bin/cat /var/run/dhclient.pid`
fi
# Start dhclient again on this interface
/sbin/dhclient $1