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 Discover 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 tableis 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 Discover 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 Discover 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. 222.Pp 223See the 224.Cm pm_rdisc 225facility described below to support "legacy" systems 226that can handle neither RIPv2 nor Router Discovery. 227.Pp 228By default, neither Router Discovery advertisements nor solicications 229are sent over point to point links (e.g. PPP). 230 231.Pp 232Options supported by 233.Nm routed : 234.Bl -tag -width Ds 235.It Fl s 236this option forces 237.Nm 238to supply routing information. 239This is the default if multiple network interfaces are present on which 240RIP or Router Discovery have not been disabled, and if the kernel switch 241ipforwarding=1. 242.It Fl q 243is the opposite of the 244.Fl s 245option. 246.It Fl d 247Do not run in the background. 248This option is meant for interactive use. 249.It Fl g 250This flag is used on internetwork routers to offer a route 251to the "default" destination. 252It is equivalent to 253.Fl F 254.Cm 0/0,1 255and is present mostly for historical reasons. 256A better choice is 257.Fl P Cm pm_rdisc 258on the command line or 259.CM pm_rdisc in the 260.Pa /etc/gateways 261file. 262since a larger metric 263will be used, reducing the spread of the potentially dangerous 264default route. 265This is typically used on a gateway to the Internet, 266or on a gateway that uses another routing protocol whose routes 267are not reported to other local routers. 268Notice that because a metric of 1 is used, this feature is 269dangerous. It is more commonly accidently used to create chaos with routing 270loop than to solve problems. 271.It Fl h 272This causes host or point-to-point routes to not be advertised, 273provided there is a network route going the same direction. 274That is a limited kind of aggregation. 275This option is useful on gateways to ethernets that have other gateway 276machines connected with point-to-point links such as SLIP. 277.It Fl m 278This causes the machine to advertise a host or point-to-point route to 279its primary interface. 280It is useful on multi-homed machines such as NFS servers. 281This option should not be used except when the cost of 282the host routes it generates is justified by the popularity of 283the server. 284It is effective only when the machine is supplying 285routing information, because there is more than one interface. 286The 287.Fl m 288option overrides the 289.Fl q 290option to the limited extent of advertising the host route. 291.It Fl A 292do not ignore RIPv2 authentication if we do not care about RIPv2 293authentication. 294This option is required for conformance with RFC 1723. 295However, it makes no sense and breaks using RIP as a discovery protocol 296to ignore all RIPv2 packets that carry authentication when this machine 297does not care about authentication. 298.It Fl T Ar tracefile 299increases the debugging level to at least 1 and 300causes debugging information to be appended to the trace file. 301Note that because of security concerns, it is wisest to not run 302.Nm routed 303routinely with tracing directed to a file. 304.It Fl t 305increases the debugging level, which causes more information to be logged 306on the tracefile specified with 307.Fl T 308or standard out. 309The debugging level can be increased or decreased 310with the 311.Em SIGUSR1 312or 313.Em SIGUSR2 314signals or with the 315.Cm rtquery 316command. 317.It Fl F Ar net[/mask][,metric] 318minimize routes in transmissions via interfaces with addresses that match 319.Em net/mask , 320and synthesizes a default route to this machine with the 321.Em metric . 322The intent is to reduce RIP traffic on slow, point-to-point links 323such as PPP links by replacing many large UDP packets of RIP information 324with a single, small packet containing a "fake" default route. 325If 326.Em metric 327is absent, a value of 14 is assumed to limit 328the spread of the "fake" default route. 329 330This is a dangerous feature that when used carelessly can cause routing 331loops. 332Notice also that more than one interface can match the specified network 333number and mask. 334See also 335.Fl g . 336.It Fl P Ar parms 337is equivalent to adding the parameter 338line 339.Em parms 340to the 341.Pa /etc/gateways 342file. 343.El 344.Pp 345Any other argument supplied is interpreted as the name 346of a file in which the actions of 347.Nm 348should be logged. 349It is better to use 350.Fl T 351instead of 352appending the name of the trace file to the command. 353.Pp 354.Nm 355also supports the notion of 356"distant" 357.Em passive 358or 359.Em active 360gateways. 361When 362.Nm 363is started, it reads the file 364.Pa /etc/gateways 365to find such distant gateways which may not be located using 366only information from a routing socket, to discover if some 367of the local gateways are 368.Em passive , 369and to obtain other parameters. 370Gateways specified in this manner should be marked passive 371if they are not expected to exchange routing information, 372while gateways marked active 373should be willing to exchange RIP packets. 374Routes through 375.Em passive 376gateways are installed in the 377kernel's routing tables once upon startup and are not included in 378transmitted RIP responses. 379.Pp 380Distant active gateways are treated like network interfaces. 381RIP responses are sent 382to the distant 383.Em active 384gateway. 385If no responses are received, the associated route is deleted from 386the kernel table and RIP responses advertised via other interfaces. 387If the distant gateway resumes sending RIP responses, the associated 388route is restored. 389.Pp 390Such gateways can be useful on media that do not support broadcasts 391or multicasts but otherwise act like classic shared media like 392Ethernets such as some ATM networks. 393One can list all RIP routers reachable on the ATM network in 394.Pa /etc/gateways 395with a series of 396"host" lines. 397.Pp 398Gateways marked 399.Em external 400are also passive, but are not placed in the kernel 401routing table nor are they included in routing updates. 402The function of external entries is to indicate 403that another routing process 404will install such a route if ncessary, 405and that alternate routes to that destination should not be installed 406by 407.Nm routed . 408Such entries are only required when both routers may learn of routes 409to the same destination. 410.Pp 411The 412.Em /etc/gateways 413file is comprised of a series of lines, each in 414one of the following formats or consist of parameters described below: 415.Pp 416.Bd -ragged 417.Cm net 418.Ar Nname[/mask] 419.Cm gateway 420.Ar Gname 421.Cm metric 422.Ar value 423.Pf < Cm passive No \&| 424.Cm active No \&| 425.Cm extern Ns > 426.Ed 427.Bd -ragged 428.Cm host 429.Ar Hname 430.Cm gateway 431.Ar Gname 432.Cm metric 433.Ar value 434.Pf < Cm passive No \&| 435.Cm active No \&| 436.Cm extern Ns > 437.Ed 438.Pp 439.Ar Nname 440or 441.Ar Hname 442is the name of the destination network or host. 443It may be a symbolic network name or an Internet address 444specified in "dot" notation (see 445.Xr inet 3 ). 446(If it is a name, then it must either be defined in 447.Pa /etc/networks 448or 449.Pa /etc/hosts , 450or 451.Xr named 8 , 452must have been started before 453.Xr routed Ns .) 454.Pp 455.Ar mask 456is an optional number between 1 and 32 indicating the netmask associated 457with 458.Ar Nname . 459.Pp 460.Ar Gname 461is the name or address of the gateway to which RIP responses should 462be forwarded. 463.Pp 464.Ar Value 465is the hop count to the destination host or network. 466.Ar " host hname " 467is equivalent to 468.Ar " net nname/32 ". 469.Pp 470One of the keywords 471.Cm passive , 472.Cm active 473or 474.Cm external 475must be present to indicate whether the gateway should be treated as 476.Cm passive 477or 478.Cm active 479(as described above), 480or whether the gateway is 481.Cm external 482to the scope of the RIP protocol. 483.Pp 484Lines that start with neither "net" nor "host" must consist of one 485or more of the following parameter settings, separated by commas or 486blanks: 487.Bl -tag -width Ds 488.It Cm if Ns \&= Ns Ar ifname 489indicates that the other parameters on the line apply to the interface 490name 491.Ar ifname . 492.It Cm subnet Ns \&= Ns Ar nname[/mask][,metric] 493advertises a route to network 494.AR nname 495with mask 496.AR mask 497and the supplied metric (default 1). 498This is useful for filling "holes" in CIDR allocations. 499This parameter must appear by itself on a line. 500.Pp 501Do not use this feature unless necessary. It is dangerous. 502.It Cm passwd Ns \&= Ns Ar XXX 503specifies a RIPv2 password that will be included on all RIPv2 504responses sent and checked on all RIPv2 responses received. 505The password must not contain any blanks, tab characters, commas 506or '#' characters. 507.It Cm no_ag 508turns off aggregation of subnets in RIPv1 and RIPv2 responses. 509.It Cm no_super_ag 510turns off aggregation of networks into supernets in RIPv2 responses. 511.It Cm passive 512is equivalent 513.Cm no_rip Cm no_rdisc . 514.It Cm no_rip 515disables all RIP processing on the specified interface. 516If no interfaces are allowed to process RIP packets, 517.Nm 518acts purely as a router discovery daemon. 519.Cm No_rip 520is equivalent to 521.Cm no_ripv1_in no_ripv2_in no_ripv1_out no_ripv2_out . 522 523Note that turning off RIP without explicitly turning on router 524discovery advertisements with 525.Cm rdisc_adv 526or 527.Fl s 528causes 529.Nm routed 530to act as a client router discovery daemon, not adveritising. 531.It Cm no_ripv1_in 532causes RIPv1 received responses to be ignored. 533.It Cm no_ripv2_in 534causes RIPv2 received responses to be ignored. 535.It Cm ripv2_out 536turns off RIPv1 output and causes RIPv2 advertisements to be 537multicast when possible. 538.It Cm no_rdisc 539disables the Internet Router Discovery Protocol. 540.It Cm no_solicit 541disables the tranmission of Router Discovery Solicitations. 542.It Cm send_solicit 543specifies that Router Discovery solicitations should be sent, 544even on point-to-point links, 545which by default only listen to Router Discovery messages. 546.It Cm no_rdisc_adv 547disables the transmission of Router Discovery Advertisements 548.It Cm rdisc_adv 549specifies that Router Discovery advertisements should be sent, 550even on point-to-point links, 551which by default only listen to Router Discovery messages 552.It Cm bcast_rdisc 553specifies that Router Discovery packets should be broadcast instead of 554multicast. 555.It Cm rdisc_pref Ns \&= Ns Ar N 556sets the preference in Router Discovery Advertisements to the integer 557.Ar N . 558.It Cm rdisc_interval Ns \&= Ns Ar N 559sets the nominal interval with which Router Discovery Advertisements 560are transmitted to N seconds and their lifetime to 3*N. 561.It Cm fake_default Ns \&= Ns Ar metric 562has an identical effect to 563.Fl F Ar net[/mask][,metric] 564with the network and mask coming from the sepcified interface. 565.It Cm pm_rdisc 566is similar to 567.Cm fake_default . 568When RIPv2 routes are multicast, so that RIPv1 listeners cannot 569receive them, this feature causes a RIPv1 default route to be 570broadcast to RIPv1 listeners. 571Unless modified with 572.Cm fake_default , 573the default route is broadcast with a metric of 14. 574That serves as a "poor man's router discovery" protocol. 575.El 576.Pp 577Note that the netmask associated with point-to-point links (such as SLIP 578or PPP, with the IFF_POINTOPOINT flag) is used by 579.Nm routed 580to infer the netmask used by the remote system when RIPv1 is used. 581.Pp 582.Sh FILES 583.Bl -tag -width /etc/gateways -compact 584.It Pa /etc/gateways 585for distant gateways 586.El 587.Sh SEE ALSO 588.Xr gated 8 , 589.Xr udp 4 , 590.Xr icmp 4 , 591.Xr htable 8 , 592.Xr rtquery 8 . 593.Rs 594.%T Internet Transport Protocols 595.%R XSIS 028112 596.%Q Xerox System Integration Standard 597.Re 598.Sh BUGS 599It does not always detect unidirectional failures in network interfaces 600(e.g., when the output side fails). 601.Sh HISTORY 602The 603.Nm 604command appeared in 605.Bx 4.2 . 606