locked
Force Internet connection to desired network adapter RRS feed

  • Question

  • Hi.  I frequently need to utilize multiple network adapters, where each adapter has a unique purpose.  One adapter is designated for Internet access, while the others are for accessing multiple LANs.  How can I force Windows to use the adapter I choose for Internet access?  Why doesn't Windows automatically try a different adapter when one fails to get out to the Internet?  Each network adapter can potentially have a gateway assigned to it.

    I have already tried changing the priority of the network adapters in Network Connections > Advanced > Advanced Settings.  This has not resolved the issue.

    Thanks.

    Sunday, February 5, 2012 9:19 PM

Answers

  • This is decided by the routing table on your computer. Open a command prompt and run "route print" to see what it looks like. The interface that has 0.0.0.0 assigned to it will be the one used for internet access. If there are more than one with 0.0.0.0 then the one with the lowest metric will be used. One way to force internet traffic to go through a certain interface is to add a route with a low metric for 0.0.0.0 to this interface.

    Run "route print". Look at the Interface List and remember the number of the interface you want to create a route for.

    Run "route delete 0.0.0.0 if <number of wanted interface>". This is because you cannot have two entries for the same route on the same interface.

    Run "route -p add 0.0.0.0 mask 0.0.0.0 <ip of gateway> metric 1 if <number of wanted interface>". The -p switch makes it permanent. Metric 1 will give it the lowes cost, hence it will be the preferred entry to use for requests to addresses not specified in the routing table.

    Btw, having default gateways on more than one interface is generally not a good idea.


    • Edited by Eirik Hamer Sunday, February 5, 2012 9:52 PM
    • Marked as answer by Lentilbean Sunday, February 5, 2012 11:26 PM
    Sunday, February 5, 2012 9:50 PM

All replies

  • This is decided by the routing table on your computer. Open a command prompt and run "route print" to see what it looks like. The interface that has 0.0.0.0 assigned to it will be the one used for internet access. If there are more than one with 0.0.0.0 then the one with the lowest metric will be used. One way to force internet traffic to go through a certain interface is to add a route with a low metric for 0.0.0.0 to this interface.

    Run "route print". Look at the Interface List and remember the number of the interface you want to create a route for.

    Run "route delete 0.0.0.0 if <number of wanted interface>". This is because you cannot have two entries for the same route on the same interface.

    Run "route -p add 0.0.0.0 mask 0.0.0.0 <ip of gateway> metric 1 if <number of wanted interface>". The -p switch makes it permanent. Metric 1 will give it the lowes cost, hence it will be the preferred entry to use for requests to addresses not specified in the routing table.

    Btw, having default gateways on more than one interface is generally not a good idea.


    • Edited by Eirik Hamer Sunday, February 5, 2012 9:52 PM
    • Marked as answer by Lentilbean Sunday, February 5, 2012 11:26 PM
    Sunday, February 5, 2012 9:50 PM
  • Hey Eirik.  Your solution has solved the problem!  Thank you very much for the detailed response.  I did a quick search for a utility to ease adjusting the route table and found this one: NetRouteView by NirSoft.

    Many thanks!

    Sunday, February 5, 2012 11:26 PM
  • You two dears, are awesome!!

    I have been looking for this for a long time now.

    Thank you very much.

    Saturday, November 9, 2013 12:07 AM
  • Erick... You're the best..!! Thanks
    Thursday, February 2, 2017 2:22 AM
  • Hi

    For some reason the LAN NIC always takes the lower matric. even when I force it. anything we can do?

    Thursday, July 6, 2017 7:23 AM
  • I have found that some metric values are not accepted.  I'm uncertain of what the criteria is.  My practice has been to massage the metrics for the NICs in question, which sometimes means bumping the LAN NIC up and the WAN NIC down.  You could also try setting the persistent value to yes.
    Monday, July 17, 2017 4:26 PM
  • This fix worked from me on a VM that was connected to two different networks.
    Monday, January 15, 2018 9:15 PM
  • Thanks Eirik for your answer. I have a question:
    What do you mean by : the number of the interface ? is it the IP address of my PC on that network ?
    Tuesday, June 26, 2018 7:05 PM
  • If you run "route print" you see the number in the first column of the interface list.
    Wednesday, June 27, 2018 5:14 PM
  • This is decided by the routing table on your computer. Open a command prompt and run "route print" to see what it looks like. The interface that has 0.0.0.0 assigned to it will be the one used for internet access. If there are more than one with 0.0.0.0 then the one with the lowest metric will be used. One way to force internet traffic to go through a certain interface is to add a route with a low metric for 0.0.0.0 to this interface.

    Run "route print". Look at the Interface List and remember the number of the interface you want to create a route for.

    Run "route delete 0.0.0.0 if <number of wanted interface>". This is because you cannot have two entries for the same route on the same interface.

    Run "route -p add 0.0.0.0 mask 0.0.0.0 <ip of gateway> metric 1 if <number of wanted interface>". The -p switch makes it permanent. Metric 1 will give it the lowes cost, hence it will be the preferred entry to use for requests to addresses not specified in the routing table.

    Btw, having default gateways on more than one interface is generally not a good idea.


    Hi Eirik,

    Do you know any way I could "Bind" an application/program (browser for example) to the VPN adapter?

    So for example, to add Chrome to use my VPN tunnel, instead of the default gateway? The rest of the traffic can use the default route.

    I was able at home to split tunnel and to create the routes, but I need only some traffic to go through my VPN. So I was thinking that I could link somehow Chrome to my VPN (or other browser).

    Thank you.  

    Wednesday, August 7, 2019 10:04 AM
  • Not that I am aware of, but these operate on different layers so I doubt it.

    Either way, I would suggest you create a new thread for this question if you want more responses to it.

    Tuesday, August 13, 2019 1:37 PM