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.

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.

share|improve this question

migrated from stackoverflow.com Apr 22 '10 at 14:26

This question came from our site for professional and enthusiast programmers.

    
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
1  
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
add comment

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.

share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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 200.100.100.3.txt).

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

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.