1.\" $FreeBSD$ 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.\" $FreeBSD$ 37.\" 38.Dd June 1, 1996 39.Dt ROUTED 8 40.Os 41.Sh NAME 42.Nm routed , 43.Nm rdisc 44.Nd network RIP and router discovery routing daemon 45.Sh SYNOPSIS 46.Nm 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 advertises 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 , 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 "quiet-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 . 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 . ) 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.Pp 486.Cm Host Ar hname 487is equivalent to 488.Cm net Ar nname/32 . 489.Pp 490One of the keywords 491.Cm passive , 492.Cm active 493or 494.Cm external 495must be present to indicate whether the gateway should be treated as 496.Cm passive 497or 498.Cm active 499(as described above), 500or whether the gateway is 501.Cm external 502to the scope of the RIP protocol. 503.Pp 504As can be seen when debugging is turned on with 505.Fl t , 506such lines create pseudo-interfaces. 507To set parameters for remote or external interfaces, 508a line starting with 509.Cm if=alias(Hname) , 510.Cm if=remote(Hname) , 511etc. should be used. 512.Pp 513Lines that start with neither "net" nor "host" must consist of one 514or more of the following parameter settings, separated by commas or 515blanks: 516.Bl -tag -width Ds 517.It Cm if Ns \&= Ns Ar ifname 518indicates that the other parameters on the line apply to the interface 519name 520.Ar ifname . 521.It Cm subnet Ns \&= Ns Ar nname[/mask][,metric] 522advertises a route to network 523.Ar nname 524with mask 525.Ar mask 526and the supplied metric (default 1). 527This is useful for filling "holes" in CIDR allocations. 528This parameter must appear by itself on a line. 529The network number must specify a full, 32-bit value, as in 192.0.2.0 530instead of 192.0.2. 531.Pp 532Do not use this feature unless necessary. It is dangerous. 533.It Cm ripv1_mask Ns \&= Ns Ar nname/mask1,mask2 534specifies that netmask of the network of which 535.Cm nname/mask1\f1 536is 537a subnet should be 538.Cm mask2 . 539For example \f2ripv1_mask=192.0.2.16/28,27\f1 marks 192.0.2.16/28 540as a subnet of 192.0.2.0/27 instead of 192.0.2.0/24. 541It is better to turn on RIPv2 instead of using this facility, for example 542with \f2ripv2_out\f1. 543.It Cm passwd Ns \&= Ns Ar XXX[|KeyID[start|stop]] 544specifies a RIPv2 cleartext password that will be included on 545all RIPv2 responses sent, and checked on all RIPv2 responses received. 546Any blanks, tab characters, commas, or '#', '|', or NULL characters in the 547password must be escaped with a backslash (\\). 548The common escape sequences \\n, \\r, \\t, \\b, and \\xxx have their 549usual meanings. 550The 551.Cm KeyID 552must be unique but is ignored for cleartext passwords. 553If present, 554.Cm start 555and 556.Cm stop 557are timestamps in the form year/month/day@hour:minute. 558They specify when the password is valid. 559The valid password with the most future is used on output packets, unless 560all passwords have expired, in which case the password that expired most 561recently is used, or unless no passwords are valid yet, in which case 562no password is output. 563Incoming packets can carry any password that is valid, will 564be valid within 24 hours, or that was valid within 24 hours. 565To protect the secrets, the passwd settings are valid only in the 566.Em /etc/gateways 567file and only when that file is readable only by UID 0. 568.It Cm md5_passwd Ns \&= Ns Ar XXX|KeyID[start|stop] 569specifies a RIPv2 MD5 password. 570Except that a 571.Cm KeyID 572is required, this keyword is similar to 573.Cm passwd . 574.It Cm no_ag 575turns off aggregation of subnets in RIPv1 and RIPv2 responses. 576.It Cm no_super_ag 577turns off aggregation of networks into supernets in RIPv2 responses. 578.It Cm passive 579marks the interface to not be advertised in updates sent via other 580interfaces, and turns off all RIP and router discovery through the interface. 581.It Cm no_rip 582disables all RIP processing on the specified interface. 583If no interfaces are allowed to process RIP packets, 584.Nm 585acts purely as a router discovery daemon. 586.Pp 587Note that turning off RIP without explicitly turning on router 588discovery advertisements with 589.Cm rdisc_adv 590or 591.Fl s 592causes 593.Nm 594to act as a client router discovery daemon, not advertising. 595.It Cm no_rip_mcast 596causes RIPv2 packets to be broadcast instead of multicast. 597.It Cm no_ripv1_in 598causes RIPv1 received responses to be ignored. 599.It Cm no_ripv2_in 600causes RIPv2 received responses to be ignored. 601.It Cm ripv2_out 602turns on RIPv2 output and causes RIPv2 advertisements to be 603multicast when possible. 604.It Cm ripv2 605is equivalent to 606.Cm no_ripv1_in 607and 608.Cm no_ripv1_out . 609This enables RIPv2. 610.It Cm no_rdisc 611disables the Internet Router Discovery Protocol. 612.It Cm no_solicit 613disables the transmission of Router Discovery Solicitations. 614.It Cm send_solicit 615specifies that Router Discovery solicitations should be sent, 616even on point-to-point links, 617which by default only listen to Router Discovery messages. 618.It Cm no_rdisc_adv 619disables the transmission of Router Discovery Advertisements. 620.It Cm rdisc_adv 621specifies that Router Discovery Advertisements should be sent, 622even on point-to-point links, 623which by default only listen to Router Discovery messages. 624.It Cm bcast_rdisc 625specifies that Router Discovery packets should be broadcast instead of 626multicast. 627.It Cm rdisc_pref Ns \&= Ns Ar N 628sets the preference in Router Discovery Advertisements to the optionally 629signed integer 630.Ar N . 631The default preference is 0. 632Default routes with smaller or more negative preferences are preferred by 633clients. 634.It Cm rdisc_interval Ns \&= Ns Ar N 635sets the nominal interval with which Router Discovery Advertisements 636are transmitted to N seconds and their lifetime to 3*N. 637.It Cm fake_default Ns \&= Ns Ar metric 638has an identical effect to 639.Fl F Ar net[/mask][=metric] 640with the network and mask coming from the specified interface. 641.It Cm pm_rdisc 642is similar to 643.Cm fake_default . 644When RIPv2 routes are multicast, so that RIPv1 listeners cannot 645receive them, this feature causes a RIPv1 default route to be 646broadcast to RIPv1 listeners. 647Unless modified with 648.Cm fake_default , 649the default route is broadcast with a metric of 14. 650That serves as a "poor man's router discovery" protocol. 651.It Cm trust_gateway Ns \&= Ns Ar rname[|net1/mask1|net2/mask2|...] 652causes RIP packets from that router and other routers named in 653other 654.Cm trust_gateway 655keywords to be accepted, and packets from other routers to be ignored. 656If networks are specified, then routes to other networks will be ignored 657from that router. 658.It Cm redirect_ok 659causes RIP to allow ICMP Redirect messages when the system is acting 660as a router and forwarding packets. 661Otherwise, ICMP Redirect messages are overridden. 662.El 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 rtquery 8 672.Rs 673.%T Internet Transport Protocols 674.%R XSIS 028112 675.%Q Xerox System Integration Standard 676.Re 677.Sh BUGS 678It does not always detect unidirectional failures in network interfaces, 679for example, when the output side fails. 680.Sh HISTORY 681The 682.Nm 683command appeared in 684.Bx 4.2 . 685