my-server
← Wiki

Route (command)

In computing, <code>route</code> is a command used to view and manipulate the IP routing table in Unix-like and Microsoft Windows operating systems and also in IBM OS/2 and ReactOS. Manual manipulation of the routing table is characteristic of static routing.

Implementations

Unix and Unix-like

The command originated in 4.2BSD. It is not part of any UNIX standard, but the BSD interface is widely implemented.

Linux contains a version of the 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>.

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:

The Linux syntax is:

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

Example

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:

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:

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 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":

Syntax

Print the route table:

Add a route:

Delete a route:

See also

Further reading

References

External links