次の方法で共有


Route (Compact 2013)

3/26/2014

The route command-line tool displays network routing tables; you can also use it to modify network routing tables.

Syntax

route [-d] [-f] [-p] [-4 | -6] command [destination] [MASK netmask] [gateway] [METRIC metric] [IF interface]

Options

The following table describes each route option. These options are not case-sensitive.

Option

Option

Description

-d

Prints output to the debug output port. If your device is connected to Platform Builder, route prints to the Output window in Visual Studio.

-f

Clears the routing table of all entries that are not host routes (routes with a netmask of 255.255.255.255), the loopback network route (routes with a destination of 127.0.0.0 and a netmask of 255.0.0.0), or a multicast route (routes with a destination of 224.0.0.0 and a netmask of 240.0.0.0). If you use the -f option together with one of the commands (such as ADD, DELETE, PRINT, or CHANGE), the route command-line tool clears the tables before running the command.

-p

Makes a route persistent across repeated boots of the system. When you combine the -p option with the ADD command, the specified route is added to the registry and is used to initialize the IP routing table whenever the TCP/IP protocol starts. By default, added routes are not preserved when the TCP/IP protocol is started. When you combine the -p option with the PRINT command, the list of persistent routes is displayed. This option is ignored for the DELETE and CHANGE commands.

-4

Restricts the command to the IPv4 routing table. For example, route -4 PRINT displays only the IPv4 routing table.

-6

Restricts the command to the IPv6 routing table. For example, route -6 PRINT displays only the IPv6 routing table.

command

Specifies the command you want to run. The command option can be one of the following.

CommandDescription
ADDAdds a route.
DELETEDeletes a route.
PRINTPrints a route.
CHANGEModifies an existing route.

destination

Specifies the network destination of the route. The destination can be an IP network address (where the host bits of the network address are set to 0), an IP address for a host route, or 0.0.0.0 for the default route.

MASK

netmask

Specifies the netmask (also known as a subnet mask) associated with the network destination. The subnet mask can be the appropriate subnet mask for an IP network address, 255.255.255.255 for a host route, or 0.0.0.0 for the default route. If you do not specify a subnet mask, the subnet mask 255.255.255.255 is used. Because of the relationship between the destination and the subnet mask in defining routes, the destination cannot be more specific than its corresponding subnet mask. In other words, the destination address cannot have a bit set to 1 if the corresponding bit in the subnet mask is a 0.

gateway

Specifies the forwarding or next hop IP address over which the set of addresses defined by the network destination and subnet mask are reachable. For locally attached subnet routes, the gateway address is the IP address assigned to the interface that is attached to the subnet. For remote routes, available across one or more routers, the gateway address is a directly reachable IP address that is assigned to a neighboring router.

METRIC

metric

Specifies an integer cost metric (ranging from 1 to 9999) for the route, which the routing algorithm uses when choosing among multiple routes in the routing table that most closely match the destination address of a packet being forwarded. The route with the lowest metric is chosen. The metric can reflect the number of hops, the speed of the path, path reliability, path throughput, or administrative properties.

IF

interface

Specifies the interface index for the interface over which the destination is reachable. To view a list of interfaces and their corresponding interface indexes, use the routePRINT command. You can use either decimal or hexadecimal values for the interface index. For hexadecimal values, precede the hexadecimal number with 0x. When the IF option is omitted, the interface is determined from the gateway address.

Remarks

Large values in the metric column of the routing table are the result of allowing TCP/IP to automatically determine the metric for routes in the routing table based on the configuration of IP address, subnet mask, and default gateway for each LAN interface. Automatic determination of the interface metric, enabled by default, determines the speed of each interface and adjusts the metrics of routes for each interface so that the fastest interface creates the routes with the lowest metric. However, this automatic determinism may not always result in the most optimum metrics, and large metrics can result in slower network performance. To prevent the large metrics, disable the automatic determination of the interface metric from the advanced properties of the TCP/IP protocol for each LAN connection.

Names can be used for destination and gateway as long as they can be resolved to an IP address through standard host name resolution techniques such as Domain Name System (DNS) queries.

If the command is PRINT or DELETE, the gateway parameter can be omitted and wildcards can be used for the destination and gateway. The destination value can be a wildcard value specified by an asterisk (*). If the destination specified contains an asterisk (*) or a question mark (?), it is treated as a wildcard and only matching destination routes are printed or deleted. The asterisk matches any string, and the question mark matches any single character. For example, 10.*.1, 192.168.*, 127.*, and *224* are all valid uses of the asterisk wildcard.

If you specify an invalid value for netmask so that the result of a bitwise-AND operation between destination and netmask does not equal the value of destination, route returns an error. For example, the following route command generates an error message:

route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1

When you enter this command, route returns the following error message:

The route addition failed: (null)

Example

The following example shows several ways to use the route command-line tool.

route PRINT
route ADD 157.0.0.0 MASK 255.0.0.0 157.55.80.1 METRIC 3 IF 2
route DELETE 157.0.0.0

The following example shows the typical output from the route PRINT command.

===========================================================================
Interface List
  2 ...00 03 ff a5 ca 8e ...... VMINI1
  1 ........................... Software Loopback Interface 1
===========================================================================
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination          Netmask          Gateway       Interface  Metric
            0.0.0.0          0.0.0.0     10.125.148.1  10.125.149.100      41
       10.125.148.0    255.255.254.0          On-link  10.125.149.100     296
     10.125.149.100  255.255.255.255          On-link  10.125.149.100     296
     10.125.149.255  255.255.255.255          On-link  10.125.149.100     296
          127.0.0.0        255.0.0.0          On-link       127.0.0.1     306
          127.0.0.1  255.255.255.255          On-link       127.0.0.1     306
    127.255.255.255  255.255.255.255          On-link       127.0.0.1     306
          224.0.0.0        240.0.0.0          On-link  10.125.149.100     296
          224.0.0.0        240.0.0.0          On-link       127.0.0.1     306
    255.255.255.255  255.255.255.255          On-link  10.125.149.100     296
    255.255.255.255  255.255.255.255          On-link       127.0.0.1     306
===========================================================================
Persistent Routes:
  None
IPv6 Route Table
Active Routes:
 If Metric Network Destination      Gateway
  1    306 ::1/128                  On-link
  2    296 fe80::/64                On-link
  2    296 fe80::84de:2299:8c0a:5fd4/128
                                    On-link
  2    296 ff00::/8                 On-link
  1    306 ff00::/8                 On-link
===========================================================================
Persistent Routes:
  None

To view route destinations that begin with 10.125, for example, you can enter the following command:

route PRINT 10.125.*

This qualified route PRINT command displays only those routes with a destination address that begin with 10.125:

===========================================================================
Interface List
  2 ...00 03 ff a5 ca 8e ...... VMINI1
  1 ........................... Software Loopback Interface 1
===========================================================================
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination          Netmask          Gateway       Interface  Metric
       10.125.148.0    255.255.254.0          On-link  10.125.149.100     296
     10.125.149.100  255.255.255.255          On-link  10.125.149.100     296
     10.125.149.255  255.255.255.255          On-link  10.125.149.100     296
===========================================================================
Persistent Routes:
  None
IPv6 Route Table
Active Routes:
  None
Persistent Routes:
  None

See Also

Reference

Network Command-Line Tools Reference

Concepts

Network Command-Line Tools Catalog Items and Sysgen Variables