How does a Windows computer behave when it has multiple default gateways?

5

3

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 ?

Snake Hernandez

Posted 2014-03-30T14:49:30.643

Reputation: 63

2

>

  • 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. - http://windows.microsoft.com/en-us/windows/configuring-multiple-network-gateways#1TC=windows-7
  • – joeqwerty – 2014-03-30T15:27:51.047

    Answers

    7

    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.

    Tero Kilkanen

    Posted 2014-03-30T14:49:30.643

    Reputation: 1 405

    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

    kallax

    Posted 2014-03-30T14:49:30.643

    Reputation: 66

    1You 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 – 2014-03-30T15:35:16.380

    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 – 2014-03-30T15:49:16.783

    Teamwork in action. :) – joeqwerty – 2014-03-30T15:50:07.570

    0

    you also can do like this for a specific reason, assume we have WSUS Server and inside the company have more than 6 networks with limited speed, in this case, If You desired to download updates directly from the internet, so we can set 2 default gateway using specific subnet, for internet access add route 0.0.0.0 mask 0.0.0.0 10.10.20.1 metric 10 for accessing internal networks, assume we have six networks from 192.168.1.1 to 6 and our WSUS server subnet is 192.168.3.x, then do like this add route 192.168.0.0 mask 255.255.0.0 192.168.3.1

    Mohammad Kamil

    Posted 2014-03-30T14:49:30.643

    Reputation: 1

    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.

    Fiasco Labs

    Posted 2014-03-30T14:49:30.643

    Reputation: 6 368

    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.

    ohzir

    Posted 2014-03-30T14:49:30.643

    Reputation: 1