Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In Windows/Windows Server, if I have a physical NIC that has two or four ports on it, is there a scriptable/programmatic way to determine which "Network Connection" (such as "Local Area Connection 3", for example,) is associated with which physical NIC port?

I took a quick glance through the win32_networkadapter and win32_networkadapterconfiguration classes, but didn't see anything immediately helpful.

share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

The big problem is that Windows does not enumerate installed NICs in any particular order. This is a common issue with server configuration. Assuming you're configuring the server manually (which is what we normally do), you can just shut/no shut the ports to see which is connected to what.

If you need your NICs enumerated in a particular order, one trick that I use is to map the ports as described above, then in device manager, delete the NICs that are enumerated incorrectly. When Windows re-installs the NICs they will be randomly assigned again. After doing this a few times while not touching ones that are in the correct order, the enumeration will be correct.

If you need a scriptable NIC enumeration capability, Kelvin Wong has done some work with this using WMI queries to look through the registry. Note that NIC settings in the registry require you to cross-reference multiple entries in different locations, so it will require some work on your part to ensure your script is designed properly.

share|improve this answer
    
You all provided good answers, but in the end I am going to have to pick this answer, because it is the one that helped me the most. Especially the link to Wong's info. Thanks! –  Ryan Ries Feb 17 '12 at 16:14
add comment

Well, the output of ipconfig /all includes the MAC address of all ports on the system.

As far as I know, there's no hard and fast way to programmatically correlate these MAC addresses with physical ports. Typically physical interface in cards like these have sequential MAC addresses. In the case of an add-on PCI card, the MAC addresses typically increase numerically starting with the interface closest to the PCI bus.

In the case of built-in ports, I'd just look at the CAM table on the switch it's connected to and then trace cables.

share|improve this answer
    
The sequential MAC addresses is a good idea. I might try that as a best effort sort of thing if I can't find any better solution. Thanks for your help. –  Ryan Ries Feb 16 '12 at 17:36
add comment

Most high end cards come with a utility that allows you to do advanced configuration tasks. One of the option is commonly to make the lights on the port blink in a set pattern so you can identify the ports.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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