pavement

Route

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
m (changed wording on Microsoft Windows equivalents)
m (The default gateway is documented under gateway)
 
(3 intermediate revisions by one user not shown)
Line 52: Line 52:
  
 
The '''monitor''' command continuously displays changes to or queries from 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 192.168.0.1
 +
add net default: gateway 192.168.0.1
 +
 +
The 'default' option is an inbuilt alias for the default gateway and '192.168.0.1' is the router IP in this instance.
 +
 +
=== Manual route ===
 +
 +
Adding a static route is done using the following command:
 +
 +
#route add -net 192.168.20.0/24 192.168.0.2
 +
add net 192.168.20.0: gateway 192.168.0.2
 +
 +
The '192.168.20.0/24' is the subnet of the remote network, which would have been specified as '192.168.20.0 mask 255.255.255.0' on Microsoft Windows or '192.168.20.0 netmask 255.255.255.0' on Linux and other platforms.  The '192.168.0.2' is the router IP connecting to the remote network.
 +
 +
=== Delete route ===
 +
 +
Deleting a route is done using the following command:
 +
 +
#route delete 192.168.20.0
 +
delete net 192.168.20.0
 +
 +
The '192.168.20.0' is the route entry being deleted.  This can also be specified as '192.168.20.0/24' where a more specific route is used.
  
 
== Microsoft Windows equivalents ==
 
== Microsoft Windows equivalents ==

Latest revision as of 06:22, 24 January 2008

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.

Contents

[edit] Usage

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.

[edit] Debug

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.

[edit] 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.

[edit] Verbosity

The -v option presents additional information on the screen.

[edit] Quiet

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

[edit] Commands

The following commands are exist:

[edit] Add

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

[edit] Flush

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

[edit] Delete

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

[edit] Change

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

[edit] Get

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

[edit] Monitor

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

[edit] 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.

[edit] Default route (gateway)

Adding a default gateway is done using the following command:

#route add -net default 192.168.0.1
add net default: gateway 192.168.0.1

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

[edit] Manual route

Adding a static route is done using the following command:

#route add -net 192.168.20.0/24 192.168.0.2
add net 192.168.20.0: gateway 192.168.0.2

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

[edit] Delete route

Deleting a route is done using the following command:

#route delete 192.168.20.0
delete net 192.168.20.0

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

[edit] 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

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

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

[edit] See also

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

Personal tools