Creating Static Routes
In some instances you need to add a static route to your Windows Server 2008 router. This, of course, has its advantages and disadvantages. Creating a static route is simple; however, the routes you configure are not shared between routers. Static routes specify the network address and subnet mask that tell the router how to reach a certain destination. The router uses the information to determine to which gateway to forward the packet so that the packet can reach the destination host.
Static routes can be configured in one of two ways:
- Using the route command.
- Using the RRAS management console.
Using the Route Command
The route command is used to view and modify the network routing tables of an IP network. The route print command displays a list of current routes that the host knows (see Figure 5.1).
Figure 5.1 Route Print command output.
Routes added to a routing table are not made persistent unless the -p switch is specified. Non-persistent routes last only until the computer is restarted or until the interface is deactivated. The interface can be deactivated when the plug-and-play interface is unplugged (such as for laptops and hot-swap PCs), when the wire is removed from the media card (if the adapter supports media fault sensing), or when the interface is manually disconnected from the adapter in the Network and Dial-up Connections folder.
The usage for the route command is
ROUTE [-f] [-p] [command [destination]] [MASK netmask] [gateway] [METRIC metric]
- -f—Clears the routing tables of all gateway entries. If this is used in conjunction with one of the commands, the tables are cleared before the command is run.
- -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. When used with the print command, displays the list of registered persistent routes. Ignored for all other commands, which always affects the appropriate persistent routes.
- Destination—Specifies the network or host to which packets are being sent to.
- MASK netmask—Specifies a subnet mask to be associated with this route entry. If a netmask value is not specified, it defaults to 255.255.255.255.
- gateway—Specifies gateway or router.
- METRIC metric—Assigns an integer cost metric (ranging from 1 to 9,999) to be used in calculating the fastest, most reliable, and/or least expensive routes.
The commands usable in the preceding syntax are PRINT, ADD, DELETE, and CHANGE:
- PRINT—Displays a route
- ADD—Adds a route
- DELETE—Deletes a route
- CHANGE—Modifies an existing route
For example, to create a static route, you could type
route ADD 188.8.131.52 MASK 255.255.255.0 184.108.40.206 METRIC 2
After this command is executed, any packet that is sent to the 220.127.116.11 network or host with an IP address ranging between 18.104.22.168 and 22.214.171.124 will be forwarded to the router with a local host address of 126.96.36.199. If multiply entries specify these destination addresses, this route has a metric of two hops.
Using Routing and Remote Access
To add a static route to a Windows Server 2008 multihomed computer, you would use the Routing and Remote Access program located under Administrative Tools or use the appropriate MMC snap-in. Next, right-click Static Routes under IPv4 or IPv6 and select New Static Route for IP Networks (see Figure 5.2).
Figure 5.2 Using the Routing and Remote Access console to create a static route.
For a static IP route, in Interface, Destination, Network Mask, Gateway, and Metric, enter the interface, destination, network mask, gateway, and metric. If this is a demand-dial interface, Gateway is unavailable. You can also select the Use This Route to Initiate Demand-Dial Connections check box to initiate a demand-dial connection for traffic that matches the route.
For IP static addresses, the destination provides a space for you to type a destination for the route. The destination can be a host address, subnet address, network address, or the destination for the default route (0.0.0.0). The subnet mask provides a space for you to type the network mask for the static route. The network mask number is used in conjunction with the destination to determine when the route is used.
The mask of 255.255.255.255 means that only an exact match of the destination number can use this route. The mask of 0.0.0.0 means that any destination can use this route. The gateway provides a space for you to type the forwarding IP address for this route. For LAN interfaces, the gateway address must be configured and must be a directly reachable IP address for the network segment of the selected interface. Again, for demand-dial interfaces, the gateway address is not configured or used. The metric provides a space to type the cost associated with this route to reach the destination. The metric is commonly used to indicate the number of routers (hops) to the destination. When deciding between multiple routes to the same destination, the route with the lowest metric is selected as the best route.