xref: /freebsd/sbin/routed/routed.8 (revision 6e8394b8baa7d5d9153ab90de6824bcd19b3b4e1)
1.\"   $Revision: 2.17 $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)routed.8	8.2 (Berkeley) 12/11/93
35.\"
36.\"     $Id$
37.\"
38.Dd June 1, 1996
39.Dt ROUTED 8
40.Os BSD 4.4
41.Sh NAME
42.Nm routed ,
43.Nm rdisc
44.Nd network RIP and router discovery routing daemon
45.Sh SYNOPSIS
46.Nm routed
47.Op Fl sqdghmpAtv
48.Op Fl T Ar tracefile
49.Oo
50.Fl F
51.Ar net Ns Op /mask Ns Op ,metric
52.Oc
53.Op Fl P Ar parms
54.Sh DESCRIPTION
55.Nm Routed
56is a daemon invoked at boot time to manage the network
57routing tables.
58It uses Routing Information Protocol, RIPv1 (RFC\ 1058),
59RIPv2 (RFC\ 1723),
60and Internet Router Discovery Protocol (RFC 1256)
61to maintain the kernel routing table.
62The RIPv1 protocol is based on the reference
63.Bx 4.3
64daemon.
65.Pp
66It listens on the
67.Xr udp 4
68socket for the
69.Xr route 8
70service (see
71.Xr services 5 )
72for Routing Information Protocol packets.
73It also sends and receives multicast Router Discovery ICMP messages.
74If the host is a router,
75.Nm
76periodically supplies copies
77of its routing tables to any directly connected hosts and networks.
78It also advertise or solicits default routes using Router Discovery
79ICMP messages.
80.Pp
81When started (or when a network interface is later turned on),
82.Nm
83uses an AF_ROUTE address family facility to find those
84directly connected interfaces configured into the
85system and marked "up".
86It adds necessary routes for the interfaces
87to the kernel routing table.
88Soon after being first started, and provided there is at least one
89interface on which RIP has not been disabled,
90.Nm
91deletes all pre-existing
92non-static routes in kernel table.
93Static routes in the kernel table are preserved and
94included in RIP responses if they have a valid RIP metric
95(see
96.Xr route 8 ).
97.Pp
98If more than one interface is present (not counting the loopback interface),
99it is assumed that the host should forward packets among the
100connected networks.
101After transmitting a RIP
102.Em request
103and
104Router Discovery Advertisements or Solicitations on a new interface,
105the daemon enters a loop, listening for
106RIP request and response and Router Discovery packets from other hosts.
107.Pp
108When a
109.Em request
110packet is received,
111.Nm
112formulates a reply based on the information maintained in its
113internal tables.
114The
115.Em response
116packet generated contains a list of known routes, each marked
117with a "hop count" metric (a count of 16 or greater is
118considered "infinite").
119Advertised metrics reflect the metric associated with interface
120(see
121.Xr ifconfig 8 ),
122so setting the metric on an interface
123is an effective way to steer traffic.
124.Pp
125Responses do not include routes with a first hop on the requesting
126network to implement in part
127.Em split-horizon .
128Requests from query programs
129such as
130.Xr rtquery 8
131are answered with the complete table.
132.Pp
133The routing table maintained by the daemon
134includes space for several gateways for each destination
135to speed recovery from a failing router.
136RIP
137.Em response
138packets received are used to update the routing tables provided they are
139from one of the several currently recognized gateways or
140advertise a better metric than at least one of the existing
141gateways.
142.Pp
143When an update is applied,
144.Nm
145records the change in its own tables and updates the kernel routing table
146if the best route to the destination changes.
147The change in the kernel routing table is reflected in the next batch of
148.Em response
149packets sent.
150If the next response is not scheduled for a while, a
151.Em flash update
152response containing only recently changed routes is sent.
153.Pp
154In addition to processing incoming packets,
155.Nm
156also periodically checks the routing table entries.
157If an entry has not been updated for 3 minutes, the entry's metric
158is set to infinity and marked for deletion.
159Deletions are delayed until the route has been advertised with
160an infinite metric to insure the invalidation
161is propagated throughout the local internet.
162This is a form of
163.Em poison reverse .
164.Pp
165Routes in the kernel table that are added or changed as a result
166of ICMP Redirect messages are deleted after a while to minimize
167.Em black-holes .
168When a TCP connection suffers a timeout,
169the kernel tells
170.Nm Ns ,
171which deletes all redirected routes
172through the gateway involved, advances the age of all RIP routes through
173the gateway to allow an alternate to be chosen, and advances of the
174age of any relevant Router Discovery Protocol default routes.
175.Pp
176Hosts acting as internetwork routers gratuitously supply their
177routing tables every 30 seconds to all directly connected hosts
178and networks.
179These RIP responses are sent to the broadcast address on nets that support
180broadcasting,
181to the destination address on point-to-point links, and to the router's
182own address on other networks.
183If RIPv2 is enabled, multicast packets are sent on interfaces that
184support multicasting.
185.Pp
186If no response is received on a remote interface, if there are errors
187while sending responses,
188or if there are more errors than input or output (see
189.Xr netstat 1 ),
190then the cable or some other part of the interface is assumed to be
191disconnected or broken, and routes are adjusted appropriately.
192.Pp
193The
194.Em Internet Router Discovery Protocol
195is handled similarly.
196When the daemon is supplying RIP routes, it also listens for
197Router Discovery Solicitations and sends Advertisements.
198When it is quiet and listening to other RIP routers, it
199sends Solicitations and listens for Advertisements.
200If it receives
201a good Advertisement and it is not multi-homed,
202it stops listening for broadcast or multicast RIP responses.
203It tracks several advertising routers to speed recovery when the
204currently chosen router dies.
205If all discovered routers disappear,
206the daemon resumes listening to RIP responses.
207It continues listening to RIP while using Router Discovery
208if multi-homed to ensure all interfaces are used.
209.Pp
210The Router Discovery standard requires that advertisements
211have a default "lifetime" of 30 minutes.  That means should
212something happen, a client can be without a good route for
21330 minutes.  It is a good idea to reduce the default to 45
214seconds using
215.Fl P Cm rdisc_interval=45
216on the command line or
217.Cm rdisc_interval=45
218in the
219.Pa /etc/gateways
220file.
221.Pp
222While using Router Discovery (which happens by default when
223the system has a single network interface and a Router Discover Advertisement
224is received), there is a single default route and a variable number of
225redirected host routes in the kernel table.
226On a host with more than one network interface,
227this default route will be via only one of the interfaces.
228Thus, multi-homed hosts running with \f3\-q\f1 might need
229.Cm no_rdisc
230described below.
231.Pp
232See the
233.Cm pm_rdisc
234facility described below to support "legacy" systems
235that can handle neither RIPv2 nor Router Discovery.
236.Pp
237By default, neither Router Discovery advertisements nor solicitations
238are sent over point to point links (e.g. PPP).
239The netmask associated with point-to-point links (such as SLIP
240or PPP, with the IFF_POINTOPOINT flag) is used by
241.Nm
242to infer the netmask used by the remote system when RIPv1 is used.
243.Pp
244The following options are available:
245.Bl -tag -width indent
246.It Fl s
247force
248.Nm
249to supply routing information.
250This is the default if multiple network interfaces are present on which
251RIP or Router Discovery have not been disabled, and if the kernel switch
252ipforwarding=1.
253.It Fl q
254is the opposite of the
255.Fl s
256option.
257This is the default when only one interface is present.
258With this explicit option, the daemon is always in "quite-mode" for RIP
259and does not supply routing information to other computers.
260.It Fl d
261do not run in the background.
262This option is meant for interactive use.
263.It Fl g
264used on internetwork routers to offer a route
265to the "default" destination.
266It is equivalent to
267.Fl F
268.Cm 0/0,1
269and is present mostly for historical reasons.
270A better choice is
271.Fl P Cm pm_rdisc
272on the command line or
273.Cm pm_rdisc
274in the
275.Pa /etc/gateways
276file.
277since a larger metric
278will be used, reducing the spread of the potentially dangerous
279default route.
280This is typically used on a gateway to the Internet,
281or on a gateway that uses another routing protocol whose routes
282are not reported to other local routers.
283Notice that because a metric of 1 is used, this feature is
284dangerous.  It is more commonly accidentally used to create chaos with a
285routing loop than to solve problems.
286.It Fl h
287cause host or point-to-point routes to not be advertised,
288provided there is a network route going the same direction.
289That is a limited kind of aggregation.
290This option is useful on gateways to Ethernets that have other gateway
291machines connected with point-to-point links such as SLIP.
292.It Fl m
293cause the machine to advertise a host or point-to-point route to
294its primary interface.
295It is useful on multi-homed machines such as NFS servers.
296This option should not be used except when the cost of
297the host routes it generates is justified by the popularity of
298the server.
299It is effective only when the machine is supplying
300routing information, because there is more than one interface.
301The
302.Fl m
303option overrides the
304.Fl q
305option to the limited extent of advertising the host route.
306.It Fl A
307do not ignore RIPv2 authentication if we do not care about RIPv2
308authentication.
309This option is required for conformance with RFC 1723.
310However, it makes no sense and breaks using RIP as a discovery protocol
311to ignore all RIPv2 packets that carry authentication when this machine
312does not care about authentication.
313.It Fl t
314increase the debugging level, which causes more information to be logged
315on the tracefile specified with
316.Fl T
317or standard out.
318The debugging level can be increased or decreased
319with the
320.Em SIGUSR1
321or
322.Em SIGUSR2
323signals or with the
324.Xr rtquery 8
325command.
326.It Fl T Ar tracefile
327increases the debugging level to at least 1 and
328causes debugging information to be appended to the trace file.
329Note that because of security concerns, it is wisest to not run
330.Nm
331routinely with tracing directed to a file.
332.It Fl v
333display and logs the version of daemon.
334.It Fl F Ar net[/mask][,metric]
335minimize routes in transmissions via interfaces with addresses that match
336.Em net/mask ,
337and synthesizes a default route to this machine with the
338.Em metric .
339The intent is to reduce RIP traffic on slow, point-to-point links
340such as PPP links by replacing many large UDP packets of RIP information
341with a single, small packet containing a "fake" default route.
342If
343.Em metric
344is absent, a value of 14 is assumed to limit
345the spread of the "fake" default route.
346This is a dangerous feature that when used carelessly can cause routing
347loops.
348Notice also that more than one interface can match the specified network
349number and mask.
350See also
351.Fl g .
352.It Fl P Ar parms
353is equivalent to adding the parameter
354line
355.Em parms
356to the
357.Pa /etc/gateways
358file.
359.El
360.Pp
361Any other argument supplied is interpreted as the name
362of a file in which the actions of
363.Nm
364should be logged.
365It is better to use
366.Fl T
367instead of
368appending the name of the trace file to the command.
369.Pp
370.Nm Routed
371also supports the notion of
372"distant"
373.Em passive
374or
375.Em active
376gateways.
377When
378.Nm
379is started, it reads the file
380.Pa /etc/gateways
381to find such distant gateways which may not be located using
382only information from a routing socket, to discover if some
383of the local gateways are
384.Em passive ,
385and to obtain other parameters.
386Gateways specified in this manner should be marked passive
387if they are not expected to exchange routing information,
388while gateways marked active
389should be willing to exchange RIP packets.
390Routes through
391.Em passive
392gateways are installed in the
393kernel's routing tables once upon startup and are not included in
394transmitted RIP responses.
395.Pp
396Distant active gateways are treated like network interfaces.
397RIP responses are sent
398to the distant
399.Em active
400gateway.
401If no responses are received, the associated route is deleted from
402the kernel table and RIP responses advertised via other interfaces.
403If the distant gateway resumes sending RIP responses, the associated
404route is restored.
405.Pp
406Such gateways can be useful on media that do not support broadcasts
407or multicasts but otherwise act like classic shared media like
408Ethernets such as some ATM networks.
409One can list all RIP routers reachable on the HIPPI or ATM network in
410.Pa /etc/gateways
411with a series of
412"host" lines.
413Note that it is usually desirable to use RIPv2 in such situations
414to avoid generating lists of inferred host routes.
415.Pp
416Gateways marked
417.Em external
418are also passive, but are not placed in the kernel
419routing table nor are they included in routing updates.
420The function of external entries is to indicate
421that another routing process
422will install such a route if necessary,
423and that other routes to that destination should not be installed
424by
425.Nm Ns .
426Such entries are only required when both routers may learn of routes
427to the same destination.
428.Pp
429The
430.Pa /etc/gateways
431file is comprised of a series of lines, each in
432one of the following two formats or consist of parameters described later.
433Blank lines and lines starting with '#' are comments.
434.Pp
435.Bd -ragged
436.Cm net
437.Ar Nname[/mask]
438.Cm gateway
439.Ar Gname
440.Cm metric
441.Ar value
442.Pf < Cm passive No \&|
443.Cm active No \&|
444.Cm extern Ns >
445.Ed
446.Bd -ragged
447.Cm host
448.Ar Hname
449.Cm gateway
450.Ar Gname
451.Cm metric
452.Ar value
453.Pf < Cm passive No \&|
454.Cm active No \&|
455.Cm extern Ns >
456.Ed
457.Pp
458.Ar Nname
459or
460.Ar Hname
461is the name of the destination network or host.
462It may be a symbolic network name or an Internet address
463specified in "dot" notation (see
464.Xr inet 3 ).
465(If it is a name, then it must either be defined in
466.Pa /etc/networks
467or
468.Pa /etc/hosts ,
469or
470.Xr named 8 ,
471must have been started before
472.Nm Ns .)
473.Pp
474.Ar Mask
475is an optional number between 1 and 32 indicating the netmask associated
476with
477.Ar Nname .
478.Pp
479.Ar Gname
480is the name or address of the gateway to which RIP responses should
481be forwarded.
482.Pp
483.Ar Value
484is the hop count to the destination host or network.
485.Ar " Host hname "
486is equivalent to
487.Ar " net  nname/32 ".
488.Pp
489One of the keywords
490.Cm passive ,
491.Cm active
492or
493.Cm external
494must be present to indicate whether the gateway should be treated as
495.Cm passive
496or
497.Cm active
498(as described above),
499or whether the gateway is
500.Cm external
501to the scope of the RIP protocol.
502.Pp
503As can be seen when debugging is turned on with
504.Fl t ,
505such lines create pseudo-interfaces.
506To set parameters for remote or external interfaces,
507a line starting with
508.Cm if=alias(Hname) ,
509.Cm if=remote(Hname) ,
510etc. should be used.
511.Pp
512Lines that start with neither "net" nor "host" must consist of one
513or more of the following parameter settings, separated by commas or
514blanks:
515.Bl -tag -width Ds
516.It Cm if Ns \&= Ns Ar ifname
517indicates that the other parameters on the line apply to the interface
518name
519.Ar ifname .
520.It Cm subnet Ns \&= Ns Ar nname[/mask][,metric]
521advertises a route to network
522.Ar nname
523with mask
524.Ar mask
525and the supplied metric (default 1).
526This is useful for filling "holes" in CIDR allocations.
527This parameter must appear by itself on a line.
528The network number must specify a full, 32-bit value, as in 192.0.2.0
529instead of 192.0.2.
530.Pp
531Do not use this feature unless necessary.  It is dangerous.
532.It Cm ripv1_mask Ns \&= Ns Ar nname/mask1,mask2
533specifies that netmask of the network of which
534.Cm nname/mask1\f1
535is
536a subnet should be
537.Cm mask2 .
538For example \f2ripv1_mask=192.0.2.16/28,27\f1 marks 192.0.2.16/28
539as a subnet of 192.0.2.0/27 instead of 192.0.2.0/24.
540It is better to turn on RIPv2 instead of using this facility, for example
541with \f2ripv2_out\f1.
542.It Cm passwd Ns \&= Ns Ar XXX[|KeyID[start|stop]]
543specifies a RIPv2 cleartext password that will be included on
544all RIPv2 responses sent, and checked on all RIPv2 responses received.
545Any blanks, tab characters, commas, or '#', '|', or NULL characters in the
546password must be escaped with a backslash (\\).
547The common escape sequences \\n, \\r, \\t, \\b, and \\xxx have their
548usual meanings.
549The
550.Cm KeyID
551must be unique but is ignored for cleartext passwords.
552If present,
553.Cm start
554and
555.Cm stop
556are timestamps in the form year/month/day@hour:minute.
557They specify when the password is valid.
558The valid password with the most future is used on output packets, unless
559all passwords have expired, in which case the password that expired most
560recently is used, or unless no passwords are valid yet, in which case
561no password is output.
562Incoming packets can carry any password that is valid, will
563be valid within 24 hours, or that was valid within 24 hours.
564To protect the secrets, the passwd settings are valid only in the
565.Em /etc/gateways
566file and only when that file is readable only by UID 0.
567.It Cm md5_passwd Ns \&= Ns Ar XXX|KeyID[start|stop]
568specifies a RIPv2 MD5 password.
569Except that a
570.Cm KeyID
571is required, this keyword is similar to
572.Cm passwd .
573.It Cm no_ag
574turns off aggregation of subnets in RIPv1 and RIPv2 responses.
575.It Cm no_super_ag
576turns off aggregation of networks into supernets in RIPv2 responses.
577.It Cm passive
578marks the interface to not be advertised in updates sent via other
579interfaces, and turns off all RIP and router discovery through the interface.
580.It Cm no_rip
581disables all RIP processing on the specified interface.
582If no interfaces are allowed to process RIP packets,
583.Nm
584acts purely as a router discovery daemon.
585.Pp
586Note that turning off RIP without explicitly turning on router
587discovery advertisements with
588.Cm rdisc_adv
589or
590.Fl s
591causes
592.Nm
593to act as a client router discovery daemon, not advertising.
594.It Cm no_rip_mcast
595causes RIPv2 packets to be broadcast instead of multicast.
596.It Cm no_ripv1_in
597causes RIPv1 received responses to be ignored.
598.It Cm no_ripv2_in
599causes RIPv2 received responses to be ignored.
600.It Cm ripv2_out
601turns on RIPv2 output and causes RIPv2 advertisements to be
602multicast when possible.
603.It Cm ripv2
604is equivalent to
605.Cm no_ripv1_in
606and
607.Cm no_ripv1_out .
608This enables RIPv2.
609.It Cm no_rdisc
610disables the Internet Router Discovery Protocol.
611.It Cm no_solicit
612disables the transmission of Router Discovery Solicitations.
613.It Cm send_solicit
614specifies that Router Discovery solicitations should be sent,
615even on point-to-point links,
616which by default only listen to Router Discovery messages.
617.It Cm no_rdisc_adv
618disables the transmission of Router Discovery Advertisements.
619.It Cm rdisc_adv
620specifies that Router Discovery Advertisements should be sent,
621even on point-to-point links,
622which by default only listen to Router Discovery messages.
623.It Cm bcast_rdisc
624specifies that Router Discovery packets should be broadcast instead of
625multicast.
626.It Cm rdisc_pref Ns \&= Ns Ar N
627sets the preference in Router Discovery Advertisements to the optionally
628signed integer
629.Ar N .
630The default preference is 0.
631Default routes with smaller or more negative preferences are preferred by
632clients.
633.It Cm rdisc_interval Ns \&= Ns Ar N
634sets the nominal interval with which Router Discovery Advertisements
635are transmitted to N seconds and their lifetime to 3*N.
636.It Cm fake_default Ns \&= Ns Ar metric
637has an identical effect to
638.Fl F Ar net[/mask][=metric]
639with the network and mask coming from the specified interface.
640.It Cm pm_rdisc
641is similar to
642.Cm fake_default .
643When RIPv2 routes are multicast, so that RIPv1 listeners cannot
644receive them, this feature causes a RIPv1 default route to be
645broadcast to RIPv1 listeners.
646Unless modified with
647.Cm fake_default ,
648the default route is broadcast with a metric of 14.
649That serves as a "poor man's router discovery" protocol.
650.It Cm trust_gateway Ns \&= Ns Ar rname[|net1/mask1|net2/mask2|...]
651causes RIP packets from that router and other routers named in
652other
653.Cm trust_gateway
654keywords to be accepted, and packets from other routers to be ignored.
655If networks are specified, then routes to other networks will be ignored
656from that router.
657.It Cm redirect_ok
658causes RIP to allow ICMP Redirect messages when the system is acting
659as a router and forwarding packets.
660Otherwise, ICMP Redirect messages are overridden.
661.El
662.Pp
663.Sh FILES
664.Bl -tag -width /etc/gateways -compact
665.It Pa /etc/gateways
666for distant gateways
667.El
668.Sh SEE ALSO
669.Xr icmp 4 ,
670.Xr udp 4 ,
671.Xr gated 8 ,
672.Xr htable 8 ,
673.Xr rtquery 8 .
674.Rs
675.%T Internet Transport Protocols
676.%R XSIS 028112
677.%Q Xerox System Integration Standard
678.Re
679.Sh BUGS
680It does not always detect unidirectional failures in network interfaces,
681for example, when the output side fails.
682.Sh HISTORY
683The
684.Nm
685command appeared in
686.Bx 4.2 .
687