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