cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
391
Views
10
Helpful
3
Replies

Need Port Number, MAC, and IP for every Device per Switch

Hershey1702
Level 1
Level 1

Hello,

 

I have inherited a network with which very little documentation exists. I need to get the IP, MAC, and port number for every device per switch on my network.

The current method has been time consuming as I have had to ping the IP to generate the arp record and then I can get the info I need, but I am wondering if there is a way to get a list with the needed attributes through command line or a tool that can do the work? Any help is appreciated.

3 Replies 3

Leo Laohoo
Hall of Fame
Hall of Fame

Depends on the platform/IOS version but one way is to enable IP Device Tracking.

Dan Frey
Cisco Employee
Cisco Employee

I had to do something similar a while ago and used this tool in the device tcl shell to get the output.

ping 192.168.0.255
tclsh
set hostname [info hostname]
set result [exec show arp]
set lines [split $result "\n"]
foreach line $lines {
    if [regexp {[a-zA-Z]+\s+(\d+\.\d+\.\d+\.\d+)\s+[0-9]+\s+([0-9a-f]+\.[0-9a-f]+\.[0-9a-f]+)\s+ARPA\s+([A-Za-z0-9]+)} $line match ip mac vlan] {
        set output [exec "show mac address-table | inc $mac"]
        if [regexp {DYNAMIC\s+([A-Za-z0-9\/\-]+)} $output match port] {
            puts "$hostname  $ip  $mac  $vlan  $port"
        }
        set output ""
    }
}

 Run the script on the switch CLI produces this output.

C3750X-G  192.168.0.33  e00e.da71.cc40  Vlan1  Gi1/0/12
C3750X-G  192.168.0.39  40f4.ec05.1b40  Vlan1  Gi1/0/47
C3750X-G  192.168.0.1  00be.7590.3a74  Vlan1  Gi1/0/48
C3750X-G  192.168.0.25  a023.9f8d.7818  Vlan1  Gi1/0/20
C3750X-G  192.168.0.26  a023.9f8d.781e  Vlan1  Gi1/0/19
C3750X-G  192.168.0.27  74a0.2fa4.9252  Vlan1  Gi1/0/16
C3750X-G  192.168.0.28  74a0.2fa4.9256  Vlan1  Gi1/0/17
C3750X-G  192.168.0.29  e00e.da71.dc1c  Vlan1  Gi1/0/2
C3750X-G  192.168.0.31  003a.7d31.3c24  Vlan1  Gi1/0/7
C3750X-G  192.168.0.19  5254.00e9.239b  Vlan1  Gi1/0/18
C3750X-G  192.168.0.20  5254.00b6.bb8b  Vlan1  Gi1/0/27
C3750X-G  192.168.0.244  084f.a90b.ef71  Vlan1  Gi1/0/25
C3750X-G  192.168.0.245  b08b.d076.d85e  Vlan1  Gi1/0/48
C3750X-G  192.168.0.212  5254.00f6.f9f1  Vlan1  Gi1/0/18

 

 

WoW