TCL Script to get MAC to IP and connected port
TCL Script to get MAC to IP and connected port
I have used simple image to test and it works fine
below IOS i have tested in my LAB.
INET#show version
Cisco IOS Software, vios_l2 Software (vios_l2-ADVENTERPRISEK9-M), Version 15.2(HI_20170202)FLO_DSGS7, EARLY DEPLOYMENT DEVELOPMENT BUILD, synced to FLO_DSGS7_POSTCOLLAPSE_TEAM_TRACK_DSGS_PI5
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2017 by Cisco Systems, Inc.
Compiled Thu 02-Feb-17 06:12 by mmen
Here is the steps
INET#tclsh
INET(tcl)#puts [open “flash:tcl_script1.tcl” w+] {
PASTE here your TCL Script to run
#############
foreach ip $::argv {
set result [exec “show arp | inc $ip”]
if [regexp {[a-zA-Z]+\s+\d+\.\d+\.\d+\.\d+\s+\d+\s+([0-9a-f]+\.[0-9a-f]+\.[0-9a-f]+)\s+ARPA} $result match mac ] {
set output [exec “show mac address-table address $mac”]
regexp {(\d+\s+[0-9a-f]+\.[0-9a-f]+\.[0-9a-f]+\s+[A-Z]+\s+[0-9\/a-zA-Z]+)} $output match output
puts “$ip = $output”
} else {
puts “$ip not in arp table”
}}
########
} – To close the script
INET(tcl)#tclquit
INET#
here is my test
It works, simple for day to day life of DevOps.
I am going to create another one..which collect all MAC address and IP and port information stored in Database, so Engineer can pull the data when ever required
happy labinnggggggggggggg !