Update – [Cisco] I wrote a script that will take an IP address and give return the edge switch and port to which it’s connected

Update – [Cisco] I wrote a script that will take an IP address and give return the edge switch and port to which it’s connected

Original post

I greatly enjoyed the (mostly) positive responses I received when I first shared my script and am excited to share the latest enhancements I’ve made. Please see the usage examples below, and please see the Cisco IP Trace github page for additional info and to hopefully download the script!

The script will now allow you to scan a single IP address or scan a contiguous IP range within a /24.

Do you want to scan a single IP or a range? 1. Single IP 2. Range (must be contiguous; no greater than /24) Please input 1 or 2: 

Single IP:

Enter IP address to trace: 10.1.10.184 Enter the IP address of the core router/switch that can ARP for the IP address to trace: 10.1.1.1 Username: admin Password: ******** 

Range of IPs:

Enter first three octets of subnet you'd like to scan (ex. 10.1.1.): 10.1.10 Enter last octet of first IP in the range to scan: 184 Enter the last octet of the last IP in the range to scan: 187 Enter the IP address of the core router/switch that can ARP for the IP address to trace: 10.1.1.1 Username: admin Password: ********* 

The output is mostly the same as the example in my original post, except now the script will alert you if multiple MAC addresses are currently learned on the edge port, or if the IP address provided is a CDP neighbor:

Note: More than one MAC found on this port, possible unmanaged switch present. 10.1.10.184,abcd.4567.2fc2,SwitchA,Gi2/0/30 Note: The IP provided is a CDP neighbor. 10.1.1.10,0124.abcd.1234,CoreA,Gi4/1 

It was pointed out by a few people in my original post that there are already solutions to do this, likely better than this script. That’s great! I really didn’t intend to re-invent the wheel. I was unaware of those solutions when I first wrote this script, but was still happy to learn of them in my last post. The creation of this script was more of a personal challenge to learn more Python and to automate something I was in the habit of doing manually.

Overall, I still hope this script is useful to at least one person who comes across this. Please let me know what you think. Thanks!

submitted by /u/routetehpacketz to r/networking
[link] [comments]

top scoring links : multi

Related posts

Leave a Comment