Configuring multiple gateways on a network
If you have multiple network adapters in your computer and you configure a default gateway for each adapter (which creates a default route in the IP routing table for all destinations that are not located on the subnet), information on your network might not be routed to the correct destinations if you connect to disjoint networks—separate networks that are not designed to communicate directly.
Only a single gateway is used for all destinations that are not located on the subnet, even when you configure multiple default gateways. An example of this is when a computer is connected to both an intranet with multiple subnets and the Internet. With a default gateway configured for both adapters, you can either communicate with all computers on the Internet or all computers on the intranet, but not both.
To solve this problem, do the following:
-
Configure a default gateway for the network adapter that's connected to the network with the most routes (usually the network adapter that's connected to the Internet).
-
Don't configure a default gateway for any other network adapter. Instead, use static routes or dynamic routing protocols to add the routes for the other disjoint networks to the local IP routing table. If the routing infrastructure uses Routing Information Protocol (RIP) for IPv4, you can turn on RIP Listener in Windows, which allows your computer to learn other routes on the network by "listening" to broadcast RIP messages, and then adding IPv4 routes to the routing table. If the routing infrastructure doesn't use RIP, you can't use RIP listening.
The alternative is to use the route add -p command to manually add the individual routes to the IPv4 routing table. For IPv6, you must use the netsh interface ipv6 add route command.
To configure a default gateway
-
Open Network Connections by clicking the Start button
, and then clicking Control Panel. In the search box, type adapter, and then, under Network and Sharing Center, click View network connections.
-
Right-click the network adapter that you want to configure a default gateway for, and then click Properties.
If you're prompted for an administrator password or confirmation, type the password or provide confirmation.
-
Click the Networking tab.
-
Under This connection uses the following items, click either Internet Protocol Version 4 (TCP/IPv4) or Internet Protocol Version 6 (TCP/IPv6), and then click Properties.
-
In the dialog box that appears, select either Obtain an IP address automatically or Use the following IP address.
The Internet Protocol Version 4 (TCP/IPv4) Properties dialog box
If you configure the network adapter to obtain an IP address automatically, the default gateway is assigned by the DHCP server. If you specify an alternate configuration (IPv4 only), the default gateway is the IP address in the Default gateway box on the Alternate Configuration tab. You can only specify one default gateway.
If you manually specify an IP address configuration, the default gateway is the IP address in the Default gateway box on the General tab.
To turn on RIP Listener
-
Open Programs and Features by clicking the Start button
, clicking Control Panel, clicking Programs, and then clicking Programs and Features.
-
In the left pane, click Turn Windows features on or off.
If you're prompted for an administrator password or confirmation, type the password or provide confirmation.
-
Select the RIP Listener check box, and then click OK.
To manually add routes for IPv4
-
Open the Command Prompt window by clicking the Start button
. In the search box, type Command Prompt, and then, in the list of results, click Command Prompt.
-
At the command prompt, type route -p add [destination] [mask <netmask>] [gateway] [metric <metric>] [if <interface>].
The following table describes the parameters for the route -p add command.
|
Parameter
| |
Description
|
|
destination
| |
Specifies the network destination of the route. The destination can be an IP address or subnet prefix (also known as the network address or network identifier) (where the host bits of the prefix are set to 0), an IP address for a host route, or 0.0.0.0 for the default route.
|
|
mask
| |
Specifies the subnet mask associated with the network destination. The subnet mask can be the appropriate subnet mask for an IP address or subnet prefix, 255.255.255.255 for a host route, or 0.0.0.0 for the default route. If omitted, 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 can't be more specific than its corresponding subnet mask. In other words, there can't be a bit set to 1 in the destination 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 is reachable. For locally attached subnet routes, the gateway address is the IP address assigned to the interface attached to the subnet. For remote routes (available across one or more routers), the gateway address is a directly reachable IP address assigned to a neighboring router.
|
|
metric
| |
Specifies an integer cost metric (ranging from 1 to 9999) for the route, which is used 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
| |
Specifies the interface index for the interface over which the destination is reachable. For a list of interfaces and their corresponding interface indexes, use the display of the route print 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 parameter is omitted, the interface is determined from the gateway address.
|
With the -p parameter, the specified route is added to the registry and is used to initialize the IP routing table whenever the TCP/IP protocol is started.
To manually add routes for IPv6
-
Open the Command Prompt window by clicking the Start button
. In the search box, type Command Prompt, and then, in the list of results, click Command Prompt.
-
At the command prompt, type netsh interface ipv6 add route [prefix=]<IPv6 address>/<integer> [interface=]<string>
[[nexthop=]<IPv6 address>] [[siteprefixlength=]<integer>]
[[metric=]<integer>] [[publish=]<value>]
[[validlifetime=]<integer>|infinite]
[[preferredlifetime=]<integer>]
[[store=]<value>].
The following table describes the parameters for the netsh interface ipv6 add route command.
|
Parameter
| |
Description
|
|
prefix
| |
Address or subnet prefix to add a route for.
|
|
interface
| |
Interface name or index.
|
|
nexthop
| |
Gateway address, if the prefix is not on-link.
|
|
siteprefixlength
| |
Prefix length for the entire site, if on-link.
|
|
metric
| |
Route metric.
|
|
publish
| |
Represents one of the following values:
-
no: Not advertised in Route Advertisements
(default)
-
age: Advertised in Route Advertisements
with decreasing lifetimes
-
yes: Advertised in Route Advertisements
with unchanging lifetimes
When publish is set to
"age," the Route Advertisement will contain the valid lifetime
remaining until deletion.
When publish is set to "yes," the route will never be deleted,
regardless of the validlifetime value, and every Route
Advertisement will contain the (same) specified valid lifetime. When publish is set to "no" or "age," the route will be deleted
after the end of the valid lifetime.
|
|
validlifetime
| |
Lifetime over which the route is valid expressed in days, hours, minutes, and seconds (for example: 1d2h3m4s).
The default value is "infinite."
|
|
preferredlifetime
| |
Lifetime over which the route is preferred.
The default is equal to the valid lifetime.
|
|
store
| |
Represents one of the following values:
|