6

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
    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 Mar 30 '14 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 Jul 29 at 18:23
9

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.

| improve this answer | |
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

| improve this answer | |
  • 1
    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 Mar 30 '14 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 Mar 30 '14 at 15:49
  • Teamwork in action. :) – joeqwerty Mar 30 '14 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.

| improve this answer | |
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.

| improve this answer | |
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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.