How to get default NIC Connection Name

后端 未结 6 1628
刺人心
刺人心 2021-01-01 02:27

IMPORTANT EDIT: Back again on this subject. As you said there should be no default NIC, I\'m trying to understand if there is a way to detect all the NICs t

6条回答
  •  生来不讨喜
    2021-01-01 02:41

    As others have mentioned, there is no "Default" NIC adapter in Windows. The NIC used is chosen based on the destination network (address) and the metric.

    For example, if you have two NICs and two different networks:

      10.1.10.1 - Local Area Connection (metric 20)
      10.1.50.1 - Local Area Connection 2 (metric 10)
    

    And you want to connect to 10.1.10.15, Windows will choose Local Area Connection and route that way. Conversely, if you want to connect to 10.1.50.30, Windows will choose Local Area Connection 2.

    Now, if you try to connect to 74.125.67.106 (google.com), Windows will choose Local Area Connection 2 because it has a lower metric value.

    EDIT: Here is a great article explaining routing - http://www.windowsnetworking.com/articles_tutorials/Making-Sense-Windows-Routing-Tables.html
    EDIT2: Spelling.

    Hope this helps.

提交回复
热议问题