8

I have a computer(Windows XP) connected to two network interfaces, these two interfaces are connected to different networks and they are configured to receive a DHCP configuration, which means that both of them will give to the computer a default gateway.
The computer behaves sometimes correctly and sends packets to the right interfaces, sometimes it doesn't.
Is there a logical explanation about how computers behave in such situations?
Is there a right way to keep these both interfaces configured like that and behave correctly ?

2
  • 2
    1. the computer behaves sometimes correctly and sends packets to the right interfaces, sometimes it doesn't doesn't tell us anything about what you mean. You need to give us more details. 2. Windows computers can't use multiple default gateways. - windows.microsoft.com/en-us/windows/…
    – joeqwerty
    Commented Mar 30, 2014 at 15:27
  • The logical explanation is that according to the original design principles of the Internet and TCP/IP, there is supposed to be only one global Internet and therefore it doesn't matter which default gateway is chosen. NAT and private IP ranges are a hack added later to extend IPv4 address space. So valid behaviors according to original principles are picking one and sticking with it, or "round robin"-ing between them.
    – LawrenceC
    Commented Jul 29, 2020 at 18:23

5 Answers 5

12

If Windows has multiple interfaces connected to several networks that use DHCP, it installs default gateways for all those interfaces.

By default, Windows sets the metric of the default gateways to the same, effectively leading to random selection of default gateway.

If you want to make Windows to select certain gateway always, you can change interface metrics for the interfaces' configuration you don't want to use:

  1. Go to your Network adapter properties
  2. Select Internet Protocol v4.
  3. Click the Advanced button on General tab.
  4. Uncheck Automatic metric.
  5. Enter a number higher than 10 to the Interface metric field.

The default automatic metric for interfaces is 10. The lower the metric, the higher the preference to use it. So, you have to enter metric higher than 10 for the interfaces you don't want to use.

EDIT: These instructions are for Windows 7, XP might be different. You shouldn't be using XP anyway.

2
  1. Your computer will not apply DHCP configuration from BOTH DHCP servers at the same time.
  2. Windows computer CAN have two default gateways. You cannot set second default gateway in GUI, but you can add it in command line with route command. In this case Windows will use path with lower metric value.

You can check if you have two default gateways with route print command. Default gateway is there, where both network address and network mask are assigned to 0.0.0.0

3
  • 2
    You certainly could add another route to 0.0.0.0 with a lower metric but Windows is not going to route traffic as you'd expect it to. There can be only one Default Gateway.
    – joeqwerty
    Commented Mar 30, 2014 at 15:35
  • 1
    @joeqwerty, seems that you are right. I've checked this situation and can now confirm that Windows not (or not always) sends traffic to route with lower metric. Next time I will check twice before answering )
    – kallax
    Commented Mar 30, 2014 at 15:49
  • 1
    Teamwork in action. :)
    – joeqwerty
    Commented Mar 30, 2014 at 15:50
0

It either uses the first default gateway it decides to use, sometimes randomly and with weird results, or it loses the ability to connect altogether.

In Windows, it is a total misconfiguration and causes much grief.

You run a script using route delete to remove default gateways (0.0.0.0) from all but the desired interface that will pass traffic to unknown subnets.

Basically, you want one default gateway and the rest will be gateways to specific subnets either internal or external.

0

For the non-default-gateway routes, you have to be very network specific. I.E. add a persistent route for the specific subnet you're trying to hit through that interface.

so if you do route print and you have persistent routes that read like

0.0.0.0 0.0.0.0 192.168.1.1 default 0.0.0.0 0.0.0.0 10.0.0.1 default

then you would change it to be more like

0.0.0.0 0.0.0.0 192.168.1.1 default 10.0.0.0 255.255.255.0 10.0.0.1 3 10.0.1.0 255.255.255.0 10.0.0.1 3

etc etc

the default gateway should be limited to the connection you use for your internet on most machines, but apply this however you need to to make it work.

Alternately, there are ways to make windows behave properly with RIP, but I don't use RIP on any of my networks so I'm not the one to explain how it works.

0

Windows doesn't automatically add default gateways for each network, they need to be explicitly added, either through the GUI, DHCP, or some other manipulation of the IP stack (e.g. "route add"). Ideally there should be one and only one default gateway configured.

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Dec 15, 2021 at 13:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .