1*95ed13e1Saisha.\" $OpenBSD: route.8,v 1.119 2023/08/02 23:34:13 aisha Exp $ 2df930be7Sderaadt.\" $NetBSD: route.8,v 1.6 1995/03/18 15:00:13 cgd Exp $ 3df930be7Sderaadt.\" 4df930be7Sderaadt.\" Copyright (c) 1983, 1991, 1993 5df930be7Sderaadt.\" The Regents of the University of California. All rights reserved. 6df930be7Sderaadt.\" 7df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without 8df930be7Sderaadt.\" modification, are permitted provided that the following conditions 9df930be7Sderaadt.\" are met: 10df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright 11df930be7Sderaadt.\" notice, this list of conditions and the following disclaimer. 12df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright 13df930be7Sderaadt.\" notice, this list of conditions and the following disclaimer in the 14df930be7Sderaadt.\" documentation and/or other materials provided with the distribution. 151ef0d710Smillert.\" 3. Neither the name of the University nor the names of its contributors 16df930be7Sderaadt.\" may be used to endorse or promote products derived from this software 17df930be7Sderaadt.\" without specific prior written permission. 18df930be7Sderaadt.\" 19df930be7Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20df930be7Sderaadt.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21df930be7Sderaadt.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22df930be7Sderaadt.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23df930be7Sderaadt.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24df930be7Sderaadt.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25df930be7Sderaadt.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26df930be7Sderaadt.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27df930be7Sderaadt.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28df930be7Sderaadt.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29df930be7Sderaadt.\" SUCH DAMAGE. 30df930be7Sderaadt.\" 31df930be7Sderaadt.\" @(#)route.8 8.3 (Berkeley) 3/19/94 32df930be7Sderaadt.\" 33*95ed13e1Saisha.Dd $Mdocdate: August 2 2023 $ 34df930be7Sderaadt.Dt ROUTE 8 35fc8533a3Saaron.Os 36df930be7Sderaadt.Sh NAME 37df930be7Sderaadt.Nm route 385eaf1a72Saaron.Nd manually manipulate the routing tables 39df930be7Sderaadt.Sh SYNOPSIS 407349792aSaaron.Nm route 41bb74c01aSclaudio.Op Fl dnqtv 4223eb395eSkn.Op Fl T Ar rtable 43df930be7Sderaadt.Ar command 44df930be7Sderaadt.Oo 45881f6c5fSkn.Op Ar modifier ... 46881f6c5fSkn.Ar arg ... 47df930be7Sderaadt.Oc 48df930be7Sderaadt.Sh DESCRIPTION 497ca6c2afSjmcAt system start, 507ca6c2afSjmcrouting tables are initialised and configured by 517ca6c2afSjmc.Xr netstart 8 . 52df930be7SderaadtThe 5358aefd4bSaaron.Nm 547ca6c2afSjmcutility can be used to view or manually manipulate the network routing tables. 557ca6c2afSjmcOnly the superuser may modify the routing tables. 56f5c38b1bSjaredy.Pp 57f5c38b1bSjaredyThe options are as follows: 58df930be7Sderaadt.Bl -tag -width Ds 592b505215Sniklas.It Fl d 607ca6c2afSjmcRun in debug-only mode, i.e. don't actually modify the routing table. 61df930be7Sderaadt.It Fl n 6200fa73dcSjmcBypass attempts to print host and network names symbolically 639615e1d4Saaronwhen reporting actions. 647ca6c2afSjmcThe process of translating between symbolic 65df930be7Sderaadtnames and numerical equivalents can be quite time consuming, and 66df930be7Sderaadtmay require correct operation of the network; thus it may be expedient 677ca6c2afSjmcto forgo this, especially when attempting to repair networking operations. 68df930be7Sderaadt.It Fl q 69df930be7SderaadtSuppress all output. 7023eb395eSkn.It Fl T Ar rtable 7118c3322bSjmcSelect an alternate routing table to modify or query. 725b5cd71cSclaudioThe default is to use the current routing table. 7376efb40cSknThe current routing table can be displayed with 7476efb40cSkn.Xr id 1 . 75f5c38b1bSjaredy.It Fl t 76f5c38b1bSjaredyWrite routing messages to a fake device 77f5c38b1bSjaredy.Pa ( /dev/null ) 78f5c38b1bSjaredyinstead of a real routing socket to test route manipulation. 7900fa73dcSjmc.It Fl v 807ca6c2afSjmcPrint additional details. 81df930be7Sderaadt.El 82df930be7Sderaadt.Pp 837ca6c2afSjmcThe commands are as follows: 847ca6c2afSjmc.Pp 857ca6c2afSjmc.Bl -tag -width "XXXX" -compact 867ca6c2afSjmc.It Xo 877ca6c2afSjmc.Nm route 887ca6c2afSjmc.Op Fl dnqtv 897ca6c2afSjmc.Op Fl T Ar rtable 904e440c72Skn.Tg 917ca6c2afSjmc.Cm add 927ca6c2afSjmc.Op Ar modifier 937ca6c2afSjmc.Ar destination 947ca6c2afSjmc.Ar gateway 957ca6c2afSjmc.Xc 967ca6c2afSjmc.It Xo 977ca6c2afSjmc.Nm route 987ca6c2afSjmc.Op Fl dnqtv 997ca6c2afSjmc.Op Fl T Ar rtable 1004e440c72Skn.Tg 1017ca6c2afSjmc.Cm change 1027ca6c2afSjmc.Op Ar modifier 1037ca6c2afSjmc.Ar destination 1047ca6c2afSjmc.Ar gateway 1057ca6c2afSjmc.Xc 1067ca6c2afSjmcAdd a new route, or modify an existing route, to the host or network at 1077ca6c2afSjmc.Ar destination . 1087ca6c2afSjmc.Ar gateway 1097ca6c2afSjmcis the next-hop intermediary by which packets should be routed. 1107ca6c2afSjmcSee 1117ca6c2afSjmc.Sx Address notation and interpretation 1127ca6c2afSjmcfor more information. 1137ca6c2afSjmc.Pp 1147ca6c2afSjmcA number of modifiers can be used with 1157ca6c2afSjmc.Cm add 1167ca6c2afSjmcand 1177ca6c2afSjmc.Cm change , 1187ca6c2afSjmcand as documented with the other commands: 11924eba409Sjmc.Pp 12024eba409Sjmc.Bl -tag -width Ds -compact 1217ca6c2afSjmc.It Ar flags 1227ca6c2afSjmcVarious flags can be set on routes 1237ca6c2afSjmc(viewable using 1247ca6c2afSjmc.Cm show ) : 1257ca6c2afSjmc.Pp 1267ca6c2afSjmc.Bl -tag -width -blackhole -compact 1277ca6c2afSjmc.It Fl blackhole 1287ca6c2afSjmcsilently discard packets 1297ca6c2afSjmc.It Fl cloning 1307ca6c2afSjmcgenerates a new route on use 1317ca6c2afSjmc.It Fl iface 1327ca6c2afSjmcdestination is directly reachable 1337ca6c2afSjmc.It Fl llinfo 1347ca6c2afSjmcvalidly translates address to link address 1357ca6c2afSjmc.It Fl mpath 1367ca6c2afSjmcmultiple gateways for a destination exist 1377ca6c2afSjmc.It Fl nostatic 1387ca6c2afSjmcpretend route added by kernel or daemon 1397ca6c2afSjmc.It Fl proto1 1407ca6c2afSjmcsets protocol specific routing flag #1 1417ca6c2afSjmc.It Fl proto2 1427ca6c2afSjmcsets protocol specific routing flag #2 1437ca6c2afSjmc.It Fl reject 1447ca6c2afSjmcemits an ICMP unreachable when matched 1457ca6c2afSjmc.It Fl static 1467ca6c2afSjmcmanually added route (default) 1477ca6c2afSjmc.El 1487ca6c2afSjmc.Pp 1497ca6c2afSjmcThe 1507ca6c2afSjmc.Fl blackhole 1517ca6c2afSjmcand 1527ca6c2afSjmc.Fl reject 1537ca6c2afSjmcflags require a 1547ca6c2afSjmc.Ar gateway 1557ca6c2afSjmcto the loopback interface, 1567ca6c2afSjmceither 127.0.0.1 or ::1. 1577ca6c2afSjmc.Pp 1587ca6c2afSjmc.It Oo Fl lock | Fl lockrest Oc Fl expire Ar n 1597ca6c2afSjmc.It Oo Fl lock | Fl lockrest Oc Fl mtu Ar n 1607ca6c2afSjmcSpecify the lifetime for the route (e.g. if generated by a redirect) 1617ca6c2afSjmcor the Maximum Transmission Unit (MTU) size for this path, respectively. 1627ca6c2afSjmcThe value 1637ca6c2afSjmc.Ar n 1647ca6c2afSjmcis locked if preceded by 1657ca6c2afSjmc.Fl lock ; 1667ca6c2afSjmcif preceded by 1677ca6c2afSjmc.Fl lockrest 1687ca6c2afSjmcall following 1697ca6c2afSjmc.Fl expire 1707ca6c2afSjmcand 1717ca6c2afSjmc.Fl mtu 1727ca6c2afSjmcmetrics are locked. 1737ca6c2afSjmc.Pp 1747ca6c2afSjmc.It Fl host | net 1757ca6c2afSjmcInterpret 1767ca6c2afSjmc.Ar destination 1777ca6c2afSjmcas a host or network, respectively. 1787ca6c2afSjmc.Pp 1797ca6c2afSjmc.It Fl ifa Ar address 1807ca6c2afSjmc.It Fl ifp Ar ifname 1817ca6c2afSjmcWhere the destination and gateway are not sufficient to specify 1827ca6c2afSjmcthe route, 1837ca6c2afSjmcthese modifiers may be used to determine the interface address 1847ca6c2afSjmc.Pq Fl ifa 1857ca6c2afSjmcor name 1867ca6c2afSjmc.Pq Fl ifp . 1877ca6c2afSjmc.Pp 1887ca6c2afSjmc.It Fl label Ar label 1897ca6c2afSjmcAssociate the route with a 1907ca6c2afSjmc.Ar label . 1917ca6c2afSjmcRoute labels can be used to attach arbitrary information to a route. 1927ca6c2afSjmc.Pp 1937ca6c2afSjmc.It Fl mpath 1947ca6c2afSjmcUsed to enter multiple gateways for the same destination address (multipath). 1957ca6c2afSjmcWhen multiple routes exist for a destination, one route is selected based 1967ca6c2afSjmcon the source address of the packet. 1977ca6c2afSjmcThe 1987ca6c2afSjmc.Xr sysctl 8 1997ca6c2afSjmcvariables 2007ca6c2afSjmc.Va net.inet.ip.multipath 2017ca6c2afSjmcand 2027ca6c2afSjmc.Va net.inet6.ip6.multipath 2037ca6c2afSjmcare used to control multipath routing. 2047ca6c2afSjmcIf set to 1, 2057ca6c2afSjmcmultiple routes with the same priority are used equally; 2067ca6c2afSjmcif set to 0, 2077ca6c2afSjmcthe first route selected will be used for subsequent packets to that 2087ca6c2afSjmcdestination regardless of source. 2097ca6c2afSjmc.Pp 2107ca6c2afSjmc.It Xo 2117ca6c2afSjmc.Fl mplslabel in Ar label 2127ca6c2afSjmc.Fl push Ns | Ns Fl pop Ns | Ns Fl swap 2137ca6c2afSjmc.Op Fl out Ar label 2147ca6c2afSjmc.Xc 2157ca6c2afSjmcFor MPLS routes, 2167ca6c2afSjmcspecify an ingress LSR to associate a particular label to an IPv4/IPv6 route. 2177ca6c2afSjmcThe MPLS traffic 2187ca6c2afSjmc.Fl in 2197ca6c2afSjmcand 2207ca6c2afSjmc.Fl out 2217ca6c2afSjmcmodifiers are intended to identify the ingress label and, optionally, 2227ca6c2afSjmcthe outgoing one. 2237ca6c2afSjmcAdditionally, one of the following operations must be used: 2247ca6c2afSjmc.Fl push , 2257ca6c2afSjmc.Fl pop 2267ca6c2afSjmcor 2277ca6c2afSjmc.Fl swap . 228a64c693dSjmcThe route's gateway can be specified using the 229a64c693dSjmc.Fl inet 230a64c693dSjmcor 231a64c693dSjmc.Fl inet6 232a64c693dSjmcmodifier before the address. 2337ca6c2afSjmc.Pp 2347ca6c2afSjmc.It Fl netmask Ar mask 2357ca6c2afSjmc.It Fl prefixlen Ar len 2367ca6c2afSjmcUsed to add subnet routes with the specified netmask. 2377ca6c2afSjmcThe netmask should be specified after the 2387ca6c2afSjmc.Ar destination 2397ca6c2afSjmcparameter. 2407ca6c2afSjmcIf no netmask is specified, 2417ca6c2afSjmcan implicit one is used for the 2427ca6c2afSjmc.Dv AF_INET 2437ca6c2afSjmcfamily. 2447ca6c2afSjmcThe network mask can also be specified as a prefix length, 2457ca6c2afSjmcbut in that case one of either 2467ca6c2afSjmc.Fl inet 2477ca6c2afSjmcor 2487ca6c2afSjmc.Fl inet6 2497ca6c2afSjmcmust also be specified. 2507ca6c2afSjmc.Pp 2517ca6c2afSjmc.It Fl priority Ar n 2527ca6c2afSjmcSpecifies a routing priority. 2537ca6c2afSjmcIf no priority is specified, the kernel will set a priority depending on the 2547ca6c2afSjmc.Dv RTF_STATIC 2557ca6c2afSjmcflag to either 2567ca6c2afSjmc.Dv RTP_STATIC 2577ca6c2afSjmcor 2587ca6c2afSjmc.Dv RTP_DEFAULT . 2597ca6c2afSjmcNote that priority 1 is reserved for kernel use. 2607ca6c2afSjmc.El 2617ca6c2afSjmc.Pp 2627ca6c2afSjmc.It Xo 2637ca6c2afSjmc.Nm route 2647ca6c2afSjmc.Op Fl dnqtv 2657ca6c2afSjmc.Op Fl T Ar rtable 2664e440c72Skn.Tg delete 2674e440c72Skn.Tg 2687ca6c2afSjmc.Cm del Ns Op Cm ete 2697ca6c2afSjmc.Ar destination 2707ca6c2afSjmc.Op Fl priority Ar n 2717ca6c2afSjmc.Op Ar gateway 2727ca6c2afSjmc.Xc 2737ca6c2afSjmcDelete the route to 2747ca6c2afSjmc.Ar destination . 2757ca6c2afSjmcIf multiple routes to the destination exist, 2767ca6c2afSjmca specific route must be selected by specifying the priority 2777ca6c2afSjmcand/or a gateway. 2787ca6c2afSjmc.Pp 2796dfdfa6aSderaadt.It Xo 2806dfdfa6aSderaadt.Nm route 28123eb395eSkn.Op Fl T Ar rtable 2824e440c72Skn.Tg 2836dfdfa6aSderaadt.Cm exec 284*95ed13e1Saisha.Ar command 285*95ed13e1Saisha.Op Ar arg ... 2866dfdfa6aSderaadt.Xc 2877ca6c2afSjmcExecute a command, forcing the process and its children to use the 2885b5cd71cSclaudiorouting table and appropriate routing domain as specified with the 28923eb395eSkn.Fl T Ar rtable 2906dfdfa6aSderaadtoption. 29124eba409Sjmc.Pp 2926dfdfa6aSderaadt.It Xo 2936dfdfa6aSderaadt.Nm route 2946dfdfa6aSderaadt.Op Fl nqv 29523eb395eSkn.Op Fl T Ar rtable 2964e440c72Skn.Tg 297df930be7Sderaadt.Cm flush 2987ca6c2afSjmc.Op Ar family 2997ca6c2afSjmc.Op Fl iface Ar ifname 3007ca6c2afSjmc.Op Fl priority Ar n 3016dfdfa6aSderaadt.Xc 3027ca6c2afSjmcDelete all gateway entries from the routing table, 3037ca6c2afSjmcoptionally limited to a specific address family. 3047ca6c2afSjmcRoutes matching a specific interface or priority can be flushed 305349ea712Sclaudioby using the 306349ea712Sclaudio.Fl iface 307349ea712Sclaudioor 308349ea712Sclaudio.Fl priority 309349ea712Sclaudiomodifiers. 31024eba409Sjmc.Pp 3116dfdfa6aSderaadt.It Xo 3127ca6c2afSjmc.Bk -words 3136dfdfa6aSderaadt.Nm route 3146dfdfa6aSderaadt.Op Fl nv 31523eb395eSkn.Op Fl T Ar rtable 3164e440c72Skn.Tg 3176dfdfa6aSderaadt.Cm get 3187ca6c2afSjmc.Ar destination 3197ca6c2afSjmc.Op Fl priority Ar n 3207ca6c2afSjmc.Op Ar gateway 3217ca6c2afSjmc.Ek 3226dfdfa6aSderaadt.Xc 3237ca6c2afSjmcDisplay the route to 3247ca6c2afSjmc.Ar destination . 3257ca6c2afSjmcIf multiple routes to the destination exist, 3267ca6c2afSjmca specific route may be selected by specifying the priority 3277ca6c2afSjmcand/or a gateway. 32824eba409Sjmc.Pp 3296dfdfa6aSderaadt.It Xo 3305329634eSreyk.Nm 3316dfdfa6aSderaadt.Op Fl n 33270a31d6aSbenno.Op Fl T Ar rtable 3334e440c72Skn.Tg 334f5c38b1bSjaredy.Cm monitor 3357ca6c2afSjmc.Op Ar family 3367ca6c2afSjmc.Op Fl iface 3376dfdfa6aSderaadt.Xc 3387ca6c2afSjmcContinuously report any changes to the routing information base. 3397ca6c2afSjmcThe information reported can be limited to a specific address family, 3407ca6c2afSjmca specific routing table 3417ca6c2afSjmcusing the 3427ca6c2afSjmc.Fl T 3437ca6c2afSjmcoption, 3447ca6c2afSjmcor interface specific messages (link state changes) using the 345ce9a50d7Sclaudio.Fl iface 3467ca6c2afSjmcmodifier. 34724eba409Sjmc.Pp 348475f43fbSjmc.It Xo 349475f43fbSjmc.Ic route 350475f43fbSjmc.Op Fl dtv 351475f43fbSjmc.Op Fl T Ar rtable 3524e440c72Skn.Tg 353475f43fbSjmc.Cm nameserver 35485e0fa93Skn.Ar interface 355636045afSjmc.Op Ar address ... 356475f43fbSjmc.Xc 357f5291493SjmcBroadcast a list of up to five nameserver address proposals to 358f5291493Sjmc.Xr resolvd 8 , 359cf0b80f8Sjsgwhich is used to update the list of nameservers for the given interface in 360636045afSjmc.Xr resolv.conf 5 . 361f5291493SjmcIf no address is given, 362f5291493Sjmca request to remove the nameservers for the given interface is sent. 36324eba409Sjmc.Pp 3646dfdfa6aSderaadt.It Xo 3656dfdfa6aSderaadt.Nm route 3666dfdfa6aSderaadt.Op Fl nv 36723eb395eSkn.Op Fl T Ar rtable 3684e440c72Skn.Tg 369f5c38b1bSjaredy.Cm show 370f5c38b1bSjaredy.Op Ar family 371bb74c01aSclaudio.Op Fl gateway 372e1aca1feSkrw.Op Fl label Ar label 3737ca6c2afSjmc.Op Fl priority Ar n 3746dfdfa6aSderaadt.Xc 3756a5148d0SjmcDisplay the routing table. 376f5c38b1bSjaredy.Pp 377bb74c01aSclaudioIf 378bb74c01aSclaudio.Fl gateway 379bb74c01aSclaudiois specified, only routes whose gateway are in the 380bb74c01aSclaudiosame address family as the destination are shown. 381e1aca1feSkrw.Pp 382e1aca1feSkrwIf 383e1aca1feSkrw.Fl label 384e1aca1feSkrwis specified, only routes with the specified label are shown. 38572ba3a7eSphessler.Pp 38672ba3a7eSphesslerIf 38772ba3a7eSphessler.Fl priority 38869de228eSjmcis specified, only routes with the specified priority are shown. 38969de228eSjmcIt may be specified by number or one of 39069de228eSjmc.Cm local , 39169de228eSjmc.Cm connected , 39269de228eSjmc.Cm static , 39369de228eSjmc.Cm ospf , 39469de228eSjmc.Cm rip , 39569de228eSjmcor 39669de228eSjmc.Cm bgp . 39772ba3a7eSphesslerIf the priority is negative, then routes that do not match the numeric 39872ba3a7eSphesslerpriority are shown. 3996a5148d0Sjmc.Pp 4006a5148d0SjmcWithin the output of 4016a5148d0Sjmc.Cm show , 4026a5148d0Sjmcthe "Flags" column indicates what flags are set on the route. 4036a5148d0SjmcThe mapping between letters and flags is: 4046a5148d0Sjmc.Bl -column "1" "RTF_BLACKHOLE" "Protocol specific routing flag #1." 405633cc5e8Skn.It Dv 1 Ta Dv RTF_PROTO1 Ta "Protocol specific routing flag #1." 406633cc5e8Skn.It Dv 2 Ta Dv RTF_PROTO2 Ta "Protocol specific routing flag #2." 407633cc5e8Skn.It Dv 3 Ta Dv RTF_PROTO3 Ta "Protocol specific routing flag #3." 408633cc5e8Skn.It Dv B Ta Dv RTF_BLACKHOLE Ta "Just discard packets." 409633cc5e8Skn.It Dv b Ta Dv RTF_BROADCAST Ta "Correspond to a local broadcast address." 410633cc5e8Skn.It Dv C Ta Dv RTF_CLONING Ta "Generate new routes on use." 411633cc5e8Skn.It Dv c Ta Dv RTF_CLONED Ta "Cloned routes (generated from RTF_CLONING)." 412633cc5e8Skn.It Dv D Ta Dv RTF_DYNAMIC Ta "Created dynamically (by redirect)." 413633cc5e8Skn.It Dv G Ta Dv RTF_GATEWAY Ta "Dest requires forwarding by intermediary." 414633cc5e8Skn.It Dv H Ta Dv RTF_HOST Ta "Host entry (net otherwise)." 415633cc5e8Skn.It Dv h Ta Dv RTF_CACHED Ta "Referenced by gateway route." 416633cc5e8Skn.It Dv L Ta Dv RTF_LLINFO Ta "Valid protocol to link address translation." 417633cc5e8Skn.It Dv l Ta Dv RTF_LOCAL Ta "Correspond to a local address." 418633cc5e8Skn.It Dv M Ta Dv RTF_MODIFIED Ta "Modified dynamically (by redirect)." 419633cc5e8Skn.It Dv m Ta Dv RTF_MULTICAST Ta "Correspond to a multicast address." 420633cc5e8Skn.It Dv n Ta Dv RTF_CONNECTED Ta "Interface route." 421633cc5e8Skn.It Dv P Ta Dv RTF_MPATH Ta "Multipath route." 422633cc5e8Skn.It Dv R Ta Dv RTF_REJECT Ta "Host or net unreachable." 423633cc5e8Skn.It Dv S Ta Dv RTF_STATIC Ta "Manually added." 424633cc5e8Skn.It Dv T Ta Dv RTF_MPLS Ta "MPLS route." 425633cc5e8Skn.It Dv U Ta Dv RTF_UP Ta "Route usable." 4266a5148d0Sjmc.El 427bb74c01aSclaudio.Pp 42872366f00Sdenis.It Xo 42972366f00Sdenis.Ic route 43072366f00Sdenis.Op Fl T Ar rtable 4314e440c72Skn.Tg 43272366f00Sdenis.Cm sourceaddr 43373a1b077Sjmc.Op Fl ifp Ar ifname | Ar address 43472366f00Sdenis.Xc 43573a1b077SjmcSet the preferred source address to 43673a1b077Sjmc.Ar address . 43773a1b077SjmcThe source address can be set to the address assigned to interface 4387ca6c2afSjmc.Ar ifname 43973a1b077Sjmcif 44073a1b077Sjmc.Fl ifp 44173a1b077Sjmcis specified, 44273a1b077Sjmcor reset by setting the address to zero. 44373a1b077SjmcIf no arguments are given, 44473a1b077Sjmcthe preferred source addresses are printed. 4457ca6c2afSjmcThe preferred source address is not used if the destination is on-link 4467ca6c2afSjmcor the source address is assigned to a disabled interface. 44772366f00Sdenis.El 4487ca6c2afSjmc.Ss Address notation and interpretation 4497ca6c2afSjmcAddresses are assumed to be IPv4 unless they contain a colon, 4507ca6c2afSjmcin which case they are treated as IPv6. 4517ca6c2afSjmcAlternatively they may be specified as belonging to a particular address family 4527ca6c2afSjmcusing one of the following modifiers: 45372366f00Sdenis.Pp 4547ca6c2afSjmc.Bl -tag -width "-inet6XXX" -offset indent -compact 455f5c38b1bSjaredy.It Fl inet 4567ca6c2afSjmcIPv4 addresses; 4577ca6c2afSjmcsee 4587ca6c2afSjmc.Xr ip 4 459f5c38b1bSjaredy.It Fl inet6 4607ca6c2afSjmcIPv6 addresses; 4617ca6c2afSjmcsee 4627ca6c2afSjmc.Xr ip6 4 463f5c38b1bSjaredy.It Fl link 4647ca6c2afSjmchardware (link-level) addresses 465b7ba21daSmichele.It Fl mpls 466f390ed78SjmcMPLS addresses 467f5c38b1bSjaredy.It Fl sa 4687ca6c2afSjmcactual 469f5c38b1bSjaredy.Vt sockaddr 470f5c38b1bSjaredydata, in hexadecimal format 471f5c38b1bSjaredy.El 472f5c38b1bSjaredy.Pp 47300fa73dcSjmc.Ar destination 4747ca6c2afSjmcis assumed to be a route to a network 4757ca6c2afSjmcif any of the following apply: 476df930be7Sderaadt.Pp 4777ca6c2afSjmc.Bl -bullet -compact 4787ca6c2afSjmc.It 479df930be7Sderaadtthe 4807ca6c2afSjmc.Fl net 4817ca6c2afSjmcmodifier is used 4827ca6c2afSjmc.It 4837ca6c2afSjmcit is the word "default", equivalent to 0/0 or ::/0 4847ca6c2afSjmc.It 4857ca6c2afSjmcit is an address with a 4867ca6c2afSjmc.Dq / Ns Em XX 4877ca6c2afSjmcsuffix, where 4887ca6c2afSjmc.Em XX 4897ca6c2afSjmcis the number of bits in the network portion of the address 4907ca6c2afSjmc.It 4917ca6c2afSjmcit specifies the network portion either with 4927ca6c2afSjmc.Fl netmask 493df930be7Sderaadtor 4947ca6c2afSjmc.Fl prefixlen 4957ca6c2afSjmc.El 496df930be7Sderaadt.Pp 4977ca6c2afSjmcIf 4987ca6c2afSjmc.Ar destination 4997ca6c2afSjmcis a valid IP address or host name, 5007ca6c2afSjmcor the 5017ca6c2afSjmc.Fl host 5027ca6c2afSjmcmodifier is used, 5037ca6c2afSjmcit is assumed to be a route to a host. 504f5c38b1bSjaredy.Pp 505df930be7SderaadtAll symbolic names specified for a 506df930be7Sderaadt.Ar destination 507df930be7Sderaadtor 508df930be7Sderaadt.Ar gateway 509ba318fafSschwarzeare looked up using 510ba318fafSschwarze.Xr gethostbyname 3 . 511e3a14731Sjmc.Sh FILES 5128b079fa5Sschwarze.Bl -tag -width "/etc/mygate" -compact 513f5c38b1bSjaredy.It Pa /etc/hosts 5148b079fa5Sschwarzehost and network name database 515e3a14731Sjmc.It Pa /etc/mygate 516f5c38b1bSjaredydefault gateway address 517e3a14731Sjmc.El 518*95ed13e1Saisha.Sh EXIT STATUS 519*95ed13e1SaishaFor commands other than 520*95ed13e1Saisha.Cm exec , 521*95ed13e1Saishathe 522*95ed13e1Saisha.Nm 523*95ed13e1Saishautility exits 0 on success, and >0 if an error occurs. 524*95ed13e1Saisha.Pp 525*95ed13e1SaishaFor the 526*95ed13e1Saisha.Cm exec 527*95ed13e1Saishacommand the 528*95ed13e1Saisha.Nm 529*95ed13e1Saishautility exits with the exit status of 530*95ed13e1Saisha.Ar command 531*95ed13e1Saishaif it could be invoked. 532*95ed13e1SaishaOtherwise the 533*95ed13e1Saisha.Nm 534*95ed13e1Saishautility exits with one of the following values: 535*95ed13e1Saisha.Bl -tag -width Ds 536*95ed13e1Saisha.It 1 537*95ed13e1SaishaAn invalid command line option was passed to 538*95ed13e1Saisha.Nm 539*95ed13e1Saishaor setting the routing table failed. 540*95ed13e1Saisha.It 126 541*95ed13e1Saisha.Ar command 542*95ed13e1Saishawas found but could not be invoked. 543*95ed13e1Saisha.It 127 544*95ed13e1Saisha.Ar command 545*95ed13e1Saishacould not be found. 546*95ed13e1Saisha.El 547c5a53718Sjmc.Sh EXAMPLES 5487ca6c2afSjmcShow the current IPv4 routing tables, 5497ca6c2afSjmcwithout attempting to print hostnames symbolically: 5507ca6c2afSjmc.Pp 5517ca6c2afSjmc.Dl $ route -n show -inet 5527ca6c2afSjmc.Pp 553c5a53718SjmcAdd a static 554c5a53718Sjmc.Xr inet 4 555c5a53718Sjmcroute to the 192.168.5.0/24 network via the 192.168.0.1 gateway: 556c5a53718Sjmc.Pp 557c5a53718Sjmc.Dl # route add -inet 192.168.5.0/24 192.168.0.1 558c5a53718Sjmc.Pp 559c5a53718SjmcAmend the 560c5a53718Sjmc.Xr inet 4 561c5a53718Sjmcroute to the 192.168.5.0/24 network to use the 192.168.0.2 gateway: 562c5a53718Sjmc.Pp 563c5a53718Sjmc.Dl # route change -inet 192.168.5.0/24 192.168.0.2 564c5a53718Sjmc.Pp 565c5a53718SjmcDelete the 566c5a53718Sjmc.Xr inet 4 567c5a53718Sjmcroute to the 192.168.5.0/24 network: 568c5a53718Sjmc.Pp 569c5a53718Sjmc.Dl # route delete -inet 192.168.5.0/24 5709e4d7689Skn.Pp 5718953024cSsthenAdd a static 5728953024cSsthen.Xr inet6 4 5738953024cSsthenroute to a host which is on the vio0 interface that is outside your prefix, 5748953024cSsthenand use that host as a default gateway, as used by some hosting providers: 5758953024cSsthen.Pp 5768953024cSsthen.Dl # route add -inet6 2001:db8:efef::1 -cloning -link -iface vio0 5778953024cSsthen.Dl # route add -inet6 default 2001:db8:efef::1 578df930be7Sderaadt.Sh DIAGNOSTICS 579eb319f3dSjmc.Bl -diag 580eb319f3dSjmc.It "%s: gateway %s flags %x" 581eb319f3dSjmcThe specified route is being added to or deleted from the tables. 582df930be7SderaadtIf the gateway address used was not the primary address of the gateway 583df930be7Sderaadt(the first one returned by 584df930be7Sderaadt.Xr gethostbyname 3 ) , 585df930be7Sderaadtthe gateway address is printed numerically as well as symbolically. 586eb319f3dSjmc.It "%s %s done" 587df930be7SderaadtWhen the 588df930be7Sderaadt.Cm flush 589df930be7Sderaadtcommand is specified, each routing table entry deleted 590df930be7Sderaadtis indicated with a message of this form. 591eb319f3dSjmc.It "Network is unreachable" 592df930be7SderaadtAn attempt to add a route failed because the gateway listed was not 593892a7bb8Saaronon a directly connected network. 594df930be7SderaadtThe next-hop gateway must be given. 595eb319f3dSjmc.It "not in table" 5965eaf1a72SaaronA 5975eaf1a72Saaron.Cm delete 5985eaf1a72Saaronoperation was attempted for an entry which 599df930be7Sderaadtwasn't present in the tables. 600eb319f3dSjmc.It "routing table overflow" 6015eaf1a72SaaronAn 6025eaf1a72Saaron.Cm add 6035eaf1a72Saaronoperation was attempted, but the system was 604df930be7Sderaadtlow on resources and was unable to allocate memory 605df930be7Sderaadtto create the new entry. 606df930be7Sderaadt.El 607df930be7Sderaadt.Sh SEE ALSO 608f5c38b1bSjaredy.Xr gethostbyname 3 , 6097ca6c2afSjmc.Xr inet_net_pton 3 , 6107ca6c2afSjmc.Xr inet_pton 3 , 611df930be7Sderaadt.Xr route 4 , 61276efb40cSkn.Xr rtable 4 , 613f5c38b1bSjaredy.Xr hosts 5 , 614e3a14731Sjmc.Xr mygate 5 , 6157ca6c2afSjmc.Xr netstart 8 616df930be7Sderaadt.Sh HISTORY 617df930be7SderaadtThe 618df930be7Sderaadt.Nm 619df930be7Sderaadtcommand appeared in 620df930be7Sderaadt.Bx 4.2 . 621d8435f62SitojunIPv6 support was added by WIDE/KAME project. 622f5c38b1bSjaredy.Pp 623f5c38b1bSjaredyThe 624f5c38b1bSjaredy.Fl recvpipe , 625f5c38b1bSjaredy.Fl hopcount , 626f5c38b1bSjaredy.Fl sendpipe , 627873f6148Skn.Fl ssthresh , 628f5c38b1bSjaredy.Fl rtt , 629f5c38b1bSjaredyand 630f5c38b1bSjaredy.Fl rttvar 631f5c38b1bSjaredymodifiers used to be used to initialize various quantities in routing 632f5c38b1bSjaredytable entries. 633f5c38b1bSjaredyThe routing system no longer uses these values and the modifiers 634f5c38b1bSjaredyexist now only for compatibility with other operating systems. 635df930be7Sderaadt.Sh BUGS 636d8435f62SitojunSome uses of the 637d8435f62Sitojun.Fl ifa 638d8435f62Sitojunor 639d8435f62Sitojun.Fl ifp 6408d301c2bSjmcmodifiers with the 6418d301c2bSjmc.Cm add 6428d301c2bSjmccommand will incorrectly fail with a 643d8435f62Sitojun.Dq Network is unreachable 644d8435f62Sitojunmessage if there is no default route. 645d8435f62SitojunSee case 646d8435f62Sitojun.Dv RTM_ADD 647d8435f62Sitojunin 648eb319f3dSjmc.Fn route_output 649eb319f3dSjmcfrom 650eb319f3dSjmc.Pa sys/net/rtsock.c 651d8435f62Sitojunfor details. 652