{"id":602,"date":"2017-11-11T23:01:42","date_gmt":"2017-11-11T23:01:42","guid":{"rendered":"http:\/\/www.balajibandi.com\/?p=602"},"modified":"2017-11-11T23:01:42","modified_gmt":"2017-11-11T23:01:42","slug":"tcl-script-to-get-mac-to-ip-and-connected-port","status":"publish","type":"post","link":"https:\/\/www.balajibandi.com\/?p=602","title":{"rendered":"TCL Script to get MAC to IP and connected port"},"content":{"rendered":"<h1><span style=\"text-decoration: underline;\"><strong>TCL Script to get MAC to IP and connected port<\/strong><\/span><\/h1>\n<p>&nbsp;<\/p>\n<p>I have used simple image to test and it works fine<\/p>\n<p>below IOS i have tested in my LAB.<\/p>\n<p>INET#show version<br \/>\nCisco 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<br \/>\nTechnical Support: http:\/\/www.cisco.com\/techsupport<br \/>\nCopyright (c) 1986-2017 by Cisco Systems, Inc.<br \/>\nCompiled Thu 02-Feb-17 06:12 by mmen<\/p>\n<p>Here is the steps<\/p>\n<p>INET#tclsh<br \/>\nINET(tcl)#puts [open &#8220;flash:tcl_script1.tcl&#8221; w+] {<\/p>\n<p>PASTE here your TCL Script to run<\/p>\n<p>#############<br \/>\nforeach ip $::argv {<br \/>\nset result [exec &#8220;show arp | inc $ip&#8221;]<br \/>\nif [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 ] {<br \/>\nset output [exec &#8220;show mac address-table address $mac&#8221;]<br \/>\nregexp {(\\d+\\s+[0-9a-f]+\\.[0-9a-f]+\\.[0-9a-f]+\\s+[A-Z]+\\s+[0-9\\\/a-zA-Z]+)} $output match output<br \/>\nputs &#8220;$ip = $output&#8221;<br \/>\n} else {<br \/>\nputs &#8220;$ip not in arp table&#8221;<\/p>\n<p>}}<\/p>\n<p>########<\/p>\n<p>}\u00a0 &#8211; To close the script<\/p>\n<p>INET(tcl)#tclquit<br \/>\nINET#<\/p>\n<p id=\"YdWmuKK\"><img loading=\"lazy\" decoding=\"async\" width=\"666\" height=\"160\" class=\"alignnone size-full wp-image-603 \" src=\"http:\/\/www.balajibandi.com\/wp-content\/uploads\/2017\/11\/img_5a0780cee2ebd.png\" alt=\"\" srcset=\"https:\/\/www.balajibandi.com\/wp-content\/uploads\/2017\/11\/img_5a0780cee2ebd.png 666w, https:\/\/www.balajibandi.com\/wp-content\/uploads\/2017\/11\/img_5a0780cee2ebd-300x72.png 300w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/p>\n<p>here is my test<\/p>\n<p id=\"nGAnmov\"><img loading=\"lazy\" decoding=\"async\" width=\"509\" height=\"41\" class=\"alignnone size-full wp-image-604 \" src=\"http:\/\/www.balajibandi.com\/wp-content\/uploads\/2017\/11\/img_5a0781036315a.png\" alt=\"\" srcset=\"https:\/\/www.balajibandi.com\/wp-content\/uploads\/2017\/11\/img_5a0781036315a.png 509w, https:\/\/www.balajibandi.com\/wp-content\/uploads\/2017\/11\/img_5a0781036315a-300x24.png 300w\" sizes=\"auto, (max-width: 509px) 100vw, 509px\" \/><\/p>\n<p>It works, simple for day to day life of DevOps.<\/p>\n<p>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<\/p>\n<p>happy labinnggggggggggggg !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TCL Script to get MAC to IP and connected port &nbsp; 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-602","post","type-post","status-publish","format-standard","hentry","category-cisco"],"_links":{"self":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=602"}],"version-history":[{"count":1,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/602\/revisions"}],"predecessor-version":[{"id":605,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=\/wp\/v2\/posts\/602\/revisions\/605"}],"wp:attachment":[{"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.balajibandi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}