Home > Cisco, Computing > How to find which port a device is connected to on your Cisco switch

How to find which port a device is connected to on your Cisco switch


I don’t work with network gear very often so every time I need to find out which switch port a device is connected to, I’ll typically have to do a quick search to find the commands.  So now I’ve decided to write a good tutorial.  The network that I manage is disconnected from the internet so I can’t post screen shots, but what you see are recreations of the screen shots I printed. 

The first thing to do is find the IP address of the device you’re looking for.  So the first step is to open a command window and use nslookup.

C:\>nslookup area1-wks01
Server: dc1.domain.com
Address: 199.254.7.10

Name: area1-wks01.domain.com
Address: 199.254.7.100

From the output you can see that the domain controller that responded to the lookup, the Fully Qualified Domain Name (FQDN) of the device, and its IP address.

Now it’s time to log into your router or some other layer 3 device in your network.  In my case it’s a 3750 switch stack that handles routing between the various subnets I have configured.  I use Putty because it supports SSH.  The first thing to do is to ping the IP address.  This will populate the ARP table.

Sw-stack#ping 199.254.7.100
Type excape sequence to abort.
Sending 5, 100-byte ICMP Echos to 199.254.7.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/8 ms

Next we have to find the mac address of the device. By pinging the device it’s mac address will be listed in the arp table.

Sw-stack#show ip arp 199.254.7.100
Protocol  Address           Age (min)  Hardware Addr   Type   Interface
Internet  199.254.7.100            1   001a.a07f.4a94  ARPA   Vlan7

Ok, from here there are two ways to find the device; the hard way and the easy way.  I’ll show the hard way first because it’s the way most people do it.  We need to search the mac address table to find out which port to follow.

Sw-stack#show mac address-table address 001a.a07f.4a94
          Mac Address Table
------------------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   7    001a.a07f.4a94    DYNAMIC     Gi2/0/25
Total Mac Addresses for this criterion: 1

Sweet! We see that our workstation is connected to Gi2/0/25.  Well it’s not quite that simple because I doubt your workstations are connected to you Layer 3 device.  A quick look at my network diagram indicates that Gi2/0/25 is a trunk connecting to another switch.  Don’t have a network diagram or too lazy to find it.  Fine, you can use the command show cdp neighbors to see which switch or router is connected to that port.  In my case this trunk goes to a switch called area1-sw1 so now I need to logon to that switch and issue the same command.

Area1-sw1# show mac address-table address 001a.a07f.4a94
          Mac Address Table
------------------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   7    001a.a07f.4a94    DYNAMIC     Gi0/22
Total Mac Addresses for this criterion: 1

Now once again looking at my handy network diagram I see that Gi0/22 is another trunk leading to another switch.  So now I need to logon to that switch (area1-sw2) and once again issue the same command.

Area1-sw2# show mac address-table address 001a.a07f.4a94
          Mac Address Table
------------------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   7    001a.a07f.4a94    DYNAMIC     Gi0/3
Total Mac Addresses for this criterion: 1

I know by looking at my diagram that this switch is the end of the line so I’ve finally found the switch and port that area1-wks01 is connected to.  Done!

If you have all Cisco devices and CDP is enabled (it is by default) then there is an easier way to find the devic,e as long as it is local to the first Layer 3 device you logged into (not routed somewhere else).  If this is the case then you won’t need to logon to each switch in the chain to find the port.  Instead do a Layer 2 traceroute using the mac address.

Sw-stack#traceroute mac 001a.a07f.4a94 001a.a07f.4a94
Source 001a.a07f.4a94 found on area1-sw2
1 area1-sw2 (199.254.98.59) : Gi0/3 => Gi0/3
Destination 001a.a07f.4a94 found on area1-sw2
Layer 2 trace completed

As you can see I used the same source and destination mac address and area1-sw2 came back and shows the source and destination as Gi0/3.  This will save you loads of time as long as you have an idea of where the device is located and logon to a local Layer 3 network device.  Have fun and keep those network drawings up to date!

About these ads
Categories: Cisco, Computing Tags: ,
  1. August 27, 2011 at 4:07 PM | #1

    I liked your article is an interesting technology
    thanks to google I found you

  2. Mohammed Rizwan Abdul Kareem
    October 24, 2011 at 9:45 PM | #2

    thanks a lot man..

  3. November 21, 2013 at 8:57 PM | #3

    I wrote a three part guide about CDP and network discovery with Cisco gear with similar concepts on my blog over at http://technologyordie.com/discovering-a-cisco-network-with-cdp-part-1

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: