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