cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1493
Views
3
Helpful
11
Replies

Need support tclsh script to ping IPs from multiple vrf

Hai Dao Tuan
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

Dan Frey
Cisco Employee
Cisco Employee

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)#

 

View solution in original post

11 Replies 11

balaji.bandi
Hall of Fame
Hall of Fame

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.

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
}

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

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}



what router ? post version - i have tested on CSR1000V in the lab (long back part of CCIE Lab testing)

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

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

HaiDaoTuan_0-1681349720141.png

 

fired why script 
IP SLA is vrf aware and you can use it to ping all VRF next-hop 
or there is something else ? 

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.

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 

Dan Frey
Cisco Employee
Cisco Employee

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)#

 

thanks @Dan Frey for the "proc" advice