xref: /netbsd/usr.sbin/ifwatchd/ifwatchd.8 (revision bf9ec67e)
1.\" $NetBSD: ifwatchd.8,v 1.12 2002/04/16 07:28:09 wiz Exp $
2.\"
3.\" Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Martin Husemann <martin@NetBSD.ORG>.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd September 2, 2001
38.Os
39.Dt IFWATCHD 8
40.Sh NAME
41.Nm ifwatchd
42.Nd "watch for addresses added to or deleted from interfaces and call up/down-scripts for them"
43.Sh SYNOPSIS
44.Nm
45.Op Fl d Ar down-script
46.Op Fl h
47.Op Fl i
48.Op Fl u Ar up-script
49.Op Fl v
50.Ar ifname(s)
51.Sh DESCRIPTION
52.Nm
53is used to monitor dynamic interfaces (for example PPP interfaces) for address
54changes.  Sometimes these interfaces are accompanied by a daemon program, which
55can take care of running any necessary scripts (like
56.Xr pppd 8
57or
58.Xr isdnd 8 ) ,
59but sometimes the interfaces run completely autonomously (like
60.Xr pppoe 8 ) .
61.Pp
62.Nm
63provides a generic way to watch this type of changes.  It works by monitoring
64the routing socket and interpreting
65.Ql RTM_NEWADDR
66.Pq address added
67and
68.Ql RTM_DELADDR
69.Pq address deleted
70messages.  It does not need special privileges to do this.  The scripts called
71for up or down events are run with the same user id as
72.Nm
73is run.
74.Pp
75The following options are available:
76.Bl -tag -width indent
77.It Fl d Ar down-script
78Specify the command to invoke on
79.Dq interface down
80events (or: deletion of an address from an interface).
81.It Fl h
82Show the synopsis.
83.It Fl i
84Inhibit a call to the up-script on startup for all watched interfaces
85already marked up. If this option is not given,
86.Nm
87will check all watched interfaces on startup whether they are already marked
88up and, if they are, call the up-script with appropriate parameters.
89.Pp
90Since ifwatchd typically is started late in the system boot sequence, some
91of the monitored interfaces may already have come up when it finally starts,
92but their up-scripts have not been called. By default
93.Nm
94calls them on startup to account for this (and make the scripts easier.)
95.It Fl u Ar up-script
96Specify the command to invoke on
97.Dq interface up
98events (or: addition of an address to an interface).
99.It Fl v
100Output verbose progress messages and flag errors ignored during normal
101operation.
102.It Ar ifname(s)
103The name of the interface to watch.  Multiple interfaces may be specified.
104Events for other interfaces are ignored.
105.El
106.Sh EXAMPLES
107.Bd -literal -offset indent
108# ifwatchd -u /etc/ppp/ip-up -d /etc/ppp/ip-down pppoe0
109
110.Ed
111If your pppoe0 interface is your main connection to the internet, the typical
112use of the up/down scripts is to add and remove a default route. This is
113an example for an up script doing this:
114.Bd -literal -offset indent
115#! /bin/sh
116/sbin/route add default $5
117
118.Ed
119As described below the fifth command line parameter will contain the peer
120address of the pppoe link. The corresponding ip-down script is:
121.Bd -literal -offset indent
122#! /bin/sh
123/sbin/route delete default $5
124
125.Ed
126Note that this is not a good idea if you have pppoe0 configured to connect
127only on demand (via the link1 flag), but works well for all permanent connected
128cases. Use
129.Bd -literal -offset indent
130! /sbin/route add default -iface 0.0.0.1
131
132.Ed
133in your
134.Pa /etc/ifconfig.pppoe0
135file in the on-demand case.
136.Sh PARAMETERS PASSED TO SCRIPTS
137The invoked scripts get passed these parameters:
138.Bl -tag -width destination
139.It Ar ifname
140The name of the interface this change is for (this allows to share the same
141script for multiple interfaces watched and dispatching on the interface name
142in the script).
143.It Ar tty
144Dummy parameter for compatibility with
145.Xr pppd 8
146which will always be
147.Em /dev/null .
148.It Ar speed
149Dummy parameter for compatibility with
150.Xr pppd 8
151which will always be
152.Em 9600 .
153.It Ar address
154The new address if this is an up event, or the no longer valid old address
155if this is a down event.
156.Pp
157The format of the address depends on the address family, for IPv4 it is the
158usual dotted quad notation, for IPv6 the colon separated standard notation.
159.It Ar destination
160For point to point interfaces, this is the remote address of the interface.
161For other interfaces it is the broadcast address.
162.El
163.Sh SEE ALSO
164.Xr route 4 ,
165.Xr ifconfig.if 5 ,
166.Xr pppoe 8 ,
167.Xr rc.d 8 ,
168.Xr route 8
169.Sh HISTORY
170The
171.Nm
172utility appeared in
173.Nx 1.6 .
174.Sh AUTHORS
175The program was written by
176.An Martin Husemann Aq martin@netbsd.org .
177