10.8. Managing Routes


You want to view the routing table on a server or possibly configure static routes. Configuring static routes generally isn't needed with today's networks, but it can be necessary especially when working in restricted lab environments that are not fully routed.


Using a command-line interface

The following command displays all the static and dynamic routes on a system:

> route print


For a good overview of what each column represents in the route print output, see MS KB 140859.

This command only shows routes that start with 64:

> route print 64.*

To add a temporary route (one that is erased after the system reboots), use this command:

> route ADD <Network> MASK <Mask> 
                  <Gateway> METRIC <Metric> IF <Interface#>

For example:

> route ADD MASK METRIC 3 IF 2

To add a permanent route, use the same command as before except include the -p switch. To delete a route, use this command:

> route DELETE <Network>

For example:

> route DELETE

Using VBScript

' This code prints similar information to the "route print" command. ' Since the Win32_IP4RouteTable class was first introduced in ' Windows Server 2003, this script does not work against a ' Windows 2000 server. ' ------ SCRIPT CONFIGURATION ------ strComputer = "." ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colRoutes = objWMI.InstancesOf("Win32_IP4RouteTable") for each objRoute in colRoutes set colNetworkAdapters ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.