Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

The catch is you have no SNMP access, not even public.
The end vision is locate a PC in building easily even if PC's are moved around.

The MAC address of the PC is known and the software would run as client on each desktop, reporting back which port the PC was plugged into.

Well from a programmer perspective, my network skills are not the best. Yes I could use SNMP, download the MAC port table, load it into SQL, match it to the PC name. Seems alot of work.

Lets say I ping a single point from the PC. Would the echo have some thing unique for each device on the same switch? All I need to identify some thing unique for each PC plugged into each port.
If the PC was moved from location A to a different location then the unique response would change.


migration rejected from Feb 17 at 19:09

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by HopelessN00b Feb 17 at 19:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions should demonstrate reasonable business information technology management practices. Questions that relate to unsupported hardware or software platforms or unmaintained environments may not be suitable for Server Fault - see the help center." – HopelessN00b
If this question can be reworded to fit the rules in the help center, please edit the question.

What kind of a switch are you using? Also, does this need to be 100% automatic without any human intervention? – Cristian Ciupitu Apr 22 '10 at 14:41
No SNMP, okay. Do you have any access at all to the switch? Can you log into it with ssh, https, etc.? Or, are you saying that someone else holds the keys to the switch and isn't sharing? – Skyhawk Apr 22 '10 at 15:18

4 Answers 4

up vote 3 down vote accepted

You're saying that you have no SNMP access to the swtich, and want to run a script on the Windows PC to query what port on that switch you're on? There is no way to do that. The only thing that can tell you that level of info is the switch itself. SOL, sorry to say.

Unless you have some other method of querying the switch, that is. If you don't have SNMP but had console access, you could login and query the CAM table - and if you had a list of MAC addresses, like from your DHCP server, you could correlate them that way.

/Edit- perhaps other people's suggestion of CDP Client software on the PC could do it, assuming you've got CDP-enabled switches.

I see your edit to your question, and there is no way for a PC to know what port on the switch it's plugged into, without the switch telling it. Either via CDP, SNMP, or something similar. – mfinni Apr 23 '10 at 13:12

Do your switches support CDP or LLDP? If so, you just have to capture the packets on the PC. Spanning tree has a port ID field as well, but its value might require further interpretation depending on the make and model of the switch. For example, LLDP says I'm plugged into port "g7". STP says it's 0x8007.

If you don't want to do the packet dissection yourself you could use WinDump/tcpdump or TShark.


If your switch is a Cisco one, then you can use CDP (Cisco Discovery Protocol) to know what switch you're plugged into, and on which port.

There are both free and commercial CDP applications available.


We occasionally used a script which SSH into our switches, downloads the MAC address table table as a text file for each switch (named as

Then use grep on the directory containing the files to find the port.


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