To route traffic correctly between a single Ethernet interface and two distinct networks, you must configure static routes with appropriate metrics rather than relying on the default gateway for all destinations. The Windows routing table uses the lowest metric to determine the primary path, so private network traffic requires a specific static route pointing to the local subnet’s gateway, while general internet traffic defaults to the ISP gateway. This approach ensures that internal resources remain accessible without disrupting external connectivity.
Understanding the Default Gateway Conflict
When you connect to a network, Windows automatically adds a default route (0.0.0.0/0) using the DHCP-provided gateway. If your machine is also connected to a private LAN via the same NIC, you cannot have two default gateways active simultaneously for the same interface. Instead, you rely on subnet-specific routes. For example, if your internet gateway is
192.168.1.1 and your private network is
10.0.0.0/24, traffic destined for
10.0.0.x must not go through
192.168.1.1. Without explicit instructions, Windows might attempt to send private traffic to the internet gateway, resulting in connection failures for local resources.
Verifying Current Routing State
Before adding new rules, inspect the existing routing table to understand how Windows currently prioritizes traffic. Open Command Prompt as Administrator and run:
route print
Look for the IPv4 Route Table section. Identify the Active Routes. You will see an entry for
0.0.0.0 with a mask of
0.0.0.0, which represents the default gateway. Note its Interface IP and Metric. If you already have a route for your private subnet, note its metric as well. A lower metric indicates higher priority. If no specific route exists for your private network, any traffic to that subnet will fall back to the default gateway, which is likely incorrect.
For more details on diagnosing these entries, see our guide on
Check Windows Routing Table Entry Used Given IP Address.
Adding Static Routes for the Private Network
The core solution involves adding a static route that explicitly directs traffic for the private subnet to the correct local gateway. Use the
route add command with the following syntax:
route add [Private_Subnet] mask [Subnet_Mask] [Gateway_IP] metric [Metric_Value] if [Interface_Index]
Here is a concrete example. Assume your private network is
10.0.0.0 with a subnet mask of
255.255.255.0 (
/24). Your private gateway is
10.0.0.1. The command would be:
route add 10.0.0.0 mask 255.255.255.0 10.0.0.1
This command tells Windows: "If the destination IP starts with
10.0.0, send it to
10.0.0.1." By default, Windows assigns a metric based on the interface speed and type. To ensure this route takes precedence over the default route for these specific IPs, you may need to adjust the metric. However, since the default route is
0.0.0.0/0 (all traffic), and this new route is
10.0.0.0/24 (specific traffic), Windows uses the longest prefix match rule. Therefore, the specific route wins regardless of metric, provided it exists.
Persisting Routes Across Reboots
By default, routes added via
route add are volatile and disappear after a restart. To make them permanent, use the
-p flag:
route -p add 10.0.0.0 mask 255.255.255.0 10.0.0.1
This writes the entry to the registry. Verify persistence by running
route print again after a reboot. Ensure the metric is reasonable; typically, default routes have high metrics (e.g., 25 or 26 depending on OS version), while static routes inherit the interface metric. If you have multiple interfaces, ensuring the correct interface index is specified prevents ambiguity.
Troubleshooting Common Issues
If private network access fails after configuration, check for conflicts. Ensure no other static routes overlap incorrectly. Use
ping 10.0.0.1 to verify reachability to the private gateway. If ping succeeds but applications fail, check firewall settings. Additionally, review your DNS settings; sometimes private network resolution requires a specific DNS server reachable only via the private gateway.
For deeper diagnostics on route conflicts, refer to
Troubleshooting Static Route Issues in Windows.
FAQ
Can I use two default gateways on one NIC?
No, Windows does not support multiple default gateways for a single interface. You must use specific static routes for non-internet subnets to direct traffic appropriately.
How do I remove a static route?
Use the
route delete command followed by the target network address. For example,
route delete 10.0.0.0 removes the specific route for that subnet.
Why is my private network unreachable even with a static route?
Check if the gateway IP is valid and reachable. Also, verify that the subnet mask matches the actual network configuration. A mismatched mask can cause traffic to be routed incorrectly.
Does the metric matter for specific vs default routes?
For specific subnets, the longest prefix match takes precedence over the metric. The metric primarily matters when comparing two routes with the same prefix length.
What happens if I lose connection to the private gateway?
Traffic destined for the private subnet will fail until the route is removed or the gateway becomes available again. Consider using a script to monitor gateway status if high availability is critical.