This is done by the Metric setting which is assigned to each gateway. The gateway with lowest Metric is the first to be searched(Default Gateway). Metric is the cost of using that gateway, and it will always use the one with the lowest cost first.
The metric can also be applied when having more than one network adapter, which connects to the same Network(Subnet). Example if using a wireless NIC and a standard NIC, then one can decide if it should use go through the Wireless NIC before using the Standard NIC. This is done by lowering the interface metric of the Wireless NIC.
The metric can also be used for manual load balancing between multiple network adapters:
- Install TCP/IP for all adapters and assign them a different IP-address on the same subnet (Becomes Multihoming)
- If a certain adapter should be dedicated for outgoing traffic then it should be given a lower interface metric
- If a certain adapter should be used for certain incoming traffic then make sure the clients connects to its IP-Address
- Note Netbios traffic (outgoing/incoming) can only be handled by a single adapter or else a name conflict will arise (Though it doesn't have to be the one dedicated for outgoing IP traffic)
- Note it is possible for clients to connect to a service (FTP/HTTP,etc.) through all network adapters (To force clients to use a certain adapter one can use DNS or port blocking)
- Open Control Panel
- Double click Network and Dial-up Connections(Win2k) or Network Connections(WinXP)
- Righ click Local Area Connection and select Properties
- Double click Internet Protocol (TCP/IP)
- Press Advanced-button and it is possible to configure gateways and interface metric
Note if two network interfaces have the same metric value, then their priority is based on the network binding order. To configure the network binding order in Win2k/WinXP:
- Open Control Panel
- Double click Network and Dial-Up Connections
- In the menu select Advanced and select Advanced Settings...
- Vista/Win7 will only display the Advanced menu-item when pressing the ALT-key. More Info MS KB2526067.
- Select the Adapter and Bindings-tab and change the priority of the network Connections.
More Info MS KB164214
More Info MS KB894564
More Info Cable Guy - Default Gateway Behavior for TCP/IP