From FreeBSDwiki
Jump to: navigation, search
The Mediawiki system (the 'software' that runs this site) capitalises all articles. Please note that commands on most UNIX and Unix-like systems are entered in lower case. As an example the article documenting the Ln command would be issued from the command line as 'ln'.

The route command is used to manually configure the routing on FreeBSD. It differs in usage from the Microsoft command of the same name which can confuse system administrators migrating across platforms.

Typically the route command is not required since advanced routing requirements would ordinarily be maintained by the routed daemon.



The command itself has only a few options but makes up for this with what is described as a programmatic command language interface. The available options are as follows.


The -d option executes the request but does not implement it. It allows the request to be tested to ensure there are no issues arising from doing so.

Name resolution

The -n option instructs the route command to not resolve IP addresses to DNS names. This is useful where name resolution may slow down the presentation of information or otherwise where no DNS name servers are available or configured for use.


The -v option presents additional information on the screen.


The -q option suppresses information for certain commands, namely; 'add', 'change' and 'flush' (see below).


The following commands are exist:


The add command creates a new route entry into the routing table.


The flush command removes all routes from the routing table (use with caution).


The delete command removes a single route entry from the routing table.


The change command changes a specific element of a route already in the routing table.


The get command displays a specific entry of the routing table.


The monitor command continuously displays changes to or queries from the routing table.

Example use

Note: the following commands will modify the routing table but any changes will be lost upon the next reboot. See articles in the 'See also' section below for more advanced methods of route management.

Default route (gateway)

Adding a default gateway is done using the following command:

#route add -net default
add net default: gateway

The 'default' option is an inbuilt alias for the default gateway and '' is the router IP in this instance.

Manual route

Adding a static route is done using the following command:

#route add -net
add net gateway

The '' is the subnet of the remote network, which would have been specified as ' mask' on Microsoft Windows or ' netmask' on Linux and other platforms. The '' is the router IP connecting to the remote network.

Delete route

Deleting a route is done using the following command:

#route delete
delete net

The '' is the route entry being deleted. This can also be specified as '' where a more specific route is used.

Microsoft Windows equivalents

Many system administrators from the Microsoft world will be used to using the route show command to display current routing table information. This is not available from the FreeBSD command of the same name. However it is available using netstat -r command instead.

$ netstat -r
Routing tables

Destination        Gateway            Flags    Refs      Use  Netif Expire
default           UGS         0  1822642   fxp0
localhost          localhost          UH          0     3946    lo0
172.27/24          link#1             UC          0        0   fxp0         00:02:a5:77:5c:29  UHLW        2        0   fxp0   1193
mail               00:02:a5:84:d3:10  UHLW        1    22373    lo0

Destination        Gateway            Flags      Netif Expire
localhost.domain   localhost.domain   UH          lo0
fe80::%fxp0        link#1             UC         fxp0
fe80::202:a5ff:fe8 00:02:a5:84:d3:10  UHL         lo0
fe80::%lo0         fe80::1%lo0        U           lo0
fe80::1%lo0        link#3             UHL         lo0
ff01:1::           link#1             UC         fxp0
ff01:3::           localhost.domain   UC          lo0
ff02::%fxp0        link#1             UC         fxp0
ff02::%lo0         localhost.domain   UC          lo0

See also

See also the articles on netstat, Network Configuration (basic) and Network Configuration (Advanced).

Personal tools