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