route(1Mtcp)


route -- manually manipulate the routing tables

Synopsis

Add a route:
route [ -nqv ] add [ -netmask new_mask ] [ [ -lock | -lockrest ] -metric value ] . . . [ [ -ifa|-ifp ] interface_spec ] [ modifier . . . ] [ -host | -net ] destination [ -interface | -gateway ] gateway

Change a route's parameters:
route [ -nqv ] change [ -netmask new_mask ] [ [ -lock | -lockrest ] -metric value ] . . . [ [ -ifa|-ifp ] interface_spec ] [ modifier . . . ] [ -host | -net ] destination [ -interface | -gateway ] gateway

Delete a route:
route [ -nqv ] delete [ -host | -net ] destination [ -interface | -gateway ] gateway

Flush routes:
route [ -nqv ] flush [ -inet ]

Get a route:
route [ -nqv ] get [ -host | -net ] destination [ [ -interface | -gateway ] gateway ]

Monitor routes:
route [ -n ] monitor

Description

The route command allows you to manipulate the network routing tables.

Only root may use the route command.

route understands the following options:


-n
Prevents attempts to print host and network names symbolically when reporting actions. This can speed up actions.

-q
Suppresses all output. This can speed up actions such as flushing routes.

-v
Displays additional details (verbose mode).

route accepts the following commands:

add
Add a route.

change
Change the parameters of a route, such as its metrics, whether it is rejected, and whether it uses path MTU discovery.

delete
Delete a specific route.

flush
Remove all gateway entries from the routing tables.

get
Look up and display the route for a destination.

monitor
Continuously report any changes to the routing information base, routing lookup misses, or suspected subnetwork partitioning.
destination specifies the destination host or network. gateway specifies the next-hop gateway to which packets should be addressed. The destination and gateway can be specified by IP addresses or names. route looks up all symbolic names specified for a destination or a gateway using gethostbyname(3N). If this fails, it uses getnetbyname(3N) to interpret the name as that of a network.

For those destinations that do not require a unique routing table entry, use default as the destination parameter. In the following example, gator is the hostname of the gateway machine:

route add default gator

route accepts the following command modifiers. Note that some modifiers only work with certain commands:


-cloning
Mark a route via an interface as suitable for cloning. For example, this is used to derive new multicast routes from the multicast address 224.

-gateway gateway
Specify a gateway.

-host destination
Force destination to be interpreted as a host.

-interface gateway
Specify that gateway is to be interpreted as the address of an interface on this host rather than as the address of a remote gateway. The specified interface will be used as a route for transmission. This modifier is equivalent to the old and deprecated syntax of specifying ``0'' after gateway.

This option may also be specified as -iface.


-ifa interface_spec
Interpret interface_spec as an interface address. This option is only needed when the destination and gateway are not sufficient to identify the route for add or change commands.

-ifp interface_spec
Interpret interface_spec as an interface name. This option is only needed when the destination and gateway are not sufficient to identify the route for add or change commands.

-inet
Flush only those routes whose destinations use version 4 of the Internet protocol.

-lock -metric value
Lock the initial value of an individual metric option.

-lockrest
Lock the initial value of all metrics subsequently specified on the command line.

-metric value
Provide initial values for metrics and other parameters maintained in the routing entry. Available -metric options are:

-expire
Specify the expiry time of the route in seconds. An expiry time of 0 implies that the route will not expire.

-hopcount
Specify the number of hops.

-mtu
Specify the maximum transmission unit in bytes.

-recvpipe
Specify the bandwidth of the receive pipe in bytes.

-rtt
Specify the round-trip time in milliseconds.

-rttvar
Specify the variance in round-trip time in milliseconds.

-sendpipe
Specify the bandwidth of the send pipe in bytes.

-ssthresh
Specify the slow start threshold size in bytes.

-tos
Specify the type of service as defined in RFC 1349.

Note that most routing protocols only use or calculate a subset of these metrics, and so route get may display their values as 0. For example, RIP uses the hop count metric.

Values may be locked by specifying -lock before the metric option.


-net destination
Force destination to be interpreted as a network.

-netmask new_mask
Override the implicit network mask with new_mask.

-nostatic
Pretend that route has been added by the kernel or a routing daemon.

-reject
Prevent network traffic from using this route.

-notreject
Allow network traffic to use this route.

-static
Mark route as having been added manually.
If one of the options -host or -net is not specified, routes to a particular host are distinguished from those to a network by interpreting the IP address associated with destination. If the destination has a ``local address part'' of INADDR_ANY or if the destination is the symbolic name of a network, the route is assumed to be to a network; otherwise, it is assumed to be a route to a host. This is demonstrated in the following table:

Destination entry Interpreted as
128.32 -host 128.0.0.32
-net 128.32 -net 128.32.0.0
128.32.130 -host 128.32.0.130
-net 128.32.130 -net 128.32.130.0

 +------------------+--------------------+
 |Destination entry | Interpreted as     |
 +------------------+--------------------+
 |128.32            | -host 128.0.0.32   |
 +------------------+--------------------+
 |-net 128.32       | -net 128.32.0.0    |
 +------------------+--------------------+
 |128.32.130        | -host 128.32.0.130 |
 +------------------+--------------------+
 |-net 128.32.130   | -net 128.32.130.0  |
 +------------------+--------------------+
The kernel variables ipforwarding, ipsendredirects, and ipnonlocalsrcroute are relevant to systems set up as routers. For more information about these variables, see inconfig(1Mtcp).

Diagnostics

Error messages


network is unreachable
An attempt to add a route failed because the gateway listed was not on a directly-connected network. The next-hop gateway must be given.

not in table
A delete operation was attempted for an entry which wasn't present in the tables.

routing table overflow
An add operation was attempted, but the system was low on resources and was unable to allocate memory to create the new entry.

Confirmation messages


add host destination: gateway gateway flags hex-flags
The specified route to a host is being added to the tables. The values printed are from the routing table entry supplied in the ioctl call. If the gateway address used was not the primary address of the gateway (that is, the first one returned by gethostbyname), the gateway address is printed numerically as well as symbolically.

add net destination: gateway gateway flags hex-flags
As above, but when adding a network entry.

delete host destination: gateway gateway flags hex-flags
As above, but when deleting a host entry.

delete net destination: gateway gateway flags hex-flags
As above, but when deleting a network entry.

destination gateway done
When the flush command is specified, each routing table entry deleted is indicated with a message of this form.

References

gated(1Mtcp), hosts(4tcp), netstat(1Mtcp), networks(4tcp), route(7tcp), routed(1Mtcp)

Examples

Display information about the route to network 152.106.1.0 via the gateway 152.106.7.1:

route get -net 152.106.1.0 -gateway 152.106.7.1

Add a route to the host 152.106.2.1 via the gateway 152.106.7.12 using a hop count of 1:

route add -hopcount 1 -host 152.106.2.1 -gateway 152.106.7.12

Set the MTU value to 296 for the route to the host 152.106.2.1 via the gateway 152.106.7.12:

route change -mtu 296 -host 152.106.2.1 -gateway 152.106.7.12

Delete the route to the host 152.106.2.1 via the gateway 152.106.7.12:

route delete -host 152.106.2.1 -gateway 152.106.7.12


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004