Google ADs
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} {
1 1.1.1.1
2 2.2.2.2
3 3.3.3.3
4 4.4.4.4
5 5.5.5.5} { puts [ ios_config “interface Loopback$number” “ip address $address 255.255.255.255” ] }
1 1.1.1.1
2 2.2.2.2
3 3.3.3.3
4 4.4.4.4
5 5.5.5.5} { puts [ ios_config “interface Loopback$number” “ip address $address 255.255.255.255” ] }
R1#tclsh
R1(tcl)#foreach {number address} {
+>(tcl)# 1 1.1.1.1
+>(tcl)# 2 2.2.2.2
+>(tcl)# 3 3.3.3.3
+>(tcl)# 4 4.4.4.4
+>(tcl)# 5 5.5.5.5
+>(tcl)#+>(tcl)# } { puts [ ios_config “interface Loopback$number” “ip address $ address 255.255.255.255” ] }
R1(tcl)#foreach {number address} {
+>(tcl)# 1 1.1.1.1
+>(tcl)# 2 2.2.2.2
+>(tcl)# 3 3.3.3.3
+>(tcl)# 4 4.4.4.4
+>(tcl)# 5 5.5.5.5
+>(tcl)#+>(tcl)# } { puts [ ios_config “interface Loopback$number” “ip address $ address 255.255.255.255” ] }
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 1.1.1.1 YES unset up up
Loopback2 2.2.2.2 YES unset up up
Loopback3 3.3.3.3 YES unset up up
Loopback4 4.4.4.4 YES unset up up
Loopback5 5.5.5.5 YES unset up up
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset administratively down down
FastEthernet0/1 unassigned YES unset administratively down down
Loopback1 1.1.1.1 YES unset up up
Loopback2 2.2.2.2 YES unset up up
Loopback3 3.3.3.3 YES unset up up
Loopback4 4.4.4.4 YES unset up up
Loopback5 5.5.5.5 YES unset up up
Nice to see how TCL script can make tiring activities fun and time saver for techies.
Google ADs
Continue Reading:
BGP Neighborship Drops when NAT is Enabled
ABOUT THE AUTHOR

Founder of AAR TECHNOSOLUTIONS, Rashmi is an evangelist for IT and technology. With more than 12 years in the IT ecosystem, she has been supporting multi domain functions across IT & consultancy services, in addition to Technical content making.
You can learn more about her on her linkedin profile – Rashmi Bhardwaj