cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2027
Views
0
Helpful
1
Replies

TCL Script to ping multiple VRFs each with Multiple IP addresses. IOS-XE and Nexus

S.Srivas1
Level 1
Level 1

Dear Community,

 

Could I request help to write a TCL Script to ping multiple VRFs each with Multiple IP addresses of their own.

Scripts required for IOS-XE and Nexus. 

 

!!!VRF List

aaa_VRF1

bbb_VRF1

ccc_VRF1

!!! IP address list for each VRF set

!!! aaa_VRF1

10.10.11.1

10.10.25.1

10.9.3.1

!!!bbb_VRF1

172.16.33.1

10.20.20.1

192.168.32.1

!!!ccc_VRF1

10.50.1.1

10.60.2.2

10.100.18.3

 

With appreciation.

 

1 Reply 1

lewislampkinCC
Level 1
Level 1

I had this issue today, and my Google search brought me to this thread. Figured I'd post back to this thread what worked for my specific case (IOS-XE).

I used this reference to get sorted: https://wiki.tcl-lang.org/page/foreach

Syntax A:

foreach a [list 10.10.11.1 10.10.25.1 10.9.3.1] b [list 172.16.33.1 10.20.10.1 192.168.32.1] c [list 10.50.1.1 10.60.2.2 10.100.18.3] {
ping vrf aaa_VRF1 $a
ping vrf bbb_VRF1 $b
ping vrf ccc_VRF1 $c
}

Syntax B:

foreach {network address} [list aaa_VRF1 10.10.11.1 aaa_VRF1 10.10.25.1 aaa_VRF1 10.9.3.1 bbb_VRF1 172.16.33.1] {ping vrf $network $address}

foreach {network address} [list bbb_VRF1 10.20.10.1 bbb_VRF1 192.168.32.1 ccc_VRF1 10.50.1.1 ccc_VRF1 10.60.2.2 ccc_VRF1 10.100.18.3] {ping vrf $network $address}

Note: The Syntax A runs kinda interleaved. The Syntax B is more explicit, but ... I was running into buffer issues when I tried to use a string too long, and that's why I broke the second example into multiple lines, in case others catch that same issue. I never investigated further into the buffer issue, I was just glad to fix the immediate issue I had, and figured I'd share.