Route add or delete from commands

Using Route commands to Add ,Delete ,Print Routes
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\Documents and Settings\Admin>route/?

Manipulates network routing tables.

ROUTE [-f] [-p] [command [destination]
[MASK netmask]  [gateway] [METRIC metric]  [IF interface]

-f           Clears the routing tables of all gateway entries.  If this is
used in conjunction with one of the commands, the tables are
cleared prior to running the command.
-p           When used with the ADD command, makes a route persistent

across
boots of the system. By default, routes are not preserved
when the system is restarted. Ignored for all other commands,
which always affect the appropriate persistent routes. This
option is not supported in Windows 95.
command      One of these:
PRINT     Prints  a route
ADD       Adds    a route
DELETE    Deletes a route
CHANGE    Modifies an existing route
destination  Specifies the host.
MASK         Specifies that the next parameter is the ‘netmask’ value.
netmask      Specifies a subnet mask value for this route entry.
If not specified, it defaults to 255.255.255.255.
gateway      Specifies gateway.
interface    the interface number for the specified route.
METRIC       specifies the metric, ie. cost for the destination.

All symbolic names used for destination are looked up in the network database
file NETWORKS. The symbolic names for gateway are looked up in the host name
database file HOSTS.

If the command is PRINT or DELETE. Destination or gateway can be a wildcard,
(wildcard is specified as a star ‘*’), or the gateway argument may be omitted.

If Dest contains a * or ?, it is treated as a shell pattern, and only
matching destination routes are printed. The ‘*’ matches any string,
and ‘?’ matches any one char. Examples: 157.*.1, 157.*, 127.*, *224*.
Diagnostic Notes:
Invalid MASK generates an error, that is when (DEST & MASK) != DEST.
Example> route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
The route addition failed: The specified mask parameter is invalid.
(Destination & Mask) != Destination.

Examples:

> route PRINT
> route ADD 157.0.0.0 MASK 255.0.0.0  157.55.80.1 METRIC 3 IF 2
destination^      ^mask      ^gateway     metric^    ^
Interface^
If IF is not given, it tries to find the best interface for a given
gateway.
> route PRINT
> route PRINT 157*          …. Only prints those matching 157*
> route CHANGE 157.0.0.0 MASK 255.0.0.0 157.55.80.5 METRIC 2 IF 2

CHANGE is used to modify gateway and/or metric only.
> route PRINT
> route DELETE 157.0.0.0
> route PRINT

D:\Documents and Settings\Admin>

A route describes the gateway IP address and network interface to use when

sending packets to a network. The routing table on a host holds a list of

destination networks and the routes to those networks. This recipe describes

adding entries to this routing table that will not persist following a

reboot. These temporary routes are useful during troubleshooting or when

making changes to the network topology.

To add a route to the network 192.168.1.1/24 (corresponding to a subnet mask

of 255.255.255.0) through the gateway 192.168.1.10, use the following

command:

route add 192.168.1.1 mask 255.255.255.0 192.168.1.10

This is the simplest method of adding a temporary route. The subnet mask

parameter is optional and defaults to 255.255.255.255 which specifies that

the target is a single IP address instead of a network.

An optional routing metric can be added to the route command for more

complex situations. The metric can be considered a cost for using the route.

If a routing table contains multiple routes to the same destination, the

cheapest route (lowest cost or metric) will be used. To add a route with a

metric of 10 to the host 192.168.1.123 through the gateway 192.168.1.10, use

the following command:

route add 192.168.1.123 192.168.1.10 metric 10

In this case, the subnet mask is not given so the command defaults to the

mask 255.255.255.255.

It is possible to use names instead of numbers for the gateway and subnets.

If you use a name for the gateway, the name is looked up in the hosts file

({windows_home}\system32\drivers\etc\hosts) and the corresponding IP address

is used. Named subnets will be looked up in the networks file

({windows_home}\system32\drivers).

If multiple network interfaces are available to route to the same

destination, the interface can be specified in the route command. The

interface number associated with the interface is shown using the route

print command. Windows will automatically guess which interface is most

appropriate for the given route. If you are dissatisfied with Windows’s

guess, the optional if {interface} parameter can be used. To specify that

the previous route example should use interface 2 (identified with the

hexadecimal value 0×2 in the route print command), use the following

command:

route add 192.168.1.123 192.168.1.10 metric 10 if 2

Advertisements

Posted on April 17, 2011, in Uncategorized, Windows. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: