Search for PC connection port by MAC address (Cisco)

Sometimes, we need to know which switch port a PC is connected in order to troubleshoot LAN connection problem.  Statistics on the access port, such as input error, CRC error, Duplex and speed setting is often very useful for troubleshooting.

In a LAN environment with hundreds of PC and poor documentation, it is difficult to locate which access port a computer is connecting to.  Besides following the label on structure cable system, we can use MAC address and few Cisco command to do the job.
  1. Open Command Prompt.
  2. Find the MAC address of the PC first:
    C:\>ping MyPC

    Reply from 192.168.1.4: bytes=32 time<1ms TTL=128
    Reply from 192.168.1.4: bytes=32 time<1ms TTL=128

    Ping statistics for 10.68.11.49:
    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

  3. At this point, the MAC address will be saved in ARP cache in the computer.  Use the below command to reveal the MAC address.
    C:\>arp -a | findstr "
    192.168.1.4"
        192.168.1.4            00-aa-bb-cc-dd-ee      dynamic

  4. (For Cisco IOS command)  The below will show how to find MAC address in IOS.  Login to your network Cisco switch to find the connection port: C:\>telnet your_switch

    User Access Verification

    Password:
    your_switch>en
    SW2#show mac address-table dynamic address  00aa.bbcc.ddee
              Mac Address Table
    -------------------------------------------

    Vlan    Mac Address       Type        Ports
    ----    -----------       --------    -----
       3    00aa.bbcc.ddee    DYNAMIC     Gi0/2
    Total Mac Addresses for this criterion: 1

     

    (For CatOS)your_switch is an old Cisco switch using CatOS.  The below will show how to find MAC address in CatOS.  Login to your network Cisco switch to find the connection port:

    C:\>telnet your_switch

    Cisco Systems Console
    Welcome to your_switch

    Enter password:
    your_switch> en

    Enter password:
    your_switch> (enable) show cam 00-aa-bb-cc-dd-ee
    * = Static Entry. + = Permanent Entry. # = System Entry. R = Router Entry.
    X = Port Security Entry $ = Dot1x Security Entry


    VLAN Dest MAC/Route Des [CoS] Destination Ports or VCs / [Protocol Type]
    ---- ------------------ ----- -------------------------------------------
    3     00-aa-bb-cc-dd-ee       3/8                             [ALL]
    Total Matching CAM Entries Displayed =1

  5. (IOS) We know that myPC is connected to your_switch via port Gi0/2.  Let's check if Gi0/2 is connected to another Cisco switch, not directly to myPC.  Cisco Discovery Protocol(CDP) must be enabled in order to use the below command. 
    your_switch#show cdp neighbors Gi0/2
    Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                      S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone

    Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
    core_switch      Gig 0/2           142          R S I     WS-C4507R Gig 1/1

    (CatOS)We know that myPC is connected to your_switch via port 3/8.  Let's check if 3/8 is connected to another Cisco switch, not directly to myPC.  Cisco Discovery Protocol(CDP) must be enabled in order to use the below command.

    your_switch> (enable) show cdp neighbors 3/8
    * - indicates vlan mismatch.
    # - indicates duplex mismatch.
    Port  Device-ID      Port-ID              Platform
    ----- -------------- -------------------- ---------
    3/8   your_switch2   GigabitEthernet0/1   cisco WS-C3560-24TS

  6. (IOS) At this point we know that myPC is connected to your_switch via your_switch2.  Let's go to your_switch2 and find out which access port myPC is connecting.  Please note your_switch2 is using IOS.  The below sample is using IOS command.

    C:\>telnet your_switch2
      
    Welcome to your_switch2

    User Access Verification

    Password:
    your_switch2>en
    Password: 

    your_switch2#show mac-address-table address 00-aa-bb-cc-dd-ee
              Mac Address Table
    -------------------------------------------

    Vlan    Mac Address       Type        Ports
    ----    -----------       --------    -----
       3    00aa.bbcc.ddee    DYNAMIC     Fa0/13

    Total Mac Addresses for this criterion: 1


  7. We then know that myPC is connected at FastEthernet port 13.

  8. (IOS)To know more information about that access port, use the below command:
    your_switch2#show interfaces Fa0/13
    FastEthernet0/13 is up, line protocol is up (connected)
      Hardware is Fast Ethernet, address is 0018.7300.1122 (bia  0018.7300.1122 )
      MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,
         reliability 255/255, txload 1/255, rxload 1/255
      Encapsulation ARPA, loopback not set
      Keepalive set (10 sec)
      Full-duplex, 100Mb/s, media type is 10/100BaseTX
      input flow-control is off, output flow-control is unsupported
      ARP type: ARPA, ARP Timeout 04:00:00
      Last input never, output 00:00:01, output hang never
      Last clearing of "show interface" counters never
      Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
      Queueing strategy: fifo
      Output queue: 0/40 (size/max)
      5 minute input rate 50000 bits/sec, 11 packets/sec
      5 minute output rate 125000 bits/sec, 19 packets/sec
         17009916 packets input, 2224460537 bytes, 0 no buffer
         Received 49139 broadcasts (0 multicast)
         0 runts, 0 giants, 0 throttles
         1 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
         0 watchdog, 28 multicast, 0 pause input
         0 input packets with dribble condition detected
         53834839 packets output, 3153486266 bytes, 0 underruns
         0 output errors, 8 collisions, 2 interface resets
         0 babbles, 35 late collision, 0 deferred
         0 lost carrier, 0 no carrier, 0 PAUSE output
         0 output buffer failures, 0 output buffers swapped out


  9. (IOS) Can search via ARP cache

    your_switch2#show ip arp vrf yourvrfname vlan_number | include yourMACaddress






Comments

Anonymous said…
My partner and I absolutely love your blog and find most of
your post's to be just what I'm looking for. Does one offer guest writers to write content for yourself? I wouldn't mind writing a post or elaborating on a lot of the subjects you write in relation to here. Again, awesome website!
my web site >