Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Traceroute MAC "mac" "mac#

Hello guys,

 

I currently have this script, it's not good, but neither I am.

Either way I'm trying to improve this script, and I want to add a command to the script, but I don't know how or where.

This script is to find devices on the network, I work with large LAN environments and some devices aren't documented yet.

 

The idea behind this is to ping the range of addresses and resolve their mac addresses, then it would do a traceroute to the mac address.

traceroute mac xxxx.xxxx.xxxx xxxx.xxxx.xxxx, I currently have this.

Can you guys help me to improve this and add this command to what I already have?? Almost of it is taken from this forum so I hope you can help me.

 

proc validate {args} {
foreach address $args {
    set output [exec "ping $address"]
    puts $output
    if { [regexp {.!!!!} $output] } {
        set output [exec "show ip arp $address"]
        puts $output
    }
}}
validate 10.112.0.251
proc resolve {args} {
foreach ip $args {
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"
}
}}
resolve 10.112.0.251

 

In the end I obtain this output

Exxxxxx-B1SW1(tcl)#resolve 10.112.0.251
10.112.0.251 = 11    0800.277c.39cc    DYNAMIC     Gi0/13


but I want to receive this as well

traceroute mac 0040.8c93.749c 0040.8c93.749c
Source 0040.8c93.749c found on E1405897-B2SW1
1 E1405897-B2SW1 (10.xx.xx.57) : Gi0/12 => Gi0/12
Destination 0040.8c93.749c found on Exxxxx-B2SW1
Layer 2 trace completed

Thanks in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

It could be as simple as

It could be as simple as adding this after your puts "$ip ..." line:

 

set tro [exec "traceroute mac $mac $mac"]

puts "Traceroute = $tro"

2 REPLIES
Cisco Employee

It could be as simple as

It could be as simple as adding this after your puts "$ip ..." line:

 

set tro [exec "traceroute mac $mac $mac"]

puts "Traceroute = $tro"

New Member

Thanks men!!!

Thanks men!!!

216
Views
5
Helpful
2
Replies
CreatePlease login to create content