cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2976
Views
0
Helpful
6
Replies

script to get all IP connected to interfaces

amir83
Level 1
Level 1

I can get mac address from each interface from the following command -

 

sw1#show mac address-table interface Gi1/0/23
Mac Address Table
-------------------------------------------

Vlan Mac Address Type Ports
---- ----------- -------- -----
500 0007.5avd.fcn2 DYNAMIC Gi1/0/23
Total Mac Addresses for this criterion: 1

 

AND THEN TO GET IP FOR THAT MAC ADD,  I TYPE THE FOLLOWING COMMAND-


sw1#show arp | i 0007.5avd.fcn2
Internet 10.7.2.39 1 0007.5avd.fcn2 Vlan500

 

 

So for each interfaces I have to do this command to get all IPs for each MAC address.

How can I get all of the IP and MAC address in one command for each interfaces.

 

Is there a way write a script .

 

Also if a device is disconnected, I don't get IP and MAC address anymore.  Is there a way it saves the information prior to disconnect.

 

Thank you.

1 Accepted Solution

Accepted Solutions

balaji.bandi
Hall of Fame
Hall of Fame

There is number ways to look this and capture the information .

 

1. you can use SNMP and Grab all the information and store data periodically and use for report.

2. you can use script to get all the same arp and IP information, store locally and co-relate the information offline scripts.

 

 

example :

 

https://github.com/rikosintie/ARP-Sort

https://brezular.com/2015/11/29/collecting-mac-and-ip-adresses-of-hosts-connected-to-cisco-switches-using-snmp/

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

View solution in original post

6 Replies 6

balaji.bandi
Hall of Fame
Hall of Fame

There is number ways to look this and capture the information .

 

1. you can use SNMP and Grab all the information and store data periodically and use for report.

2. you can use script to get all the same arp and IP information, store locally and co-relate the information offline scripts.

 

 

example :

 

https://github.com/rikosintie/ARP-Sort

https://brezular.com/2015/11/29/collecting-mac-and-ip-adresses-of-hosts-connected-to-cisco-switches-using-snmp/

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

amir83
Level 1
Level 1
command work on core router but I am working on a switch

Leo Laohoo
Hall of Fame
Hall of Fame

Depending on the model and, if 3650/3850 &/or Catalyst 9k, IOS-XE version, there is an easier way by using IP Device Tracking. 

For Classic IOS

1.  Configure IP device tracking globally

ip device tracking

2.  Configure IP device tracking on the interface level 

interface <PORT>
 ip device tracking max <VALUE>

3.  Give the switch about 10 seconds and then check the DB

show ip device tracking all

NOTE:

Configuring IP Device Tracking on switches running IOS-XE can be confusing because Cisco has changed the commands, depending on the firmware when it was first enabled.  If the command "ip device tracking" does not work then use the alternate command "device-tracking".  

 

First of all , thank you.

Cisoc 9300 switch:

 

There was a device connected to a port but now the device is faulty and cant connect and its not live anymore, how can I find out that particular device MAC, IP and Port which is not live anymore?

 

Port Name Status Vlan Duplex Speed Type
Gi1/0/1 notconnect 100 auto auto 10/100/1000BaseTXshow

 

show mac address-table does not show that Gi1/0/1

 

 

Neither command is working for C9300 switch.

 

balaji.bandi
Hall of Fame
Hall of Fame

There is no way you can find,

 

1 .until you have periodic information stored any where in the archive.

2. you have DHCP static Entry setup 

3. ARP table not expired in the switch.

 

if any of the case True, sorry you wont helpful much here.

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Review Cisco Networking for a $25 gift card