<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>loopback &#8211; Fredrik Holmberg</title>
	<atom:link href="/tag/loopback/feed/" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Network Consultant</description>
	<lastBuildDate>Thu, 10 Nov 2016 19:39:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.7.3</generator>

<image>
	<url>/wp-content/uploads/2016/04/cropped-2601-32x32.png</url>
	<title>loopback &#8211; Fredrik Holmberg</title>
	<link>/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>More on Tcl and loopback interfaces</title>
		<link>/2012/07/more-on-tcl-and-loopback-interfaces/</link>
		<comments>/2012/07/more-on-tcl-and-loopback-interfaces/#respond</comments>
		<pubDate>Wed, 18 Jul 2012 03:00:00 +0000</pubDate>
		<dc:creator><![CDATA[Fredrik Holmberg]]></dc:creator>
				<category><![CDATA[automation]]></category>
		<category><![CDATA[loopback]]></category>
		<category><![CDATA[tcl]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Here&#8217;s yet another way to generate loopback interfaces using Tcl. This time we add interfaces from a custom list of subnet IDs. We will use the following Tcl script: set i "0" foreach subnet { 48 50 52 54 } { puts "interface loopback $i" puts " ip address 192.168.$subnet.1 255.255.255.0" incr i 1 } [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s yet another way to <a href="/2012/03/generating-loopback-interfaces-using-tcl/">generate loopback interfaces</a> using Tcl. This time we add interfaces from a custom list of subnet IDs.</p>
<p><span id="more-10"></span></p>
<p>We will use the following Tcl script:</p>
<blockquote>
<pre>set i "0"

foreach subnet {
 48
 50
 52
 54
} {
 puts "interface loopback $i"
 puts " ip address 192.168.$subnet.1 255.255.255.0"
 incr i 1
}</pre>
</blockquote>
<p>Using this script we can do the following:</p>
<blockquote>
<pre>Router#
Router#<b>tclsh</b>
Router(tcl)#<b>set i "0"</b>
0
Router(tcl)#<b>foreach subnet {</b>
<b>+&gt; 48
+&gt; 50
+&gt; 52
+&gt; 54
+&gt;} {
+&gt; puts "interface loopback $i"
+&gt; puts " ip address 192.168.$subnet.1 255.255.255.0"
+&gt; incr i 1
+&gt;}</b>
interface loopback 0
 ip address 192.168.48.1 255.255.255.0
interface loopback 1
 ip address 192.168.50.1 255.255.255.0
interface loopback 2
 ip address 192.168.52.1 255.255.255.0
interface loopback 3
 ip address 192.168.54.1 255.255.255.0

Router(tcl)#exit</pre>
</blockquote>
<p>Notice how the script only sends the configuration to standard output. In order to actually create the interfaces we have to copy and paste the script output into configure terminal:</p>
<blockquote>
<pre>Router#
Router#<b>conf t</b>
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#<b>interface loopback 0</b>
Router(config-if)#<b> ip address 192.168.48.1 255.255.255.0</b>
Router(config-if)#<b>interface loopback 1</b>
Router(config-if)#<b> ip address 192.168.50.1 255.255.255.0</b>
Router(config-if)#<b>interface loopback 2</b>
Router(config-if)#<b> ip address 192.168.52.1 255.255.255.0</b>
Router(config-if)#<b>interface loopback 3</b>
Router(config-if)#<b> ip address 192.168.54.1 255.255.255.0</b>
Router(config-if)#
*Mar  1 00:01:19.331: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
*Mar  1 00:01:19.547: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to up
*Mar  1 00:01:19.659: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback2, changed state to up
*Mar  1 00:01:19.779: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback3, changed state to up
Router(config-if)#<b>end</b>
Router#<b>sh protocols</b>
Global values:
  Internet Protocol routing is enabled
FastEthernet0/0 is administratively down, line protocol is down
FastEthernet0/1 is administratively down, line protocol is down
Loopback0 is up, line protocol is up
  Internet address is 192.168.48.1/24
Loopback1 is up, line protocol is up
  Internet address is 192.168.50.1/24
Loopback2 is up, line protocol is up
  Internet address is 192.168.52.1/24
Loopback3 is up, line protocol is up
  Internet address is 192.168.54.1/24

</pre>
</blockquote>
<p>Very handy when doing labs <img src="https://s.w.org/images/core/emoji/2.2.1/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
			<wfw:commentRss>/2012/07/more-on-tcl-and-loopback-interfaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating loopback interfaces using Tcl</title>
		<link>/2012/03/generating-loopback-interfaces-using-tcl/</link>
		<comments>/2012/03/generating-loopback-interfaces-using-tcl/#respond</comments>
		<pubDate>Wed, 28 Mar 2012 21:35:00 +0000</pubDate>
		<dc:creator><![CDATA[Fredrik Holmberg]]></dc:creator>
				<category><![CDATA[loopback]]></category>
		<category><![CDATA[tcl]]></category>
		<category><![CDATA[automation]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[When doing networking labs you often need to configure a series of loopback interfaces to simulate connected subnets and so on. Configuring them manually on every router or using Notepad with search and replace can be a pain. Here&#8217;s another way to do it! The first three scripts only sends the commands to standard output. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>When doing networking labs you often need to configure a series of loopback interfaces to simulate connected subnets and so on. Configuring them manually on every router or using Notepad with search and replace can be a pain. Here&#8217;s another way to do it!</p>
<p><span id="more-15"></span></p>
<p>The first three scripts only sends the commands to standard output. Just copy and paste them in configuration mode (<i>configure terminal</i>). The last script creates the actual interfaces without user interaction.</p>
<p>Here&#8217;s how to generate commands for an incremental series of interfaces:</p>
<blockquote>
<pre>Router#tclsh
Router(tcl)#for {set io 0} {$io &lt; 6} {incr io} {
+&gt;puts "interface loopback $io"
+&gt;puts " ip address 10.1.$io.1 255.255.255.0"
+&gt;}
interface loopback 0
 ip address 10.1.0.1 255.255.255.0
interface loopback 1
 ip address 10.1.1.1 255.255.255.0
interface loopback 2
 ip address 10.1.2.1 255.255.255.0
interface loopback 3
 ip address 10.1.3.1 255.255.255.0
interface loopback 4
 ip address 10.1.4.1 255.255.255.0
interface loopback 5
 ip address 10.1.5.1 255.255.255.0</pre>
</blockquote>
<p>&nbsp;</p>
<p>You can also do even numbered interfaces and subnets:</p>
<blockquote>
<pre>Router#tclsh
Router(tcl)#for {set io 0} {$io &lt; 11} {incr io 2} {
+&gt;puts "interface loopback $io"
+&gt;puts " ip address 10.1.$io.1 255.255.255.0"
+&gt;}
interface loopback 0
 ip address 10.1.0.1 255.255.255.0
interface loopback 2
 ip address 10.1.2.1 255.255.255.0
interface loopback 4
 ip address 10.1.4.1 255.255.255.0
interface loopback 6
 ip address 10.1.6.1 255.255.255.0
interface loopback 8
 ip address 10.1.8.1 255.255.255.0
interface loopback 10
 ip address 10.1.10.1 255.255.255.0</pre>
</blockquote>
<p>&nbsp;</p>
<p>.. or odd numbered:</p>
<blockquote>
<pre>Router#tclsh
Router(tcl)#for {set io 1} {$io &lt; 11} {incr io 2} {
+&gt;puts "interface loopback $io"
+&gt;puts " ip address 10.1.$io.1 255.255.255.0"
+&gt;}
interface loopback 1
 ip address 10.1.1.1 255.255.255.0
interface loopback 3
 ip address 10.1.3.1 255.255.255.0
interface loopback 5
 ip address 10.1.5.1 255.255.255.0
interface loopback 7
 ip address 10.1.7.1 255.255.255.0
interface loopback 9
 ip address 10.1.9.1 255.255.255.0</pre>
</blockquote>
<p>&nbsp;</p>
<p>And finally, here&#8217;s how you can actually create a series of loopback interfaces:</p>
<blockquote>
<pre>Router#tclsh
Router(tcl)#for {set i 0} {$i &amp;lt; 5} {incr i} {
+&gt;ios_config "interface loopback $i" "ip address 10.1.$i.1 255.255.255.0"
+&gt;}

Router(tcl)#exit
*Mar  1 01:30:10.811: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0,
changed state to up
*Mar  1 01:30:10.855: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1,
changed state to up
*Mar  1 01:30:10.895: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback2,
changed state to up
*Mar  1 01:30:10.939: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback3,
changed state to up
*Mar  1 01:30:10.983: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback4,
changed state to up

Router#show protocols
Global values:
  Internet Protocol routing is enabled
FastEthernet0/0 is administratively down, line protocol is down
FastEthernet0/1 is administratively down, line protocol is down
Loopback0 is up, line protocol is up
  Internet address is 10.1.0.1/24
Loopback1 is up, line protocol is up
  Internet address is 10.1.1.1/24
Loopback2 is up, line protocol is up
  Internet address is 10.1.2.1/24
Loopback3 is up, line protocol is up
  Internet address is 10.1.3.1/24
Loopback4 is up, line protocol is up
  Internet address is 10.1.4.1/24

Router#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  administratively down down
FastEthernet0/1            unassigned      YES unset  administratively down down
Loopback0                  10.1.0.1        YES unset  up                    up
Loopback1                  10.1.1.1        YES unset  up                    up
Loopback2                  10.1.2.1        YES unset  up                    up
Loopback3                  10.1.3.1        YES unset  up                    up
Loopback4                  10.1.4.1        YES unset  up                    up</pre>
</blockquote>
<p>&nbsp;</p>
<p>Pretty cool!</p>
<p>For more information on Tcl scripting check out:<br />
<a href="http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html">http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html</a><br />
<a href="http://www.cisco.com/en/US/docs/ios/12_3t/12_3t2/feature/guide/gt_tcl.html">http://www.cisco.com/en/US/docs/ios/12_3t/12_3t2/feature/guide/gt_tcl.html</a></p>
]]></content:encoded>
			<wfw:commentRss>/2012/03/generating-loopback-interfaces-using-tcl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
