{{Short description|Computer operating system command}} {{Other uses of|route|Route (disambiguation)}} {{Lowercase title}} {{Infobox software | name = route | logo = | screenshot = ReactOS-0.4.13 route command 667x514.png | screenshot size = | caption = The ReactOS <code>route</code> command | developer = Fred N. van Kempen, Microsoft, IBM, ReactOS Contributors | released = | latest release version = | latest release date = | operating system = Unix-like, OS/2, Microsoft Windows, ReactOS | platform = Cross-platform | genre = Command | license = OS/2, Windows: Proprietary commercial software<br />ReactOS: GPLv2 | website = }} In computing, <code>'''route'''</code> is a command used to view and manipulate the IP routing table in Unix-like and Microsoft Windows<ref>{{Cite web |url=http://www.howtogeek.com/howto/windows/adding-a-tcpip-route-to-the-windows-routing-table/ |title=Adding a TCP/IP Route to the Windows Routing Table |access-date=2016-11-13 |archive-date=2016-11-13 |archive-url=https://web.archive.org/web/20161113120145/http://www.howtogeek.com/howto/windows/adding-a-tcpip-route-to-the-windows-routing-table/ |url-status=dead }}</ref> operating systems and also in IBM OS/2 and ReactOS.<ref name=react>{{Cite web|url=https://github.com/reactos/reactos/blob/master/base/applications/network/route/route.c|title = Reactos/Reactos|website = GitHub|date = 4 November 2021}}</ref> Manual manipulation of the routing table is characteristic of static routing.

==Implementations== ===Unix and Unix-like=== The {{code|route}} command originated in 4.2BSD. It is not part of any UNIX standard, but the BSD interface is widely implemented.<ref>{{Man|8|route|FreeBSD}}</ref>

Linux contains a version of the {{code|route}} originally written by Fred N. van Kempen, later merged with <code>netstat</code>'s codebase (another command originating in 4.2BSD). It implements an extended syntax compared to the BSD version. In Linux distributions based on 2.2.x Linux kernels, the <code>ifconfig</code> and <code>route</code> commands are operated together to connect a computer to a network, and to define routes between computer networks. Distributions based on later kernels have deprecated <code>ifconfig</code> and <code>route</code>, replacing them with <code>iproute2</code>.<ref>{{man|8|route|Linux}}</ref>

On macOS, the <code>route</code> utility is present but largely nonfunctional. Displaying the routing table is instead performed via <code>netstat -nr</code>.

====Syntax==== The BSD syntax is: <syntaxhighlight lang="shell"> route [-dnqtv] {add|del|flush|get|monitor} [[modifiers] args] </syntaxhighlight>

The Linux syntax is: <syntaxhighlight lang="shell"> route [-nNvee] [-FC] [<AF>] # List kernel routing tables route [-v] [-FC] {add|del|flush} ... # Modify routing table for AF. route {-h|--help} [<AF>] # Detailed usage syntax for specified AF. route {-V|--version} # Display version/author and exit. </syntaxhighlight>

In other words, the basic <code>route add</code> and <code>route del</code> commands are portable.

====Example==== <syntaxhighlight lang="console"> user@linux:~$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.101.0 192.168.102.102 255.255.255.0 UG 0 0 0 eth0 192.168.102.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.103.0 192.168.102.102 255.255.255.0 UG 0 0 0 eth0 192.168.12.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 0.0.0.0 192.168.12.1 0.0.0.0 UG 0 0 0 eth0 </syntaxhighlight>

===Microsoft Windows=== The command is only available if the TCP/IP protocol is installed as a component in the properties of a network adapter. ====Syntax==== The command-syntax is: <syntaxhighlight lang="dos"> route [-f] [-p] [-4|-6] [Command [Destination] [mask Netmask] [Gateway] metric Metric if Interface </syntaxhighlight>

====Parameters==== * <kbd>'''-f'''</kbd>: Clears the routing table * <kbd>'''-p'''</kbd>: The route is added to the Windows Registry and is used to initialize the IP routing table whenever the TCP/IP protocol is started (only when used with the <kbd>add</kbd> command) * <kbd>'''Command'''</kbd>: The command to run (<kbd>add</kbd>, <kbd>change</kbd>, <kbd>delete</kbd>, <kbd>print</kbd>) * <kbd>'''-4'''</kbd>: Force using IPv4 * <kbd>'''-6'''</kbd>: Force using IPv6 * <kbd>'''Destination'''</kbd>: Network destination of the route * <kbd>'''mask Netmask'''</kbd>: The netmask (subnet mask) associated with the network destination * <kbd>'''Gateway'''</kbd>: The forwarding or next hop IP address over which the set of addresses defined by the network destination and subnet mask are reachable * <kbd>'''metric Metric'''</kbd>: Integer cost metric (ranging from 1 to 9999) for the route * <kbd>'''if Interface'''</kbd>: The index of the interface over which the destination is reachable * <kbd>'''/?'''</kbd>: Command help

The <kbd>-p</kbd> parameter is only supported on Windows NT 4.0, Windows 2000, Windows Millennium Edition, and Windows XP. It is not supported on Windows 95 or Windows 98.

===IBM OS/2=== ====Syntax==== The command-syntax is: <syntaxhighlight lang="dos"> route [-nqv] [COMMAND] [[MODIFIERS] args] </syntaxhighlight>

====Parameters==== * <kbd>'''-n'''</kbd>: Bypasses translating IP addresses to symbolic host names * <kbd>'''-q'''</kbd>: Suppresses all output * <kbd>'''-v'''</kbd>: Verbose * <kbd>'''COMMAND'''</kbd>: The command to run (<kbd>add</kbd>, <kbd>delete</kbd>, <kbd>change</kbd>, <kbd>get</kbd>, <kbd>monitor</kbd>, <kbd>flush</kbd>) * <kbd>'''-net'''</kbd>: <kbd><dest></kbd> is a network address * <kbd>'''-host'''</kbd>: <kbd><dest></kbd> is host name or address (default) * <kbd>'''-netmask'''</kbd>: the mask of the route * <kbd>'''<dest>'''</kbd>: IP address or host name of the destination * <kbd>'''<gateway>'''</kbd>: IP address or host name of the next-hop router

===ReactOS=== ReactOS is an open-source Windows clone. The {{code|route}} implementation will eventually cover all options supported by Windows, but the current (as of 2025) version does not. It instead implements a subset of the options, a "poor man's route":<ref name=react/>

====Syntax==== Print the route table: <syntaxhighlight lang="dos"> route print </syntaxhighlight> Add a route: <syntaxhighlight lang="dos"> route add <target> [mask <mask>] <gw> [metric <m>] </syntaxhighlight> Delete a route: <syntaxhighlight lang="dos"> route delete <target> <gw> </syntaxhighlight>

==See also== * Routing table * Internet Protocol Suite * iproute2 * BusyBox

==Further reading== *{{Cite book|title=Microsoft Windows Command-Line Administrator's Pocket Consultant|year=2004|url=https://archive.org/details/microsoftwindows0000stan_b1p0|url-access=registration|first=William R.|last=Stanek|isbn=0-735-62038-5}} *{{Cite book|author=John Paul Mueller|year=2007|title=Windows Administration at the Command Line for Windows Vista, Windows 2003, Windows XP, and Windows 2000|publisher=John Wiley & Sons|isbn=978-0470165799}}

==References== {{Reflist}}

==External links== {{Wikibooks|Guide to Windows Commands}} * {{man|8|route|4.2BSD}} * {{man|8|route|die.net}} * {{man|8|route|FreeBSD}} * {{man|8|route|Solaris}} * [https://technet.microsoft.com/en-us/library/bb490991.aspx route] - on [https://technet.microsoft.com technet.microsoft.com]

{{Windows commands}}

Category:Internet Protocol based network software Category:OS/2 commands Category:Routing Category:Unix network-related software Category:Windows communication and services Category:Windows administration