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