Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Since the wall jack is typically always connected to the same port on the switch I would like to be able to know which device is connected at a specific location. In my case I am talking about printers. I have code to go out on the network and find the IP Address of all of my printers, but would like to be able to update a server based on a printer being swapped out of a location for maintenance or repair. Is there a method for determining a port connection?

share|improve this question

migrated from May 26 '10 at 12:57

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

Doesn't your switch give you that information? – Nikolai N Fetissov May 26 '10 at 12:53
Only higher end switches give this information Nikolai. Knowing the switch manufacturer and model would help us answer the question. – Chris S May 26 '10 at 13:26
I would like a generic solution as I would like to provide this for customers of our printers. We may need to focus on a few major switch providers as this does appear to be switch specific. – banno May 26 '10 at 15:24

To do this manually you would use arp to get a map of MACs to IPs, then use the switch's MAC (or bridge) table to get a map of ports to MACs. put the two tables together and you have a map of IPs to ports. Bump that up against your list of IPs->printers, and there you go - a list of printers and the ports their on.

Here's an example where I can cheat a little because it's an L3 switch - I can do the arp and mac steps from the same device. Say I want to find what port is on:

tc-3750-1#sh arp | inc
Internet              6   0013.7269.075d  ARPA   Vlan2
Internet            23   0026.b931.ce28  ARPA   Vlan2
tc-3750-1#sh mac-
tc-3750-1#sh mac-address-table | inc 0013.7269.075d
   2    0013.7269.075d    STATIC      Gi2/0/3

et voila, is on port g2/0/3. This is IOS, I think in Dell switches the MAC step is "show bridge" or something similar. This becomes harder when you have a multi-switch L2 network, but the principal is the same.

I don't have extensive experience, but it sounds like you might want to play with something like NetDisco, which offers what you're asking and also stuff like change control (as I understand it you could, for instance, track the port a MAC was connected to over time across multiple devices)

share|improve this answer
What is the 'inc' command in Linux? What Linux distribution? – Edward_178118 May 18 at 7:44
'inc' is just short for "include", and its unix equivalent is grep, available on any unix/linux distribution worth its salt. – jj33 May 19 at 13:25

If it is a managed switch, you should be able to use SNMP to see the state of physical ports on a switch, if that is what you mean. Easier, would be to just ping the ip periodically.

share|improve this answer

you could use an application like nedi which can help you with documenting your network topology

share|improve this answer
+1 for mentioning NeDi. New to me. – Henk Mar 16 '12 at 14:45

Your Answer


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.