TCL Script for Multiple Loopbacks in Seconds

Rashmi Bhardwaj | Blog,Config & Troubleshoot

Scripting can be very useful tool when networkers need to work on same activity repetitively. Some of the boring and time consuming activities are –

  • Putting multiple interfaces in VLANs
  • Configuring multiple entries of BGP neighborship
  • Access list entries for same source or destination

And many more.

TCL Script for Multiple Loopbacks

So here comes in the TCL script which can complete some of repetitive and tedious jobs in seconds. Lets take an example where I want to configure 5 Loopbacks. The script will look something like this –

foreach {number address} {
5} { puts [ ios_config “interface Loopback$number” “ip address $address” ] }
Now lets test the configuration in lab –
R1(tcl)#foreach {number address} {
+>(tcl)#           1
+>(tcl)#           2
+>(tcl)#           3
+>(tcl)#           4
+>(tcl)#           5
+>(tcl)#+>(tcl)# } {   puts [ ios_config “interface Loopback$number” “ip address $ address” ] }

The output of TCL script configuration is below –

R1#show ip int brief
Interface                 IP-Address     OK?   Method    Status                            Protocol
FastEthernet0/0       unassigned     YES        unset          administratively down  down
FastEthernet0/1        unassigned     YES        unset          administratively down  down
Loopback1                     YES        unset          up                                      up
Loopback2                     YES        unset          up                                       up
Loopback3                     YES        unset          up                                       up
Loopback4                     YES        unset          up                                       up
Loopback5                      YES        unset          up                                       up

Nice to see how TCL script can make tiring activities fun and time saver for techies.


Continue Reading:

TCL Ping Script

BGP Neighborship Drops when NAT is Enabled


Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart