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