How to Determine Which Switch and Port You are Connected To

Contributor Icon Contributed by Caveman Date Icon May 4, 2005  
Tag Icon Tagged: Cisco switch

Sometimes you need to know which switch and port you are connected to. I work for a community college with hundreds of switches. Here is a method I’ve found to work well.


Pick a switch you think might be a likely candidate and telnet in.

> telnet 10.10.125.5

Once you are logged in to the switch, go to Privileged EXEC mode.

rssv125-sw5> enable

Look in the MAC address table to find your computer’s MAC address.

rssv125-sw5# show mac-address-table address 0002.3F39.BFE6

You will get a response similar to this:

Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
59 0002.3f39.bfe6 DYNAMIC Fa0/24
Total Mac Addresses for this criterion: 1

If your port is a FastEthernet port (Fa0/nn) like this example shows, you know that you are connected to FastEthernet port 0/24 on switch 10.10.125.5 (rssv125-sw5).

However, many times you will get a response similar to this:

Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
59 0002.3f39.bfe6 DYNAMIC Gi0/1
Total Mac Addresses for this criterion: 1

The Gi0/n indicates you are connected to a gigabit port. Since the gigabit ports only go to other switches, you know you are connected to another switch. To see what the neighboring switches are, use CDP (Cisco Discovery Protocol).

rssv125-sw5# show cdp neighbor Gi0/1 detail

The response should be something similar to this:

Device ID: rssv125-sw4
Entry address(es):
IP address: 10.10.125.4
Platform: cisco WS-C3550-24-PWR, Capabilities: Switch IGMP
Interface: GigabitEthernet0/1, Port ID (outgoing port): GigabitEthernet0/1
[snip]

Now go back to the telnet step above and run through it again except this time use the 10.10.125.4 IP address from the show cdp neighbor output. Repeat until you find the switch and port you are connected to.

Previous recipe | Next recipe |
 
  • Caveman
    I have used this primarily on 2950 and 3550 switches running IOS. If you find any others this works on, or you find switches it does not work on, please let me know. Thanks.

    It does not work on:
    - 4000 series w/ CatOS
  • dat
    thank for this useful guide.
  • aaronm
    If you can do all this on a network, they have some serious security concerns.... 8O
  • AWfki
    "show mac-address-table 0000.0000.0000" is too much typing for me, especially as I'm frequently called on to find which interface a server or user is connected to. Because I'm lazy in an efficient kind of way I add the "shmac" alias to all my switches.

    In config mode enter alias exec shmac SH MAC-address-table | include

    Now when you want to find a server that's got a mac address of 0102.0304.0506 you can just type shmac 0506
    and nine times out of ten you'll get the entry you're looking for. You may get multiple entries if you've got two devices with MACs ending in 0506 so you could type the whole MAC address, but I did mention that I'm "efficient" so I rarely do.

    I'd also like to note that while the author's network may always use gig interface for switch connections it's perfectly possible for a user to be connected to one so that's not actually a guarantee that's it's an interswitch link. Figuring that out requires that you know your network; which means that I can't think of a simple to explain way to figure out where the port shown leads to another switch.
  • Tony
    Is there a method if you don't have access (telnet) to the switch? Like the Fluke LinkRunner device.
blog comments powered by Disqus