Windows 7: How to bind an interface to be only route to ip

29,475

Solution 1

I have a partial success by running:

route -p add 8.8.8.8 mask 255.255.255.255 10.0.0.1 metric 1000 if 11
route -p add 8.8.8.8 mask 255.255.255.255 192.168.42.129 metric 1 if 20
route -p change 0.0.0.0 mask 0.0.0.0 192.168.42.129 metric 1000 if 20

The last line doesn't influence the standard value of 266 when I plug the second interface back in, and I have had to re-run it each time. Although traffic does not pass through the primary interface to reach 8.8.8.8 when the second interface is plugged in and configured, the routing table still permits connections to 8.8.8.8 over the standard interface. I verified these results using Wireshark, which I verified by manually providing the first interface to ping.

Posting this in case a partial answer is good enough for similar cases.

Solution 2

The NIC priority could be incorrect. With both NICs connected open

Control Panel\Network and Internet\Network Connections

Now press Alt + n to open the Advanced menu and click on Advanced Settings. Now select the NIC that you want to be the primary interface and move it to the top using the arrow buttons.

Share:
29,475

Related videos on Youtube

Iiridayn
Author by

Iiridayn

Former principle software developer with a CS undergrad and a MIS degree. Around 13 years of professional experience, worked on many kinds of projects, from embedded systems to database driven sites, on sites with traffic up to 2 million hits per month, and on teams as large as 50 other programmers. I have professionally worked primarily with nodejs, C, PHP, and MySQL, with some Python, C#, and Lisp experience mixed in. I am passionate about usability, security, and protocols. As of 2019, I am a PhD candidate in CS/Usable Security at BYU. I host the Space 4X MMOG SkyLords. I develop in and love vim and tmux. I love programming with closures (eg, in Lisp). I run Arch Linux at work and home. I beat Nethack on my Nexus One Android phone, have also owned a OnePlus One and OnePlus 3T - looking for an affordable developer and privacy friendly option for my next phone. Formerly subscribed to EVE Online, and lived in all but low-sec. You can find more about me at iiridayn.info. Using pico2wave or pico-tts my username is pronounced roughly as i'iri dan (the y is mostly elided).

Updated on September 18, 2022

Comments

  • Iiridayn
    Iiridayn almost 2 years

    I am running Windows 7, and need to route DNS traffic to 8.8.8.8 over a separate network interface without it passing through the primary (wired) interface. No other traffic should be routed through the second interface (3G) - partially due to speed and partially due to servers in the 10.x.x.x range. How can I configure Windows to route my traffic?

    In particular, how can I configure Windows to not find a route to 8.8.8.8 when the second interface is not plugged in or disabled?

    Result of running route print with second interface enabled:

    ===========================================================================
    Interface List
     11..1c 6f 65 38 15 c3 ......Realtek PCIe GBE Family Controller
     20...8a 4e 09 12 1f 35 ......Remote NDIS based Internet Sharing Device
     1...........................Software Loopback Interface 1
     12...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
     13...00 00 00 00 00 00 00 e0 Teredo Tunneling Pseudo-Interface
    ===========================================================================
    
    IPv4 Route Table
    ===========================================================================
    Active Routes:
    Network Destination        Netmask          Gateway       Interface  Metric
              0.0.0.0          0.0.0.0         10.0.0.1       10.0.10.29     10
              0.0.0.0          0.0.0.0   192.168.42.129   192.168.42.205    266
             10.0.0.0      255.255.0.0         On-link        10.0.10.29    266
           10.0.10.29  255.255.255.255         On-link        10.0.10.29    266
         10.0.255.255  255.255.255.255         On-link        10.0.10.29    266
            127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
            127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
      127.255.255.255  255.255.255.255         On-link         127.0.0.1    306
         192.168.42.0    255.255.255.0         On-link    192.168.42.205    266
       192.168.42.205  255.255.255.255         On-link    192.168.42.205    266
       192.168.42.255  255.255.255.255         On-link    192.168.42.205    266
            224.0.0.0        240.0.0.0         On-link         127.0.0.1    306
            224.0.0.0        240.0.0.0         On-link        10.0.10.29    266
            224.0.0.0        240.0.0.0         On-link    192.168.42.205    266
      255.255.255.255  255.255.255.255         On-link         127.0.0.1    306
      255.255.255.255  255.255.255.255         On-link        10.0.10.29    266
      255.255.255.255  255.255.255.255         On-link    192.168.42.205    266
    ===========================================================================
    Persistent Routes:
      None
    
    • Admin
      Admin over 11 years
      You do realise that we don't generally consider windows 7 'server' to be topical here don't you. Super User is a better place for that kind of question.
    • Iiridayn
      Iiridayn over 11 years
      @Iain I had not realized it - the question is about workstation configuration in a large corporate office. As such I felt that it struck points 1 and 3 on the faq page. As you point out, since my issue could also be generalized to include home use, it also meets Super User posting standards ("specific issues with computer ... networking"). Would you be able to migrate it over?
  • Iiridayn
    Iiridayn over 10 years
    Marking as accepted as the solution was adequate and I don't need it now. Willing to accept a better answer.
  • Iiridayn
    Iiridayn almost 9 years
    I no longer work at that company, though I could probably set up the situation again from home. How would adjusting NIC priority prevent Windows from routing traffic to 8.8.8.8 when only 1 NIC is found?