rss logo

Find a Device’s IP Address on a Cisco Switch Port (Step-by-Step)

Cisco logo

This guide explains how to map the IP address of a device connected to a Cisco switch port. The process is straightforward and relies on the relationship between MAC addresses, ARP entries, and physical interfaces.

The procedure involves two key steps:

Prerequisite: The switch must have an IP address configured in the same VLAN as the devices you want to identify. (This configuration is explained in the next section.)

Network Architecture

The diagram below illustrates the network setup we'll be working with. Our goal is to determine which IP addresses are associated with the devices connected to interfaces Gi1/0/1 and Gi1/0/2 on the switch.

Diagram showing mapping between Cisco switch interfaces, MAC and IP addresses
Example of mapping MAC and IP addresses to switch ports.

Map IP Addresses to Physical Ports

Configure an IP Address on the Switch

đź’ˇ Note: The switch must have an IP address configured in the same VLAN as the devices you want to identify. In this example, all devices are located in VLAN 1.

  • To configure the VLAN 1 interface, use the following commands:
switch01(config)# interface vlan 1
switch01(config-if)# ip address 192.168.1.1 255.255.255.0
switch01(config-if)# no shutdown

Retrieve MAC Addresses

As mentioned earlier, switches operate at Layer 2 of the OSI model, which means there is no single command to directly map an IP address to a physical port. Instead, we need to follow a two-step process:

  • First, retrieve the MAC addresses of the connected devices using the switch's MAC address table.
  • Then, correlate each MAC address with its corresponding IP address by consulting the ARP table.

Let’s start by identifying the MAC addresses associated with our two physical interfaces.

  • Display the MAC address of the device connected to interface Gi1/0/1:
switch01# show mac address-table | include Gi1/0/1
   1    24b6.fd14.0853    DYNAMIC     Gi1/0/1
  • Display the MAC address of the device connected to interface Gi1/0/2:
switch01# show mac address-table | include Gi1/0/2
   1    f8db.8845.ef15    DYNAMIC     Gi1/0/2
  • Summarize the information gathered so far:
Interface MAC Address IP Address
Gi1/0/1 24b6.fd14.0853 -
Gi1/0/2 f8db.8845.ef15 -

Retrieve the IP Addresses

⚠️ Important: Pay attention to the MAC address format in the output of the show mac address-table and show arp commands. Depending on your switch model, the format may appear as 24b6.fd14.0853 or 24:b6:fd:14:08:53. Always run show mac address-table first to verify the format used by your device and adjust the commands accordingly.

  • Ping the IP addresses you want to identify in order to populate the switch’s ARP table:
switch01# ping 192.168.1.200
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.200, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/51/74 ms
switch01# ping 192.168.1.210
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.210, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 33/48/71 ms
  • Display the ARP table to correlate each MAC address with its corresponding IP address. Use the include filter to show only the relevant entry:
switch01# show arp | include 24b6.fd14.0853
Internet  192.168.1.210              0   24b6.fd14.0853  ARPA   Vlan1
switch01# show arp | include f8db.8845.ef15
Internet  192.168.1.200              0   f8db.8845.ef15  ARPA   Vlan1

Based on this output, we can conclude that the device with IP address 192.168.1.210 is connected to interface Gi1/0/1, and the device with IP address 192.168.1.200 is connected to interface Gi1/0/2.

Interface MAC Address IP Address
Gi1/0/1 24b6.fd14.0853 192.168.1.210
Gi1/0/2 f8db.8845.ef15 192.168.1.200

Map IP Addresses to Physical Ports with a DHCP Server

Having a DHCP server in the network greatly simplifies the process of mapping an IP address to a physical switch port. The DHCP service automatically maintains the association between each IP address and its corresponding MAC address, making it easier to trace devices.

  • From your DHCP server, retrieve the target IP address and the associated MAC address from the address leases list:
Windows DHCP server window showing Address Leases with the IP address 192.168.1.31 and the corresponding MAC address in the Unique ID column
From the DHCP server (Windows): retrieve the IP address in Client IP Address and the corresponding MAC address in Unique ID.
  • Next, search for the retrieved MAC address in the switch mac address-table to identify the corresponding physical port:
switch01# show mac address-table | include bc:24:11:7a:58:a7
     1         bc:24:11:7a:58:a7        gi1/0/4    dynamic

The output shows the VLAN and the exact switch interface (Gi1/0/4) where the device with this MAC address is connected.