04-11-2023 02:06 AM - edited 04-11-2023 03:26 AM
Hi All
This time, some of my company's access lines are not stable, so I want to check ping to some my partner tunnel IPs with big size.
I know the basic syntax of ping by tclsh, but my situation is my router (ISR 4431 IOS-XE) tunnels belong to some VRF
as example
with physical Router: list IP need to ping as X.1.1.1, X.2.2.2, X.3.3.3
need ping by command "ping <ip> repeat 1000 size 1400 df-bit" for all IPs
with vrf Partner_A: list IP need to ping as A.1.1.1, A.2.2.2
need ping by command "ping vrf Partner_A <ip> repeat 1000 size 1400 df-bit" for all IPs
with vrf Partner_B: list IP need to ping as B.1.1.1, B.2.2.2, B.3.3.3, B.4.4.4.4, B.5.5.5
need ping by command "ping vrf Partner_B <ip> repeat 1000 size 1400 df-bit" for all IPs
I created 3 separte tclsh scripts and each script works separatedly. But if I copy/paste to router all 3 scripts at the same time, the router only do the first tclsh script.
Could you please give me guide/syntax to make 1 tclsh script to ping all vrf at 1 script instead I need to run each script and wait until if finish to run the next.
Many thanks
Hai
Solved! Go to Solution.
04-12-2023 12:37 PM - edited 04-12-2023 12:50 PM
One option is to put all three scripts into a single file on the router flash then source the file to run.
MPLS(tcl)#source bootflash:pingvrf.tcl
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.2, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.6, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.10, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.2, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/4 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.6, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.10, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 7.7.7.7, timeout is 2 seconds:
..........
Success rate is 0 percent (0/10)
MPLS(tcl)#
MPLS(tcl)#more bootflash:pingvrf.tcl
foreach line {172.27.1.2 172.27.1.6 172.27.1.10} {
ping vrf mpls $line repeat 10
}
foreach line {172.27.3.2 172.27.3.6 172.27.3.10 7.7.7.7} {
ping vrf metro-ethernet $line repeat 10
}
Another option is to wrap them in a proc (no file on router media required). Then call the proc.
MPLS(tcl)#proc pingvrf {} {
+>foreach line {172.27.1.2 172.27.1.6 172.27.1.10} {
+>ping vrf mpls $line repeat 10
+>}
+>
+>foreach line {172.27.3.2 172.27.3.6 172.27.3.10 7.7.7.7} {
+>ping vrf metro-ethernet $line repeat 10
+>}
+>}
MPLS(tcl)#pingvrf
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.2, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.6, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.10, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/3 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.2, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.6, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.10, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 7.7.7.7, timeout is 2 seconds:
..........
Success rate is 0 percent (0/10)
MPLS(tcl)#
04-11-2023 02:33 AM
use below thread to ping multiple devices :
https://community.cisco.com/t5/network-management/how-to-ping-repeat-in-tclsh-ios-xr/m-p/4560412
04-11-2023 03:19 AM
Thanks @balaji.bandi for reply.
For tclsh script to ping multiple IPs in 1 vrf I already know (even repeate and other ping parameter). This case I need 1 tclsh to ping IPs from multiple vrf. If you know, please give me the example.
04-11-2023 07:05 PM
how about try below :
foreach ipa [list x.x.x.x y.y.y.y] ipb [list a.a.a.a b.b.b.b ] ipc [list c.c.c.c d.d.d.d] {
ping vrf west $ipa
ping vrf east $ipb
ping vrf north $ipc
}
04-12-2023 02:25 AM - edited 04-12-2023 02:57 AM
Thanks @balaji.bandi
Actually I did try using list by 2 cases:
1st test: as your guidance: it only works if all lists have the same numbers of IP. If IPA, B, C have different numbers of IP in list, tclsh script cannot work
2nd test: using format like that foreach {vrf name IP} [list " " " " 1.1.1.1 " " " " 2.2.2.2 " " " " 3.3.3.3 vrf VRFA 4.4.4.4 vrf VRFB 5.5.5.5 ....] {ping $vrf $name $IP}. It also works but only about 9-10 IPs, if the list is too long, router doesn't understand the script.
But at the end I did try using the simple syntax as below, it works but not ... how to say: the script is not pro or beautiful as I hope
foreach address {
1.1.1.1
2.2.2.2
...
"vrf VRFA 6.6.6.6" -> must use " "
"vrf VRFA 7.7.7.7" -> must use " "
...
"vrf VRFB 8.8.8.8.8" -> must use " "
....
"vrf VRFC 9.9.9.9" -> must use " "
} { ping $address repeat 1000 size 1400 df-bit}
04-12-2023 05:24 AM
what router ? post version - i have tested on CSR1000V in the lab (long back part of CCIE Lab testing)
04-12-2023 06:36 PM
Hi @balaji.bandi
My model is 1001X with v16.9.08. And you can see in the photo, if the number members of list is different, the router cannot run all IPs in list
04-12-2023 05:33 AM
fired why script
IP SLA is vrf aware and you can use it to ping all VRF next-hop
or there is something else ?
04-12-2023 06:41 PM
We cannot use IP SLA, because some my MPLS access-lines to our partners are only 1Mbps, so if ping with big size (1400 bytes) by SLA frequently it might affect to the traffic or if SLA run during business hours the result also be affected by other traffic. And we just want to check it some time in a day like 8AM, 12PM, 5PM only, so we check by manually.
04-12-2023 06:48 PM
I think for timing you can run it every day in 8AM and 12PM ...
the issue is the IP SLA packet is default which I think not more than 500 bytes.
so script is good solution here.
thanks
04-12-2023 12:37 PM - edited 04-12-2023 12:50 PM
One option is to put all three scripts into a single file on the router flash then source the file to run.
MPLS(tcl)#source bootflash:pingvrf.tcl
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.2, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.6, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.10, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.2, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/4 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.6, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.10, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 7.7.7.7, timeout is 2 seconds:
..........
Success rate is 0 percent (0/10)
MPLS(tcl)#
MPLS(tcl)#more bootflash:pingvrf.tcl
foreach line {172.27.1.2 172.27.1.6 172.27.1.10} {
ping vrf mpls $line repeat 10
}
foreach line {172.27.3.2 172.27.3.6 172.27.3.10 7.7.7.7} {
ping vrf metro-ethernet $line repeat 10
}
Another option is to wrap them in a proc (no file on router media required). Then call the proc.
MPLS(tcl)#proc pingvrf {} {
+>foreach line {172.27.1.2 172.27.1.6 172.27.1.10} {
+>ping vrf mpls $line repeat 10
+>}
+>
+>foreach line {172.27.3.2 172.27.3.6 172.27.3.10 7.7.7.7} {
+>ping vrf metro-ethernet $line repeat 10
+>}
+>}
MPLS(tcl)#pingvrf
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.2, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.6, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.1.10, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/3 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.2, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.6, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 172.27.3.10, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 7.7.7.7, timeout is 2 seconds:
..........
Success rate is 0 percent (0/10)
MPLS(tcl)#
04-12-2023 08:24 PM
thanks @Dan Frey for the "proc" advice
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide