<?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>Network Stuff</title>
	<atom:link href="http://blog.synacknetworks.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.synacknetworks.com</link>
	<description></description>
	<lastBuildDate>Wed, 10 Mar 2010 04:13:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Configuring an Inter-AS Option B VPN between a Cisco and Juniper</title>
		<link>http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/</link>
		<comments>http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 04:13:32 +0000</pubDate>
		<dc:creator>jrowley</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Inter-AS VPNs]]></category>
		<category><![CDATA[Juniper]]></category>
		<category><![CDATA[Inter-AS VPN]]></category>
		<category><![CDATA[Interoperability]]></category>

		<guid isPermaLink="false">http://blog.synacknetworks.com/?p=147</guid>
		<description><![CDATA[One of the things I needed to put together recently is an Inter-AS VPN between a Cisco and Juniper. There isn&#8217;t much in the way of documentation on interoperability. Everything I&#8217;ve found is Cisco to Cisco or Juniper to Juniper. Hopefully this will help someone. All this came about due to us being acquired by [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things I needed to put together recently is an Inter-AS VPN between a Cisco and Juniper. There isn&#8217;t much in the way of documentation on interoperability. Everything I&#8217;ve found is Cisco to Cisco or Juniper to Juniper. Hopefully this will help someone.</p>
<p><span id="more-147"></span><br />
<script type="text/javascript"><!--
google_ad_client = "pub-5313541117764769";
/* 234x60, created 1/7/10 */
google_ad_slot = "3405453421";
google_ad_width = 234;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>All this came about due to us being acquired by another company and needing a way to extend our L3VPNs to their network quickly.</p>
<p>Our simple topology follows. It&#8217;s a 7200 that has a customer VRF, a 7600, and a Juniper that also has the other side of the customer VRF (small lab).</p>
<p><a href="http://blog.synacknetworks.com/wp-content/uploads/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/inter-as.jpg" rel="lightbox[147]"><img class="alignnone size-full wp-image-148" title="inter-as" src="http://blog.synacknetworks.com/wp-content/uploads/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/inter-as.jpg" alt="" width="853" height="226" /></a></p>
<p>One of the things we wanted to do is limit the vpnv4 prefixes that are shared between ASNs. We didn&#8217;t want anyone to have to configure anything on our 7609. To do this, we came up with additional route targets to add to the vpn routes.</p>
<p>Our 7200 config looks like this</p>
<pre class="brush: plain;">
ip vrf NNI-TEST1
 rd 65100:1001
 route-target export 65100:1001
 route-target export 65100:65200
 route-target import 65100:1001

interface Loopback101
 ip vrf forwarding NNI-TEST1
 ip address 10.10.10.1 255.255.255.255

router bgp 65100
 address-family ipv4 vrf NNI-TEST1
  no synchronization
  redistribute connected
  redistribute static
 exit-address-family
</pre>
<p>Pretty simple stuff. You can see where we add the extra route-target in the vrf (65100:65200).</p>
<p>Our 7609</p>
<pre class="brush: plain;">
router bgp 65100
 neighbor NNI:US-TO-THEM peer-group
 neighbor NNI:US-TO-THEM remote-as 65200
 neighbor x.x.156.127 peer-group NNI:US-TO-THEM
 address-family ipv4
 no neighbor NNI:US-TO-THEM activate
 no neighbor x.x.156.127 activate
 address-family vpnv4
 neighbor NNI:US-TO-THEM activate
 neighbor NNI:US-TO-THEM next-hop-self
 neighbor NNI:US-TO-THEM send-community both
 neighbor NNI:US-TO-THEM route-map NNI:IMPORT in
 neighbor NNI:US-TO-THEM route-map NNI:EXPORT out
 neighbor x.x.156.127 peer-group NNI:US-TO-THEM

ip extcommunity-list 101 permit _RT:65100:65200_
ip extcommunity-list 102 permit _RT:65200:65100_

route-map NNI:IMPORT permit 10
 match extcommunity 102
!
route-map NNI:IMPORT deny 90

route-map NNI:EXPORT permit 10
 match extcommunity 101
!
route-map NNI:EXPORT deny 90
</pre>
<p>Finally, the Juniper</p>
<pre class="brush: plain;">
set interfaces lo0 unit 250 family inet address 10.10.10.2/32

set protocols mpls interface lo0.250
set protocols mpls interface fe-0/3/0.2500
set protocols mpls interface lo0.0

set routing-options autonomous-system 65200
set protocols bgp keep all
set protocols bgp group NNI:PEER type external
set protocols bgp group NNI:PEER family inet-vpn unicast
set protocols bgp group NNI:PEER neighbor x.x.156.126 import NNI:IMPORT
set protocols bgp group NNI:PEER neighbor x.x.156.126 export NNI:EXPORT
set protocols bgp group NNI:PEER neighbor x.x.156.126 peer-as 65100

set policy-options policy-statement CUST1-export term 1 then community add NNI:EXPORT
set policy-options policy-statement CUST1-export term 1 then community add CUST1:RT
set policy-options policy-statement CUST1-export term 1 then accept
set policy-options policy-statement CUST1-export term 2 then reject
set policy-options policy-statement CUST1-import term 1 from community CUST1:RT
set policy-options policy-statement CUST1-import term 1 then accept
set policy-options policy-statement CUST1-import term 2 then reject
set policy-options policy-statement NNI:IMPORT term 1 from community NNI:IMPORT
set policy-options policy-statement NNI:IMPORT term 1 then accept
set policy-options policy-statement NNI:IMPORT term 2 then reject
set policy-options policy-statement NNI:EXPORT term 1 from community NNI:EXPORT
set policy-options policy-statement NNI:EXPORT term 1 then accept
set policy-options policy-statement NNI:EXPORT term 2 then reject

set policy-options community CUST1:RT members target:65100:1001
set policy-options community NNI:IMPORT members target:65100:65200
set policy-options community NNI:EXPORT members target:65200:65100

set routing-instances CUST1 instance-type vrf
set routing-instances CUST1 interface lo0.250
set routing-instances CUST1 route-distinguisher 65100:1001
set routing-instances CUST1 vrf-import CUST1-import
set routing-instances CUST1 vrf-export CUST1-export
</pre>
<p>Now, let&#8217;s check this out on our 7200.</p>
<pre class="brush: plain;">
NW-7206-2#sh ip route vrf NNI-TEST1 10.10.10.2

Routing Table: NNI-TEST1
Routing entry for 10.10.10.2/32
  Known via &quot;bgp 65100&quot;, distance 200, metric 0
  Tag 65200, type internal
  Last update from x.x.156.127 00:34:23 ago
  Routing Descriptor Blocks:
  * x.x.156.127 (default), from x.x.156.2, 00:34:23 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 65200
      MPLS Required
</pre>
<p>Woot!</p>
<pre class="brush: plain;">
NW-7206-2#ping vrf NNI-TEST1 ip 10.10.10.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
</pre>
<p>From our Juniper:</p>
<pre class="brush: plain;">
junos@NNI-TESTING# run ping routing-instance CUST1 10.10.10.1
PING 10.10.10.1 (10.10.10.1): 56 data bytes
64 bytes from 10.10.10.1: icmp_seq=0 ttl=255 time=0.943 ms
64 bytes from 10.10.10.1: icmp_seq=1 ttl=255 time=0.988 ms
64 bytes from 10.10.10.1: icmp_seq=2 ttl=255 time=0.911 ms
64 bytes from 10.10.10.1: icmp_seq=3 ttl=255 time=0.990 ms
^C
--- 10.10.10.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.911/0.958/0.990/0.033 ms
</pre>
<pre class="brush: plain;">
junos@NNI-TESTING# run show route table CUST1

CUST1.inet.0: 2 destinations, 2 routes (2 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.10.10.1/32      *[BGP/170] 00:34:58, localpref 100
                      AS path: 65100 ?
                    &gt; to x.x.156.126 via fe-0/3/0.2500, Push 57
10.10.10.2/32      *[Direct/0] 11:28:14
                    &gt; via lo0.250
</pre>
<p>And, on our 7609</p>
<pre class="brush: plain;">
NW-7609-1#sh ip bgp vpnv4 rd 65100:1001
BGP table version is 134, local router ID is x.x.156.2
Status codes: s suppressed, d damped, h history, * valid, &gt; best, i - internal,
              S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 65100:1001
*&gt;i10.10.10.1/32    x.x.156.7              0    100      0 ?
*&gt; 10.10.10.2/32    x.x.156.127                          0 65200 i
</pre>
<p>Here&#8217;s the l3vpn bgp table on the Juniper</p>
<pre class="brush: plain;">
junos@NNI-TESTING# run show route table bgp.l3vpn.0 extensive

bgp.l3vpn.0: 2 destinations, 2 routes (2 active, 0 holddown, 0 hidden)
65100:1001:10.10.10.1/32 (1 entry, 0 announced)
        *BGP    Preference: 170/-101
                Route Distinguisher: 65100:1001
                Next hop type: Router, Next hop index: 541
                Next-hop reference count: 3
                Source: x.x.156.126
                Next hop: x.x.156.126 via fe-0/3/0.2500, selected
                Label operation: Push 57
                State: &lt;Active Ext&gt;
                Local AS:  65200 Peer AS: 65100
                Age: 44:42
                Task: BGP_65100.x.x.156.126+179
                AS path: 65100 ?
                Communities: target:65100:65200 target:65100:1001
                Import Accepted
                VPN Label: 57
                Localpref: 100
                Router ID: x.x.156.2
                Secondary Tables: CUST1.inet.0

65100:1001:10.10.10.2/32 (1 entry, 1 announced)
TSI:
Page 0 idx 0 Type 1 val 14845048
        *Direct Preference: 0
                Next hop type: Interface
                Next-hop reference count: 2
                Next hop: via lo0.250, selected
                State: &lt;Secondary Active Int&gt;
                Age: 11:20:01
                Task: IF
                Announcement bits (1): 0-BGP RT Background
                AS path: I
                Communities: target:65200:65100 target:65100:1001
                Primary Routing Table CUST1.inet.0
</pre>
<p>This was pretty simple. So much so that I was over thinking it for quite a bit. Hopefully this helps someone else in the future.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/&amp;title=Configuring+an+Inter-AS+Option+B+VPN+between+a+Cisco+and+Juniper" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/&amp;title=Configuring+an+Inter-AS+Option+B+VPN+between+a+Cisco+and+Juniper" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/&amp;title=Configuring+an+Inter-AS+Option+B+VPN+between+a+Cisco+and+Juniper&amp;desc=One%20of%20the%20things%20I%20needed%20to%20put%20together%20recently%20is%20an%20Inter-AS%20VPN%20between%20a%20Cisco%20and%20Juniper.%20There%20isn%27t%20much%20in%20the%20way%20of%20documentation%20on%20interoperability.%20Everything%20I%27ve%20found%20is%20Cisco%20to%20Cisco%20or%20Juniper%20to%20Juniper.%20Hopefully%20this%20will%20help%20someone.%0D%0A%0D%0A%0D%0A%5Bad%23Google%20Adsense%5D%0D%0A%0D%0AAll%20this%20" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/&amp;bm_description=Configuring+an+Inter-AS+Option+B+VPN+between+a+Cisco+and+Juniper&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/&amp;title=Configuring+an+Inter-AS+Option+B+VPN+between+a+Cisco+and+Juniper" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/&amp;title=Configuring+an+Inter-AS+Option+B+VPN+between+a+Cisco+and+Juniper" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/&amp;title=Configuring+an+Inter-AS+Option+B+VPN+between+a+Cisco+and+Juniper" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Configuring+an+Inter-AS+Option+B+VPN+between+a+Cisco+and+Juniper+-+http://b2l.me/jkhhy&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.synacknetworks.com/2010/03/09/configuring-an-inter-as-option-b-vpn-between-a-cisco-and-juniper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing IP Access Lists with Cisco::Reconfig without the dreaded died at /cisco/reconfig.pm line 212 message</title>
		<link>http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/</link>
		<comments>http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 04:35:28 +0000</pubDate>
		<dc:creator>jrowley</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[reconfig]]></category>

		<guid isPermaLink="false">http://blog.synacknetworks.com/?p=133</guid>
		<description><![CDATA[Since making a few posts about using Cisco::Reconfig, two of the top search results that brings people here is &#8220;died at cisco/reconfig.pm line 212&#8243; or &#8220;died at cisco/reconfig.pm line 103&#8243;. I&#8217;ll show you what causes these as I demonstrate how to compare standard and extended ip access-lists with Cisco::Reconfig. For the second message about line [...]]]></description>
			<content:encoded><![CDATA[<p>Since making a few posts about using Cisco::Reconfig, two of the top search results that brings people here is &#8220;died at cisco/reconfig.pm line 212&#8243; or &#8220;died at cisco/reconfig.pm line 103&#8243;. I&#8217;ll show you what causes these as I demonstrate how to compare standard and extended ip access-lists with Cisco::Reconfig.</p>
<p><span id="more-133"></span><br />
</p>
<p>For the second message about line 102, that&#8217;s easy enough to fix. Search for line 103 in the Reconfig.pm module and comment out lines 103 through 106.</p>
<p>Essentially, change this:</p>
<pre class="brush: perl;">
                                # this really shouldn't happen.  But it does.
                               die unless $prev eq &quot;!\n&quot; || $prev =~ /^!.*&lt;removed&gt;$/;
                               die unless $indent == 0;
                               $ciscobug = 1;
                               $indent = $in;
</pre>
<p>To this:</p>
<pre class="brush: perl;">
                               # this really shouldn't happen.  But it does.
                               #die unless $prev eq &quot;!\n&quot; || $prev =~ /^!.*&lt;removed&gt;$/;
                               #die unless $indent == 0;
                               #$ciscobug = 1;
                               #$indent = $in;
</pre>
<p>I am not too familiar with the Cisco::Reconfig code, but I have been running scripts with this modification against 600+ routers for over a year without issues. If uncommented, it always crashes against our GSRs. It must be left over code from some old IOS configuration quirk (Cisco <em><strong>never </strong></em>changes stuff around from version to version!). Cisco&#8217;s anti-automation engineers will probably see this and the next IOS release will break all my scripts now. <img src='http://blog.synacknetworks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The second error about line 212 always seems to happen when you&#8217;re searching for route-maps or ip access-lists (not regular access-lists). Basically, anything where you have a sub query such as:</p>
<pre class="brush: perl;">
my @EACL = $::MYCONFIG-&gt;get('ip access-list extended SOMEACL', 'permit')-&gt;alltext;
</pre>
<p>If the SOMEACL ip access-list doesn&#8217;t exist, Cisco::Reconfig bombs out with the error at line 212 because it doesn&#8217;t have any error handling for this situation. Line 212 has an explicit &#8220;die&#8221; if the two sequences aren&#8217;t true. Doesn&#8217;t even print a message &#8211; just crashes.</p>
<p>So, if you run into this, you can work around it by doing your own testing first. I&#8217;ll show you how I test for whether an ip access-list exists before deciding to try to get the following lines.</p>
<pre class="brush: perl;">
                                my $eaclline = $::MYCONFIG-&gt;get($aclcmd);
                                chomp ($eaclline);
                                if ($eaclline !~ /$aclcmd/)
                                {
                                        $::REPORTID = 14;
                                        $::MESSAGE = &quot;CRITICAL: Missing '$aclcmd'!&quot;;
                                        InsertLogMessage();
                                        ClearERRs();
                                        next;
                                }
</pre>
<p>In the above code, $aclcmd is pulled from my database and basically would look like &#8216;ip access-list standard SSM&#8217;. All I care about is searching for that one line before doing a more complex search. If the output doesn&#8217;t match the $aclcmd variable, we report an error, insert it into the report table, and move on.</p>
<p>If it does exist, we can compare the contents of the ip access-list.</p>
<pre class="brush: perl;">
                                if ($deny == 1)
                                {
                                        my @EACLDt = $::MYCONFIG-&gt;get($aclcmd, 'deny')-&gt;alltext;
                                        foreach (@EACLDt)
                                        {
                                                my $line1 = $_;
                                                push @aclrestemp, split (/\n/, $line1);
                                        }
                                }
                                if ($permit == 1)
                                {
                                        my @EACLPt = $::MYCONFIG-&gt;get($aclcmd, 'permit')-&gt;alltext;
                                        foreach (@EACLPt)
                                        {
                                                my $line2 = $_;
                                                push @aclrestemp, split (/\n/, $line2);
                                        }
                                }
</pre>
<p>If you&#8217;re curious about the complete code for this function, here it is.</p>
<pre class="brush: perl;">
                my $aclsql = &quot;SELECT extended,acl,name,contents FROM AccessLists WHERE chassisid = '$::CHASSIS' AND rtypeid = '$::TYPE'&quot;;
                my $aclqry = $dbh-&gt;prepare($aclsql);
                $aclqry-&gt;execute();

                while (@aclrow = $aclqry-&gt;fetchrow_array())
                {
                        my $isExtended  = $aclrow[0];
                        my $aclcmd      = $aclrow[1];
                        my $aclname     = $aclrow[2];
                        my $aclcontents = $aclrow[3];

                        my $deny = 0;
                        my $permit = 0;

                        my @aclarr;
                        my @acltmp = split('\n', $aclcontents);
                        for (@acltmp)
                        {
                                my $aclline = $_;
                                chomp ($aclline);
                                $aclline =~ s/^\s+|\s+$//g;
                                if ($aclline =~ /^deny/)
                                {
                                        $deny = 1;
                                }
                                if ($aclline =~ /^permit/)
                                {
                                        $permit = 1;
                                }
                                push @aclarr, $aclline;
                        }

                        my @aclrestemp;

                        if ($isExtended == 0)          ### regular accesss-list
                        {
                                @aclrestemp = $::MYCONFIG-&gt;get($aclcmd)-&gt;all;
                        }
                        if ($isExtended == 1)          ### ip access-list
                        {
                                my $eaclline = $::MYCONFIG-&gt;get($aclcmd);
                                chomp ($eaclline);
                                if ($eaclline !~ /$aclcmd/)
                                {
                                        $::REPORTID = 14;
                                        $::MESSAGE = &quot;CRITICAL: Missing '$aclcmd'!&quot;;
                                        InsertLogMessage();
                                        ClearERRs();
                                        next;
                                }

                                if ($deny == 1)
                                {
                                        my @EACLDt = $::MYCONFIG-&gt;get($aclcmd, 'deny')-&gt;alltext;
                                        foreach (@EACLDt)
                                        {
                                                my $line1 = $_;
                                                push @aclrestemp, split (/\n/, $line1);
                                        }
                                }
                                if ($permit == 1)
                                {
                                        my @EACLPt = $::MYCONFIG-&gt;get($aclcmd, 'permit')-&gt;alltext;
                                        foreach (@EACLPt)
                                        {
                                                my $line2 = $_;
                                                push @aclrestemp, split (/\n/, $line2);
                                        }
                                }
                        }

                        my @aclres;
                        for (@aclrestemp)
                        {
                                my $restemp = $_;
                                $restemp =~ s/^\s+|\s+$//g;
                                chomp ($restemp);
                                push @aclres, $restemp;
                        }

                        # some quantum sexiness going on here
                        my @fACL = eigenstates(any(@aclres) ne all(@aclarr));
                        my @rACL = eigenstates(any(@aclarr) ne all(@aclres));

                        my $fcount = @fACL;
                        my $rcount = @rACL;

                        # If the first element is empty, don't try to insert stuff into the logs
                        if ($fACL[0] ne &quot;&quot;)
                        {
                                for (@fACL)
                                {
                                        $::REPORTID = 14;
                                        $::MESSAGE = &quot;$aclname extra: $_&quot;;
                                        InsertLogMessage();
                                }
                        }

                        if ($rACL[0] ne &quot;&quot;)
                        {
                                for (@rACL)
                                {
                                        $::REPORTID = 14;
                                        $::MESSAGE = &quot;$aclname missing: $_&quot;;
                                        InsertLogMessage();
                                }
                        }

                        ClearERRs();
                }
        }
</pre>
<p>Our AccessList table looks like this (click to enlarge):</p>
<p><a href="http://blog.synacknetworks.com/wp-content/uploads/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/ACLdb.jpg" rel="lightbox[133]"><img class="alignnone size-medium wp-image-135" title="ACLdb" src="http://blog.synacknetworks.com/wp-content/uploads/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/ACLdb-300x126.jpg" alt="" width="300" height="126" /></a></p>
<p>Because we have some &#8220;Core&#8221; routers that are GSRs and some that are 7600s, the table has a chassisid and rtypeid. That allows us to have different ACLs for platforms with different functions.</p>
<p>The acl column is the actual command that is searched for in the $aclcmd variable. The name column is used when inserting an error message into our report table. Finally, the contents column is a text type and contains the official access-list used to audit against.</p>
<p>I hope this post helps those of you frustrated by the cryptic errors with Cisco::Reconfig. It is very useful, but it would be nice if it actually told you why it crashed. Even better would be if it had more enhanced error handling. Unfortunately, since it was last updated 3 years ago (Feb 2007), it seems to be abandoned. A shame for such a valuable module.</p>
<p>If anyone stumbles on this post and has a different error than the two identified, please leave a comment and I&#8217;ll see what I can do to help you out.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/&amp;title=Parsing+IP+Access+Lists+with+Cisco%3A%3AReconfig+without+the+dreaded+died+at+%2Fcisco%2Freconfig.pm+line+212+message" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/&amp;title=Parsing+IP+Access+Lists+with+Cisco%3A%3AReconfig+without+the+dreaded+died+at+%2Fcisco%2Freconfig.pm+line+212+message" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/&amp;title=Parsing+IP+Access+Lists+with+Cisco%3A%3AReconfig+without+the+dreaded+died+at+%2Fcisco%2Freconfig.pm+line+212+message&amp;desc=Since%20making%20a%20few%20posts%20about%20using%20Cisco%3A%3AReconfig%2C%20two%20of%20the%20top%20search%20results%20that%20brings%20people%20here%20is%20%22died%20at%20cisco%2Freconfig.pm%20line%20212%22%20or%20%22died%20at%20cisco%2Freconfig.pm%20line%20103%22.%20I%27ll%20show%20you%20what%20causes%20these%20as%20I%20demonstrate%20how%20to%20compare%20standard%20and%20extended%20ip%20access-lists%20with%20Cisc" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/&amp;bm_description=Parsing+IP+Access+Lists+with+Cisco%3A%3AReconfig+without+the+dreaded+died+at+%2Fcisco%2Freconfig.pm+line+212+message&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/&amp;title=Parsing+IP+Access+Lists+with+Cisco%3A%3AReconfig+without+the+dreaded+died+at+%2Fcisco%2Freconfig.pm+line+212+message" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/&amp;title=Parsing+IP+Access+Lists+with+Cisco%3A%3AReconfig+without+the+dreaded+died+at+%2Fcisco%2Freconfig.pm+line+212+message" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/&amp;title=Parsing+IP+Access+Lists+with+Cisco%3A%3AReconfig+without+the+dreaded+died+at+%2Fcisco%2Freconfig.pm+line+212+message" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Parsing+IP+Access+Lists+with+Cisco%3A%3AReconfig+without+the+dreaded+died+at+%2Fcisco%2F%5B..%5D+-+http://b2l.me/gagdw&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.synacknetworks.com/2010/02/13/parsing-ip-access-lists-with-ciscoreconfig-without-the-dreaded-died-at-ciscoreconfig-pm-line-212-message/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rtrcommander: Using scripts to push out configurations or retrieve output</title>
		<link>http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/</link>
		<comments>http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 13:12:02 +0000</pubDate>
		<dc:creator>jrowley</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[mass config updates]]></category>
		<category><![CDATA[rtrcommander]]></category>

		<guid isPermaLink="false">http://blog.synacknetworks.com/?p=120</guid>
		<description><![CDATA[rtrcommander is a script I wrote to push out configurations to multiple routers, as well as to retrieve output from the cli. It&#8217;s a part of Mr Audit (the release of Mr Audit is delayed while I prepare for the CCIE lab). rtrcommander can be downloaded here: http://www.synacknetworks.com/scripts/rtrcommander.txt rtrcommander can be used as follows: pts/4 [...]]]></description>
			<content:encoded><![CDATA[<p>rtrcommander is a script I wrote to push out configurations to multiple routers, as well as to retrieve output from the cli. It&#8217;s a part of <a href="http://www.mraudit.org" target="_blank">Mr Audit</a> (the release of Mr Audit is delayed while I prepare for the CCIE lab).</p>
<p>rtrcommander can be downloaded here: <a href="http://www.synacknetworks.com/scripts/rtrcommander.txt" target="_blank">http://www.synacknetworks.com/scripts/rtrcommander.txt</a></p>
<p><span id="more-120"></span><br />
<br />
rtrcommander can be used as follows:</p>
<pre class="brush: plain;">
pts/4 jrowley@toolbox:/home/audit/scripts/rtrcmd $&gt; rtrcommander

New and Improved Router Commander 2.0

        Usage:
        ./rtrcommander [-h] -u &lt;username&gt; [-p &lt;password&gt;] -r &lt;rtrlist&gt; -c &lt;cmdlist&gt; [-l &lt;loglocation&gt;]

        -h                : prints this message
        -u                : username
        -p                : password - if not specified, will be prompted
        -r                : file containing list of routers
        -c                : file containing commands to run
        -l                : file where we should log to; defaults to &quot;ipaddress.log&quot;

        Examples:
        rtrcmd -u username -p password -r routerlist -c commandlist
        rtrcmd -u username -r routerlist -c commandlist -l mycombinedlogfile.txt
</pre>
<p>For security, if a password is not specified on the command line, you will be prompted for one.</p>
<p>This shows how we retrieved memory being held by the Logger process while checking to see our wide spread our memory leak was (see yesterday&#8217;s post).</p>
<pre class="brush: plain;">
pts/4 jrowley@toolbox:/home/audit/scripts/rtrcmd $&gt; ./rtrcommander -u jrowley -r routers -c commands -l mylog.txt
password: ********

HOSTNAME: router1
Sending: show conf | i ^hostname
Sending: show proc mem sort | i Holding|Logger|Malloc

HOSTNAME: router2
Sending: show conf | i ^hostname
Sending: show proc mem sort | i Holding|Logger|Malloc

HOSTNAME: router3
Sending: show conf | i ^hostname
Sending: show proc mem sort | i Holding|Logger|Malloc
</pre>
<p>We create two files. One is a list of IP addresses or hostnames of routers we want to run these commands on. The second is a list of commands to run.</p>
<p>routers file:</p>
<pre class="brush: plain;">
router1
router2
router3
</pre>
<p>command file:</p>
<pre class="brush: plain;">
show conf | i ^hostname
show proc mem sort | i Holding|Logger|Malloc
</pre>
<p>If you want to push out some configuration, your command file may look similar to:</p>
<pre class="brush: plain;">
config t
ip access-list standard 1
permit 10.20.114.0 0.0.1.255
permit 10.20.164.0 0.0.3.255
end
quit
</pre>
<p>The combined log file is optional. If you leave it off, it will log everything into one file per router. If you have a small set of routers, you can use either way. Since I typically run stuff against our 600+ routers, I typically combine everything into one log file, otherwise my home directory gets pretty cluttered.</p>
<p>Our combined log file looks like:</p>
<pre class="brush: plain;">
pts/4 jrowley@toolbox:/home/audit/scripts/rtrcmd $&gt; more mylog.txt
hostname router1
 PID TTY  Allocated      Freed    Holding    Getbufs    Retbufs Process
  44   0   15619876     170496    8664528      50760          0 Logger
   0   0          0          0    7257808          0          0 *MallocLite*
hostname router2
 PID TTY  Allocated      Freed    Holding    Getbufs    Retbufs Process
  44   0  393743528        188  180671388      71064          0 Logger
   0   0          0          0  139126148          0          0 *MallocLite*
hostname router3
 PID TTY  Allocated      Freed    Holding    Getbufs    Retbufs Process
   0   0          0          0     393528          0          0 *MallocLite*
  44   0   10641592   10607792      30148      10152          0 Logger
pts/4 audit@toolbox:/home/audit/scripts/rtrcmd $&gt;
</pre>
<p>Non combined logging provides just a bit more details since we use raw Net::Telnet logging</p>
<pre class="brush: plain;">
pts/4 jrowley@toolbox:/home/jrowley $&gt; more rtrcmds/2009-11-06/router.log

router line 2

User Access Verification

Username: jrowley
Password:

router#term len 0
router#config t
Enter configuration commands, one per line.  End with CNTL/Z.
router(config)#ip access-list extended OSPF_ROUTES_VOICE
router(config-ext-nacl)#permit ip 10.20.114.0 0.0.1.255 any
router(config-ext-nacl)#permit ip 10.20.164.0 0.0.3.255 any
router(config-ext-nacl)#end
router#quit
</pre>
<p>This is useful for pushing out the same configuration changes to many routers, or to run commands to capture output, such has how much memory the Logging process is holding.</p>
<p>Hopefully this will be of use for others.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/&amp;title=rtrcommander%3A+Using+scripts+to+push+out+configurations+or+retrieve+output" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/&amp;title=rtrcommander%3A+Using+scripts+to+push+out+configurations+or+retrieve+output" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/&amp;title=rtrcommander%3A+Using+scripts+to+push+out+configurations+or+retrieve+output&amp;desc=rtrcommander%20is%20a%20script%20I%20wrote%20to%20push%20out%20configurations%20to%20multiple%20routers%2C%20as%20well%20as%20to%20retrieve%20output%20from%20the%20cli.%20It%27s%20a%20part%20of%20Mr%20Audit%20%28the%20release%20of%20Mr%20Audit%20is%20delayed%20while%20I%20prepare%20for%20the%20CCIE%20lab%29.%0D%0A%0D%0Artrcommander%20can%20be%20downloaded%20here%3A%20http%3A%2F%2Fwww.synacknetworks.com%2Fscripts%2Frt" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/&amp;bm_description=rtrcommander%3A+Using+scripts+to+push+out+configurations+or+retrieve+output&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/&amp;title=rtrcommander%3A+Using+scripts+to+push+out+configurations+or+retrieve+output" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/&amp;title=rtrcommander%3A+Using+scripts+to+push+out+configurations+or+retrieve+output" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/&amp;title=rtrcommander%3A+Using+scripts+to+push+out+configurations+or+retrieve+output" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=rtrcommander%3A+Using+scripts+to+push+out+configurations+or+retrieve+output+-+http://b2l.me/dspd7&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.synacknetworks.com/2010/01/15/rtrcommander-using-scripts-to-push-out-configurations-or-retrieve-output/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Using NfSen and NfDump to identify DoS/DDoS attacks</title>
		<link>http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/</link>
		<comments>http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 04:03:28 +0000</pubDate>
		<dc:creator>jrowley</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[alerting]]></category>
		<category><![CDATA[DDoS]]></category>
		<category><![CDATA[netflow]]></category>
		<category><![CDATA[nfdump]]></category>
		<category><![CDATA[nfsen]]></category>
		<category><![CDATA[RTBH]]></category>

		<guid isPermaLink="false">http://blog.synacknetworks.com/?p=90</guid>
		<description><![CDATA[If you work for any sort of provider (hosting, isp, etc), chances are that you&#8217;ve experienced a DoS/DDoS against a customer or internal system. If so, you know how frustrating it can be to track down the source of the attack unless you have an expensive platform such as from Arbor Networks. NfSen is an [...]]]></description>
			<content:encoded><![CDATA[<p>If you work for any sort of provider (hosting, isp, etc), chances are that you&#8217;ve experienced a DoS/DDoS against a customer or internal system. If so, you know how frustrating it can be to track down the source of the attack unless you have an expensive platform such as from Arbor Networks.</p>
<p><span id="more-90"></span><br />
<br />
NfSen is an invaluable open source tool that can be used to identify and alert on specific attacks. It does this by receiving <a href="http://www.cisco.com/en/US/technologies/tk648/tk362/technologies_white_paper09186a00800a3db9_ps6601_Products_White_Paper.html" target="_blank">Netflow </a>data from a Cisco or Juniper router.</p>
<p>NfSen is available from: <a href="http://nfsen.sourceforge.net" target="_blank">http://nfsen.sourceforge.net</a><br />
NfDump (1.5.8 or greater)  is available from: <a href="http://nfdump.sourceforge.net" target="_blank">http://nfdump.sourceforge.net</a></p>
<p>Besides the above applications, you will also need the following:</p>
<ul>
<li>Perl &gt; 5.6.0</li>
<li>PHP &gt; 4.1</li>
<li>Mail::Header and Mail::Internet (from CPAN)</li>
<li><a href="http://oss.oetiker.ch/rrdtool/" target="_blank">RRDTool</a> (for graph generation)</li>
<li>a <a href="http://blog.jason-rowley.com/2010/01/02/mitigating-dosddos-attacks-with-real-time-black-hole-rtbh-filtering/" target="_blank">RTBH </a>(Real Time Black Hole) system to drop the traffic as close to ingress as possible.</li>
</ul>
<p>Once you have those installed, we can move onto plugins. By itself, NfSen gives you visibility into your network, but alone, it doesn&#8217;t alert you about anomalies. That&#8217;s where my Dynamic DDoS Detector (DDD) plugin comes in.</p>
<p>DDD can be downloaded from <a href="http://www.synacknetworks.com/ddd/ddd.zip" target="_blank">http://www.synacknetworks.com/ddd/ddd.zip</a>. This zip file contains the Perl module (ddd.pm) and the MySQL structure.</p>
<p>DDD is loosely based on a plugin by John Fraizer named newddosdetect. Other than the concept, it&#8217;s been almost entirely rewritten, hence the new name.</p>
<p>The main reason for this plugin is that we recently deployed dedicated Netflow probes through our network. These take a feed from an inline tap and generate Netflow data, which is then relayed to our collectors. These probes work fairly well, however, they continue to see an attack even though it may have been mitigated via RTBH.</p>
<p><a href="http://blog.synacknetworks.com/wp-content/uploads/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/samplenetwork.png" rel="lightbox[90]"><img class="alignnone size-medium wp-image-93" title="samplenetwork" src="http://blog.synacknetworks.com/wp-content/uploads/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/samplenetwork-300x261.png" alt="" width="300" height="261" /></a></p>
<p>Since they continue to see the attack traffic, our collector continued to alert, causing a flood of emails until we manually edited the existing plugin and reloaded NfSen. Now, all we need to do is insert the attacker&#8217;s IP in our exclusion list.</p>
<p>To install, you just need to do the following steps:</p>
<p>1) Create the MySQL database from the ddd.mysql file. You can use the cli or phpMyAdmin.</p>
<p>2) Add any IP blocks you want to exclude (in CIDR format)</p>
<p>3) Adjust the filters, if needed</p>
<p>4) Drop the ddd.pm file into your NfSen plugins directory</p>
<p>5) Edit ddd.pm and change the following</p>
<pre class="brush: perl;">
### database login info
my $dsn         = 'dbi:mysql:ddd:127.0.0.1:3306';
my $user        = 'dbuser';
my $pass        = 'dbpass';
</pre>
<pre class="brush: perl;">
# Specify the notification email(s).
if ($DEBUG &gt; 0)
{
        $emails = &quot;user\@example.com&quot;;
        print &quot;Emails = $emails\n\n&quot;;
}
else
{
        $emails = &quot;distro-list\@example.com&quot;;
}
</pre>
<pre class="brush: perl;">
# beginning of the subject line for alerts
my $subject     = &quot;&quot;;
if ($DEBUG &gt; 0)
{
        $subject        = '[DEBUG] DDoS Alert:';
}
else
{
        $subject        = &quot;DDoS Early Warning:&quot;;
}
</pre>
<p>6) Edit nfsen.conf to include the plugin.</p>
<pre class="brush: plain;">
@plugins = (
    # profile    # module
        [ 'live', 'ddd'],
);
</pre>
<p>7) Reload NfSen</p>
<pre class="brush: plain;">
bin/nfsen reload
</pre>
<p>Once done, NfSen will run the plugin every expire cycle (default is every 5 minutes). If you watch /var/log/messages, you should see it run with output similar to the following sanitized log.</p>
<pre class="brush: plain;">
Jan 11 01:45:15 hostname nfsen[9261]: 90 channels/alerts to profile
Jan 11 01:45:16 hostname nfsen[9261]: Update profile Compromised-Customers in group .
Jan 11 01:45:17 hostname nfsen[9261]: Update profile botnet in group .
Jan 11 01:45:18 hostname nfsen[9261]: Update profile live in group .
Jan 11 01:45:18 hostname nfsen[9261]: Update profile AKAMAI in group BREAKDOWN
Jan 11 01:45:19 hostname nfsen[9261]: Update profile DNS-SERVERS in group BREAKDOWN
Jan 11 01:45:20 hostname nfsen[9261]: Update profile IRC-Probable-Targets in group BREAKDOWN
Jan 11 01:45:21 hostname nfsen[9261]: Update profile Private-IPs in group BREAKDOWN
Jan 11 01:45:22 hostname nfsen[9261]: Update profile Protocols-at-a-glance in group BREAKDOWN
Jan 11 01:45:23 hostname nfsen[9261]: Update profile Services-at-a-glance in group BREAKDOWN
Jan 11 01:45:23 hostname nfsen[9477]: Plugin Cycle: Time: 201001110140, Profile: live, Group: ., Module: PortTracker,
Jan 11 01:45:25 hostname nfsen[9477]: Plugin Cycle: Time: 201001110140, Profile: live, Group: ., Module: ddd,
Jan 11 01:45:25 hostname nfsen[9477]: ddd.pm -------------------------------------------------------------
Jan 11 01:45:25 hostname nfsen[9477]: ddd.pm exclusions: (NOT net A.B.C.D/32 )
Jan 11 01:45:25 hostname nfsen[9477]: ddd.pm run: Checking Packets &gt; 50K/flow-set
Jan 11 01:45:25 hostname nfsen[9477]: ddd.pm run: NF Filter: ((packets &gt; 50000) AND NOT (proto tcp AND NOT (port 110 OR port 25)) AND NOT proto esp) AND (NOT net A.B.C.D/32 )
Jan 11 01:45:25 hostname nfsen[9477]: ddd.pm end: Packets &gt; 50K/flow-set
Jan 11 01:45:25 hostname nfsen[9477]: ddd.pm -------------------------------------------------------------
Jan 11 01:45:25 hostname nfsen[9477]: ddd.pm exclusions: (NOT net A.B.C.D/32  AND NOT net A.B.C.D/32 AND NOT net A.B.C.D/30 AND NOT net A.B.C.D/23 AND NOT net A.B.C.D/22 AND NOT net A.B.C.D/24 AND NOT net A.B.C.D/23  AND NOT net A.B.C.D/23 AND NOT net A.B.C.D/23)
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: Checking UDP Packets &gt; 80K/dest
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: NF Filter: proto udp and not out if 0 AND (NOT net A.B.C.D/32  AND NOT net A.B.C.D/32 AND NOT net A.B.C.D/30 AND NOT net A.B.C.D/23 AND NOT net A.B.C.D/22 AND NOT net A.B.C.D/24 AND NOT net A.B.C.D/23  AND NOT net A.B.C.D/23 AND NOT net A.B.C.D/23)
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: No matching flows found for UDP Packets &gt; 80K/dest
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm end: UDP Packets &gt; 80K/dest
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm -------------------------------------------------------------
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm exclusions: (NOT net A.B.C.D/28  AND NOT net A.B.C.D/32)
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: Checking TCP Packets &gt; 100K/dest
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: NF Filter: proto tcp and not out if 0 AND (NOT net A.B.C.D/28  AND NOT net A.B.C.D/32)
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: No matching flows found for TCP Packets &gt; 100K/dest
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm end: TCP Packets &gt; 100K/dest
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm -------------------------------------------------------------
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm exclusions:
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: Checking ICMP Packets &gt; 50K/dest
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: NF Filter: proto icmp and not out if 0
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: No matching flows found for ICMP Packets &gt; 50K/dest
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm end: ICMP Packets &gt; 50K/dest
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm -------------------------------------------------------------
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm exclusions: (NOT net A.B.C.D/28  AND NOT net A.B.C.D/32 AND NOT net A.B.C.D/32 AND NOT net A.B.C.D/32 AND NOT net A.B.C.D/32)
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: Checking TCP SYN Storm
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: NF Filter: proto tcp and packets eq 1 and flags S and not flags A and bpp 48 and not out if 0 AND (NOT net A.B.C.D/28  AND NOT net A.B.C.D/32 AND NOT net A.B.C.D/32 AND NOT net A.B.C.D/32 AND NOT net A.B.C.D/32)
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: No matching flows found for TCP SYN Storm
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm end: TCP SYN Storm
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm -------------------------------------------------------------
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm exclusions: (NOT net A.B.C.D/23  AND NOT net A.B.C.D/30 AND NOT net A.B.C.D/32 AND NOT net A.B.C.D/23 AND NOT net A.B.C.D/22 AND NOT net A.B.C.D/24 AND NOT net A.B.C.D/23 AND NOT net A.B.C.D/23)
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: Checking UDP Packets &gt; 70K / IP
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm run: NF Filter: proto udp and not out if 0 AND (NOT net A.B.C.D/23  AND NOT net A.B.C.D/30 AND NOT net A.B.C.D/32 AND NOT net A.B.C.D/23 AND NOT net A.B.C.D/22 AND NOT net A.B.C.D/24 AND NOT net A.B.C.D/23 AND NOT net A.B.C.D/23)
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm end: UDP Packets &gt; 70K / IP
Jan 11 01:45:26 hostname nfsen[9477]: ddd.pm -------------------------------------------------------------
Jan 11 01:45:26 hostname nfsen[9261]: Run expire at Mon Jan 11 01:45:00 2010
Jan 11 01:45:26 hostname nfsen[9261]: Expire profile Compromised-Customers group . low water mark: 90%%
Jan 11 01:45:27 hostname nfsen[9261]: Expire profile botnet group . low water mark: 90%%
Jan 11 01:45:27 hostname nfsen[9261]: Expire profile live group . low water mark: 90%%
Jan 11 01:45:27 hostname nfsen[9261]: Expire profile AKAMAI group BREAKDOWN low water mark: 90%%
Jan 11 01:45:27 hostname nfsen[9261]: Expire profile IRC-Probable-Targets group BREAKDOWN low water mark: 90%%
Jan 11 01:45:27 hostname nfsen[9261]: End expire at Mon Jan 11 01:45:00 2010
</pre>
<p>You shouldn&#8217;t see any errors here. If you do, most likely the IPs in your exclusion table aren&#8217;t in CIDR format. Even a host needs to be in that format (i.e. 192.168.1.1/32).</p>
<p>When an attack is detected, we send an email to the address listed in the plugin with the body composed of the relevant details. The following is an alert from last year indicating a UDP attack against our customer on port 113.</p>
<pre class="brush: plain;">
Date flow start          Duration Proto      Src IP Addr:Port          Dst IP Addr:Port   Flags Tos  Packets    Bytes      pps      bps    Bpp Flows
2009-11-16 03:07:15.269   133.556 UDP     AA.AAA.AAA.AAA:35198 -&gt;     XX.XXX.XX.XX:113   ......   0   187678    8.6 M     1405   517127     46     2

Summary: total flows: 2, total bytes: 8.6 M, total packets: 187678, avg bps: 517127, avg pps: 1405, avg bpp: 46
Time window: 2009-11-16 03:03:28 - 2009-11-16 03:10:06
Total flows processed: 803235, Blocks skipped: 0, Bytes read: 43449712
Sys: 0.174s flows/second: 4590622.6  Wall: 0.170s flows/second: 4724217.0
</pre>
<p>Additionally, the alert is stored in the database for future queries.</p>
<p>With this information, we can then use NfSen to pull up details for the suspected attack. We&#8217;ll want to do a query such as &#8220;host XX.XXX.XX.XX&#8221;, where xx is the destination of the attack (our customer). This allows us to see all sources because some attackers could be below our thresholds.</p>
<p><a href="http://blog.synacknetworks.com/wp-content/uploads/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/attack.png" rel="lightbox[90]"><img class="alignnone size-medium wp-image-91" title="attack" src="http://blog.synacknetworks.com/wp-content/uploads/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/attack-300x156.png" alt="" width="300" height="156" /></a></p>
<p>Chances are that if we go back to the beginning of the attack (or a few cycles before), we&#8217;ll find IRC traffic directly preceding the attack. IRC is typically on ports 6660 through 6669, or port 7000).</p>
<p><a href="http://blog.synacknetworks.com/wp-content/uploads/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/irc.png" rel="lightbox[90]"><img class="alignnone size-full wp-image-92" title="irc" src="http://blog.synacknetworks.com/wp-content/uploads/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/irc.png" alt="" width="563" height="124" /></a></p>
<p>This usually indicates one of two things. 1) Someone was talking smack on IRC and got slapped, or 2) This customer got infected by an old piece of malware and when it tried to login to the command and control channel, it had an old password, resulting in an automatic attack.</p>
<p>In either case, we mitigate the attack in our <a href="http://blog.jason-rowley.com/2010/01/02/mitigating-dosddos-attacks-with-real-time-black-hole-rtbh-filtering/" target="_blank">RTBH </a>system, apply an IRC ACL to the customer interface, and send a ticket to our security group to contact the customer so they can clean the infection.</p>
<p>Some other ideas we&#8217;ve been kicking around for future versions of DDD is the ability to automatically inject a prefix into our mitigation VRF so that our Arbor implementation can scrub the traffic instead of manually blackholing it.</p>
<p>Also, version 1.5 will include the ability to auto expire attack exclusions, in addition to permanent exclusions. You don&#8217;t want to permanently exclude an attackers or attack destination because you&#8217;ll be blind to future attacks. Additionally, NfSen can only accept filters that are so long.</p>
<p>This is a fairly simple, yet effective way to identify attacks on your network. Since NfSen is always looking 5 minutes into the past, you won&#8217;t be able to prevent an outage, but you can shorten the duration, lessening the impact.</p>
<p>Be cautious what you blackhole with this. Sure, most alerts are true attacks, but some can just be anomalous, yet valid traffic. Things like breaking news could possibly trigger an alert if a lot of users suddenly start visiting a small number of web sites. Be sure you know what an IP is associated with before null routing it. You don&#8217;t want to create an outage. You also probably don&#8217;t want to null route a customer unless an attack is affecting large portions of the network and is absolutely necessary.</p>
<p>You should also get buy-in from management before implementing new policies, such as ACLs to block IRC traffic, or even RTBH.<br />
</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/&amp;title=Using+NfSen+and+NfDump+to+identify+DoS%2FDDoS+attacks" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/&amp;title=Using+NfSen+and+NfDump+to+identify+DoS%2FDDoS+attacks" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/&amp;title=Using+NfSen+and+NfDump+to+identify+DoS%2FDDoS+attacks&amp;desc=If%20you%20work%20for%20any%20sort%20of%20provider%20%28hosting%2C%20isp%2C%20etc%29%2C%20chances%20are%20that%20you%27ve%20experienced%20a%20DoS%2FDDoS%20against%20a%20customer%20or%20internal%20system.%20If%20so%2C%20you%20know%20how%20frustrating%20it%20can%20be%20to%20track%20down%20the%20source%20of%20the%20attack%20unless%20you%20have%20an%20expensive%20platform%20such%20as%20from%20Arbor%20Networks.%0D%0A%0D%0A%0D%0A%5Bad" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/&amp;bm_description=Using+NfSen+and+NfDump+to+identify+DoS%2FDDoS+attacks&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/&amp;title=Using+NfSen+and+NfDump+to+identify+DoS%2FDDoS+attacks" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/&amp;title=Using+NfSen+and+NfDump+to+identify+DoS%2FDDoS+attacks" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/&amp;title=Using+NfSen+and+NfDump+to+identify+DoS%2FDDoS+attacks" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Using+NfSen+and+NfDump+to+identify+DoS%2FDDoS+attacks+-+http://b2l.me/de5ys&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.synacknetworks.com/2010/01/10/using-nfsen-and-nfdump-to-identify-dosddos-attacks/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Visio tips and tricks for documenting networks</title>
		<link>http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/</link>
		<comments>http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 10:53:26 +0000</pubDate>
		<dc:creator>jrowley</dc:creator>
				<category><![CDATA[Network documentation]]></category>
		<category><![CDATA[diagrams]]></category>
		<category><![CDATA[Visio]]></category>

		<guid isPermaLink="false">http://blog.synacknetworks.com/?p=40</guid>
		<description><![CDATA[Visio is one of my favorite documentation tools. This post will show how to use some of the tricks I've learned over the years to create a good looking network diagram.]]></description>
			<content:encoded><![CDATA[<p>Visio is one of my favorite documentation tools. This post will show how to use some of the tricks I&#8217;ve learned over the years to create a good looking network diagram.</p>
<p>You&#8217;ll notice that I don&#8217;t use vendor specific router shapes. They are fine for sales or marketing diagrams. For functional network diagrams, they are pretty useless. I&#8217;d rather have a colored box with the hostname and loopback IP inside than have that text outside and cluttering up the diagram. It&#8217;s a personal preference, use whatever you want.</p>
<p><span id="more-40"></span><br />
<br />
Note: Sorry for the lack of details, but I can&#8217;t zoom in any closer without giving away any proprietary data on the network.</p>
<p>A snippet of our core diagram looks like this</p>
<p><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/full.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-56" title="full" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/full.jpg" alt="core network overview" /></a></p>
<p>Instead of using the curved line tool to create the curved links, we use the circle shape tool and split it to connect routers. Additionally, we also have hidden layers that we use to align routers.</p>
<p>To work with layers, click View and then Layer Properties from the file menu.</p>
<p><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/layers.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-57" title="layers" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/layers.jpg" alt="" width="509" height="384" /></a></p>
<p>This layer is called &#8220;Drawing Aids&#8221; and is only used when modifying the drawing. We don&#8217;t want to print it on the plotter, so make sure Print is unchecked.</p>
<p>Now, draw a series of circles with the Ellipse tool from the Drawing toolbar. A tip here is to hold the shift key while sizing the circle to prevent it from turning into an oval. I usually use red for the color because it stands out enough at any zoom level.</p>
<p><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/fulllayers.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-58" title="fulllayers" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/fulllayers.jpg" alt="" width="958" height="797" /></a></p>
<p>After the circles are layed out, we want to put them into the layer. Select one or more circles and then right click. Now, click Format and then Layer. You can select an existing layer, or create a new one here.</p>
<p>Now, we are ready to create an arc that we can use to connect routers aligned along the circle. For this, I usually create a blank document or new tab and draw a circle (holding shift) and then draw straight lines through it like this:</p>
<p><a rel="attachment wp-att-44" href="http://blog.synacknetworks.com/about/2-revision/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/arc1.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-59" title="arc1" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/arc1.jpg" alt="" width="512" height="527" /></a></p>
<p>Make sure the circle and all lines are selected with Ctrl-A (if this is a new temp tab or drawing). To split the shape, click Shape, Operations, and Fragment from the file menu.Then move the new fragment away.</p>
<p><a rel="attachment wp-att-45" href="http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/25-revision/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/arc2.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-60" title="arc2" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/arc2.jpg" alt="" width="429" height="405" /></a></p>
<p>To remove the straight lines, we need to use the pencil tool. Select it and then click the corner right on top of the handle. It looks like you are going to move or size the shape, but that&#8217;s ok. You should see the corner turn red after clicking. Now, press delete.</p>
<p><a rel="attachment wp-att-46" href="http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/25-revision-2/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/arc3.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-61" title="arc3" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/arc3.jpg" alt="" width="433" height="420" /></a></p>
<p>Voila! You should have something like the above. To remove the remaining line, click the circle in the middle of the line (it should turn red too) and press delete.</p>
<p><a rel="attachment wp-att-47" href="http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/25-revision-3/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/arc4.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-62" title="arc4" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/arc4.jpg" alt="" width="425" height="427" /></a></p>
<p>Now, we have an arc that we can use to follow our layouts for market to market connections. The last thing to do is remove the fill, otherwise you will cover up overlapping shapes. In the toolbar, click the fill bucket and select No Fill.</p>
<p>Now, we can copy this and paste it into our drawing. I use these to create circular links between market routers when I want several lines that line up easily. If you want a curve that&#8217;s a bit more granular, you can use the pencil tool to draw a straight line and curve it. To keep it straight at first, hold the shift key.</p>
<p><a rel="attachment wp-att-49" href="http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/16-revision-4/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/curve1.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-63" title="curve1" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/curve1.jpg" alt="" width="265" height="193" /></a></p>
<p>Now that we have a line, we want to click the round point in the middle and drag it outward. This will curve the line.</p>
<p><a rel="attachment wp-att-50" href="http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/16-revision-5/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/curve2.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-64" title="curve2" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/curve2.jpg" alt="" width="250" height="182" /></a></p>
<p>The nice thing about this is we no longer need the drawing toolbox. If you want to reposition the arc, just do so with the pointer tool. You can also adjust the arc to line it up with your layout circles.</p>
<p>I use the same layer trick for our market detail diagrams. Only, instead of circles, I just use straight lines to line up the routers.</p>
<p><a rel="attachment wp-att-51" href="http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/25-autosave/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/markets.jpg" rel="lightbox[40]"><img class="alignnone size-large wp-image-65" title="markets" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/markets-1024x634.jpg" alt="" width="1024" height="634" /></a></p>
<p>With my layers</p>
<p><a rel="attachment wp-att-52" href="http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/25-revision-4/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/markets-layers.jpg" rel="lightbox[40]"><img class="alignnone size-large wp-image-66" title="markets-layers" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/markets-layers-1024x592.jpg" alt="" width="1024" height="592" /></a></p>
<p>The trick to keeping everything in line is to zoom in. I go as close as 200%, occasionally 400%. This allows you to use the arrow keys to move the shapes around a lot more granular than you can at 100%. I also use the Align Shapes button to line up a stack of routers.</p>
<p>For lines that have angles, I typically curve the corners.</p>
<p><a rel="attachment wp-att-56" href="http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/full/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/corners.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-67" title="corners" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/corners.jpg" alt="" width="494" height="423" /></a></p>
<p>Just select your line and right click, then Format and Line. I select the 2nd round corner since it is the smallest curve.</p>
<p><a rel="attachment wp-att-55" href="http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/40-autosave/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/corner-sample.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-68" title="corner-sample" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/corner-sample.jpg" alt="" width="89" height="105" /></a></p>
<p>Finally, you should have a legend somewhere on the map. Ours indicates what the different color links are. It also contains our default OSPF cost. Link costs are always on the links, but we use a dark red to indicate any that deviate from the standard costs so they are easy to notice.</p>
<p><a rel="attachment wp-att-53" href="http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/31-autosave/"></a><a rel="attachment wp-att-54" href="http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/31-revision/"></a><a href="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/legend.jpg" rel="lightbox[40]"><img class="alignnone size-full wp-image-69" title="legend" src="http://blog.synacknetworks.com/wp-content/uploads/2009/12/24/visio-tips-and-tricks-for-documenting-networks/legend.jpg" alt="" width="543" height="273" /></a><br />
</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/&amp;title=Visio+tips+and+tricks+for+documenting+networks" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/&amp;title=Visio+tips+and+tricks+for+documenting+networks" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/&amp;title=Visio+tips+and+tricks+for+documenting+networks&amp;desc=Visio%20is%20one%20of%20my%20favorite%20documentation%20tools.%20This%20post%20will%20show%20how%20to%20use%20some%20of%20the%20tricks%20I%27ve%20learned%20over%20the%20years%20to%20create%20a%20good%20looking%20network%20diagram." rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/&amp;bm_description=Visio+tips+and+tricks+for+documenting+networks&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/&amp;title=Visio+tips+and+tricks+for+documenting+networks" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/&amp;title=Visio+tips+and+tricks+for+documenting+networks" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/&amp;title=Visio+tips+and+tricks+for+documenting+networks" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Visio+tips+and+tricks+for+documenting+networks+-+http://b2l.me/chtfx&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.synacknetworks.com/2009/12/24/visio-tips-and-tricks-for-documenting-networks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing cisco router configurations with Cisco::Reconfig</title>
		<link>http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/</link>
		<comments>http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 12:11:15 +0000</pubDate>
		<dc:creator>jrowley</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[audit]]></category>
		<category><![CDATA[compare access-list]]></category>
		<category><![CDATA[configurations]]></category>

		<guid isPermaLink="false">http://blog.synacknetworks.com/?p=31</guid>
		<description><![CDATA[Cisco::Reconfig is probably my favorite Perl module, with Quantum::Superpositions being not very far behind. In this post, I&#8217;ll show you how using both of these can allow you to compare ACLs with very few lines of perl. Once you install them via CPAN, just add references at the top of your script #!/usr/bin/perl use Cisco::Reconfig; [...]]]></description>
			<content:encoded><![CDATA[<p>Cisco::Reconfig is probably my favorite Perl module, with Quantum::Superpositions being not very far behind. In this post, I&#8217;ll show you how using both of these can allow you to compare ACLs with very few lines of perl.</p>
<p><span id="more-31"></span><br />
<br />
Once you install them via CPAN, just add references at the top of your script</p>
<pre class="brush: perl;">
#!/usr/bin/perl
use Cisco::Reconfig;
use Quantum::Superpositions;
</pre>
<p>You should also have a Cisco configuration file available. If you use my backup script, copy one to your script directory and uncompress it with &#8216;gzip -d file.gz&#8217;.</p>
<p>Reading the Cisco configuration requires just one line</p>
<pre class="brush: perl;">
$MYCONFIG = readconfig(&quot;/tmp/myciscorouter.conf&quot;);
</pre>
<p>Make sure you keep this in appropriate scope since we only want to have to parse the entire configuration once. This allows us to quickly search for portions of configuration.</p>
<p>In this example, we&#8217;ll pretend we have a standard access-list applied to our VTYs and we want to verify the contents. We can load it like this:</p>
<pre class="brush: perl;">
my @ACL61 = $MYCONFIG&amp;minus;&gt;get('access&amp;minus;list 62')&amp;minus;&gt;all;
</pre>
<p>This creates an array that contains every line inside of access-list.</p>
<p>Now, let&#8217;s say we have a text file containing an ACL we want to verify against. Inside, it contains what the ACL should look like on our router.</p>
<pre class="brush: plain;">
pts/0 jrowley@toolbox:/home/jrowley/scripts/test $&gt; cat ACL62
access-list 62 permit 10.132.0.0 0.0.1.255
access-list 62 permit 10.137.0.0 0.0.0.255
access-list 62 permit 10.148.152.0 0.0.0.255
access-list 62 permit 10.159.0 0.0.3.255
access-list 62 permit 10.178.100.0 0.0.1.255
access-list 62 permit 10.199.144.0 0.0.0.255
access-list 62 permit 10.199.146.0 0.0.1.255
access-list 62 permit 10.202.50.0 0.0.1.255
</pre>
<p>We can read this into another array like this</p>
<pre class="brush: perl;">
my $FILENAME = &quot;/home/audit/FILES/ACL62&quot;;
open (ACL, $FILENAME);
my @REFACL62 = &lt;acl&gt;;
close(ACL);
</pre>
<p>Now, we could loop through both array&#8217;s comparing each line, but that&#8217;s too tedious. That&#8217;s where Quantum::Superpositions comes into play.</p>
<pre class="brush: perl;">
my @RESULTSf	= eigenstates(any(@ACL62)    ne all(@REFACL62));
my @RESULTSr	= eigenstates(any(@REFACL62) ne all(@ACL62));
</pre>
<p>Basically, what this does is compares the two arrays both ways. The first @RESULTSf array contains anything that is in @REFACL6, but missing from @ACL62. The @RESULTSr array contains anything that is in @ACL62, but missing from @REFACL6.</p>
<p>We just used two lines to do what normally would be a dozen or so lines. With the addition of a couple print statements, we can do a check to see if it works as expected. Here is the entire example script:</p>
<pre class="brush: perl;">
#!/usr/bin/perl
use Cisco::Reconfig;
use Quantum::Superpositions;

$MYCONFIG = readconfig(&quot;/tmp/myciscorouter.conf&quot;);

my @ACL62 = $MYCONFIG-&gt;get('access&amp;minus;list 62')-&gt;all;

print &quot;ACL on Router\n&quot;;
print &quot;@ACL62\n&quot;;

my $FILENAME = &quot;ACL62&quot;;
open (ACL, $FILENAME);
my @REFACL62 = ;
close(ACL);

print &quot;ACL in reference file\n&quot;;
print &quot;@REFACL62\n&quot;;

my @RESULTSr    = eigenstates(any(@ACL62)    ne all(@REFACL62));
my @RESULTSf    = eigenstates(any(@REFACL62) ne all(@ACL62));

print &quot;Items missing from router ACL\n&quot;;
print &quot;@RESULTSf\n&quot;;

print &quot;Items in router but not in reference file\n&quot;;
print &quot;@RESULTSr\n&quot;;
</pre>
<p>Running it gives us this</p>
<pre class="brush: plain;">
pts/0 jrowley@toolbox:/home/jrowley/scripts/test $&gt; perl test
ACL on Router
 access-list 62 permit 10.132.0.0 0.0.1.255
 access-list 62 permit 10.137.0.0 0.0.0.255
 access-list 62 permit 10.148.152.0 0.0.0.255
 access-list 62 permit 10.159.0 0.0.3.255
 access-list 62 permit 10.78.100.0 0.0.1.255
 access-list 62 permit 10.199.144.0 0.0.0.255
 access-list 62 permit 10.199.146.0 0.0.1.255
 access-list 62 permit 10.202.50.0 0.0.1.255
 access-list 62 permit 192.168.2.0.0 0.0.0.255

ACL in reference file
 access-list 62 permit 10.132.0.0 0.0.1.255
 access-list 62 permit 10.137.0.0 0.0.0.255
 access-list 62 permit 10.148.152.0 0.0.0.255
 access-list 62 permit 10.159.0 0.0.3.255
 access-list 62 permit 10.178.100.0 0.0.1.255
 access-list 62 permit 10.199.144.0 0.0.0.255
 access-list 62 permit 10.199.146.0 0.0.1.255
 access-list 62 permit 10.202.50.0 0.0.1.255

Items missing from router ACL
 access-list 62 permit 10.178.100.0 0.0.1.255

Items in router but not in reference file
 access-list 62 permit 10.78.100.0 0.0.1.255
 access-list 62 permit 192.168.2.0.0 0.0.0.255
</pre>
<p>As we can see, the router configuration is missing one line (10.178.0.0 is typo&#8217;d in the router) and it contains an extra line that isn&#8217;t in our reference file. This could indicate that your ACLs aren&#8217;t as controlled as you might expect.</p>
<p>While we&#8217;ve only checked a single router, it&#8217;s trivial to read a list from a database, read the backups generated by my backup script [<a href="http://blog.synacknetworks.com/2009/10/backing-up-cisco-routers-with-perl/">see post #2</a>], and loop through all of them.</p>
<p>For a large network, consistency is key. Sure, occasionally, you will have different ACLs on different routers, but this will help you standardize your deployment for things that should be the same everywhere. You probably don&#8217;t want to discover at 3:00am that the router you need to access doesn&#8217;t permit your vpn address. It may take a while to standardize all of your routers, but in the end, it is time very well spent.</p>
<p>With these two perl modules, you can easily audit 99% of your router configurations. The remainder is user accounts and vty passwords. You can also check those with an MD5 module and Cisco::Hash (level 7 password decrypter).</p>
<p>Happy scripting!<br />
</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/&amp;title=Parsing+cisco+router+configurations+with+Cisco%3A%3AReconfig" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/&amp;title=Parsing+cisco+router+configurations+with+Cisco%3A%3AReconfig" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/&amp;title=Parsing+cisco+router+configurations+with+Cisco%3A%3AReconfig&amp;desc=Cisco%3A%3AReconfig%20is%20probably%20my%20favorite%20Perl%20module%2C%20with%20Quantum%3A%3ASuperpositions%20being%20not%20very%20far%20behind.%20In%20this%20post%2C%20I%27ll%20show%20you%20how%20using%20both%20of%20these%20can%20allow%20you%20to%20compare%20ACLs%20with%20very%20few%20lines%20of%20perl.%0D%0A%0D%0A%0D%0A%5Bad%23Google%20Adsense%5D%0D%0AOnce%20you%20install%20them%20via%20CPAN%2C%20just%20add%20references%20at" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/&amp;bm_description=Parsing+cisco+router+configurations+with+Cisco%3A%3AReconfig&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/&amp;title=Parsing+cisco+router+configurations+with+Cisco%3A%3AReconfig" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/&amp;title=Parsing+cisco+router+configurations+with+Cisco%3A%3AReconfig" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/&amp;title=Parsing+cisco+router+configurations+with+Cisco%3A%3AReconfig" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Parsing+cisco+router+configurations+with+Cisco%3A%3AReconfig+-+http://b2l.me/chtfy&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.synacknetworks.com/2009/10/26/parsing-cisco-router-configurations-with-ciscoreconfig/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backing up Cisco routers with perl</title>
		<link>http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/</link>
		<comments>http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 18:40:16 +0000</pubDate>
		<dc:creator>jrowley</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[backups]]></category>

		<guid isPermaLink="false">http://blog.synacknetworks.com/?p=25</guid>
		<description><![CDATA[Here is a useful perl script to backup your routers. Configurations are gzipped and stored in per-hostname directories with a datestamp on each filename.

This is meant to be run from cron daily. Change the database user info and the tacacs/radius user info to whatever you use internally.]]></description>
			<content:encoded><![CDATA[<p>Here is a useful perl script to backup your routers. Configurations are gzipped and stored in per-hostname directories with a datestamp on each filename. This is meant to be run from cron daily. Change the database user info and the tacacs/radius user info to whatever you use internally. </p>
<p><span id="more-25"></span><br />
<br />
Before you begin, make sure you install the Net::Telnet::Cisco and DBD::mysql CPAN modules.</p>
<p>Download the backup script <a href="http://www.synacknetworks.com/scripts/audit/backup.txt" target="_blank">here</a>.</p>
<p><span style="font-size: x-large;">Database</span></p>
<p>We use a database to store our router information [see the soon to be released <a href="http://www.mraudit.org" target="_blank">Mr Audit</a>]. The relevant table is included in the file db.sql [<a href="http://www.synacknetworks.com/scripts/audit/db.sql" target="_blank">download</a>]. Simply create a database (we use &#39;auditdb&#39;) and import the db.sql file. It includes some sample data, so be sure to change that too.</p>
<p>You only need to be concerned with following columns:</p>
<ul>
<li>id &#8211; primary key</li>
<li>iptext &#8211; IP Address of the router</li>
<li>hostname &#8211; Hostname of the router</li>
<li>status &#8211; up or down</li>
<li>company &#8211; company name in case of multiple networks</li>
<li>backup &#8211; status field; used by script to indicate if backup was successful or not.</li>
</ul>
<p>The others are not used by the backup script. <span style="font-size: x-large;"><br />
	The Script</span></p>
<p>The only items that need to be changed are listed below.</p>
<pre class="brush: perl;">
### database login info
my $dsn         = &quot;dbi:mysql:auditdb:127.0.0.1:3306&quot;;
my $user        = &quot;dbuser&quot;;
my $pass        = &quot;dbpass&quot;;

### tacacs/radius login info
my $username    = &quot;tacacsuser&quot;;
my $password    = &quot;tacacspass&quot;;

### this is where all the config backups are stored
$::DIRECTORY = &quot;/backups/prod&quot;;

my $dbh = DBI-&gt;connect($dsn, $user, $pass) or die &quot;Cantt connect to the DB: $DBI::errstr\n&quot;;

# change company field to whatever you use
$sql = &quot;SELECT id,iptext,hostname FROM routers WHERE status='up' AND company='synacknetworks';
</pre>
<p>Once that is finished, just do a &quot;chmod +x filename&quot;&nbsp; and you can either run it now, or add a cron job to run every so often. Until <a href="http://www.mraudit.org" target="_blank">Mr Audit</a> is released, you can view your backups with the following command.</p>
<pre class="brush: plain;">
zcat /backups/prod/hostname/hostname-config.2009-10-25.gz |less
</pre>
<p>Our production deployment has over 400 days worth of backups for more than 1000 routers. Your mileage may vary depending on disk space.</p>
<p><span style="font-size: x-large;">Limited disk environments</span></p>
<p>If you don&#39;t have much storage, you can run the following command to remove anything older than x days fro the backups.&nbsp; This example uses 7 days</p>
<pre class="brush: plain;">
find /backups/prod -name &quot;*.gz&quot;; -mtime +7 -exec rm {} \;
</pre>
<p>There must be a space between {} and \; Future Over the next few months, I&#39;ll be showing how to use the tools included with <a href="http://www.mraudit.org" target="_blank">Mr Audit</a> to automate network audits. Stay tuned.</p>
<p></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/&amp;title=Backing+up+Cisco+routers+with+perl" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/&amp;title=Backing+up+Cisco+routers+with+perl" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/&amp;title=Backing+up+Cisco+routers+with+perl&amp;desc=Here%20is%20a%20useful%20perl%20script%20to%20backup%20your%20routers.%20Configurations%20are%20gzipped%20and%20stored%20in%20per-hostname%20directories%20with%20a%20datestamp%20on%20each%20filename.%0D%0A%0D%0AThis%20is%20meant%20to%20be%20run%20from%20cron%20daily.%20Change%20the%20database%20user%20info%20and%20the%20tacacs%2Fradius%20user%20info%20to%20whatever%20you%20use%20internally." rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/&amp;bm_description=Backing+up+Cisco+routers+with+perl&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/&amp;title=Backing+up+Cisco+routers+with+perl" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/&amp;title=Backing+up+Cisco+routers+with+perl" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/&amp;title=Backing+up+Cisco+routers+with+perl" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Backing+up+Cisco+routers+with+perl+-+http://b2l.me/chtfz&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.synacknetworks.com/2009/10/25/backing-up-cisco-routers-with-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl script to check customer interface status on Cisco routers</title>
		<link>http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/</link>
		<comments>http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 15:10:43 +0000</pubDate>
		<dc:creator>jrowley</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://blog.synacknetworks.com/?p=16</guid>
		<description><![CDATA[This utility is a simple perl script that checks all interfaces in a Cisco router. It is useful to run before and after router maintenance to ensure customers that were up prior, are up after.]]></description>
			<content:encoded><![CDATA[<h2>Overview</h2>
<p>This utility is a simple perl script that checks all interfaces in a Cisco router. It is useful to run before and after router maintenance to ensure customers that were up prior, are up after. This script checks both VRF and non-VRF customers. It also supports /30 and /31 interface addresses.<br />
<span id="more-16"></span><br />
</p>
<h2>Requirements</h2>
<p>It requires the following perl modules. Running the script also requires sudo access due to sending ICMP packets.</p>
<ul>
<li>Net::Telnet::Cisco</li>
<li>Net::Ping</li>
<li>NetAddr::IP</li>
<li>Cisco::Reconfig</li>
<li>Getopt::Std</li>
<li>Text::CSV</li>
</ul>
<p>Install these via CPAN. The only things that you will need to change are the username and password variables. These should be low privilege accounts, preferably TACACS or RADIUS. The script itself can be downloaded <a href="http://www.synacknetworks.com/scripts/pingcheck.txt" target="_blank">here</a>.</p>
<h2>Usage</h2>
<p>Typing &#8216;pingcheck&#8217; by itself prints out the command line options.</p>
<pre class="brush: plain;">
pts/2 jrowley@toolbox:/home/jrowley $&gt; sudo pingcheck

Cisco Ping Checker Thingy Version 1.0

        Usage:
        /APPS/sandbox/usr/local/bin/pingcheck [-h] -w init|recheck -r
        no copyright bs. just supply caffeine and cigs

        -h                : prints this message
        -w init|recheck   : initialize or recheck
        -r                : hostname or IP address

        Examples:

        Grabs router config and performs pre-check
                /APPS/sandbox/usr/local/bin/pingcheck -w init -r routername
        Re-checks interfaces from pre-check
        You must use the same router name as used to initialize
                /APPS/sandbox/usr/local/bin/pingcheck -w recheck -r routername
</pre>
<p>If you are doing something like an IOS upgrade, be sure you do a &#8216;wr mem&#8217; first. This also has the benefit of obtaining all customer configs if your company has a policy of only writing the configuration at certain times of day.</p>
<h2>Usage Example</h2>
<p>The following shows what the output looks like when running against a production router</p>
<pre class="brush: plain;">
pts/2 jrowley@toolbox:/home/jrowley $&gt; sudo pingcheck -w init -r exampleca1
Beginning initial check
Connecting to exampleca1
Grabbing config from exampleca1
Interface                              Local IP           Remote IP          Physical Logical  ICMP
Tunnel106474                           172.16.0.5         172.16.0.6         up       up       up
Tunnel175011                           172.16.0.5         172.16.0.6         up       up       up
Tunnel192359                           172.16.0.1         172.16.0.2         up       up       up
Tunnel201345                           172.16.30.9        172.16.30.10       up       up       up
Tunnel201964                           172.16.0.5         172.16.0.6         up       up       up
Tunnel213904                           172.16.0.5         172.16.0.6         up       up       up
Tunnel213980                           172.16.0.5         172.16.0.6         up       up       up
[snip]
Serial4/1/24:0                         xx.xxx.xx.51       xx.xxx.xx.50       up       up       down
Serial4/1/25:0                         NONE               NONE               up       up       down
Serial4/1/26:0                         NONE               NONE               up       up       down
Serial4/1/27:0                         NONE               NONE               up       up       down
Serial4/1/28:0                         NONE               NONE               up       up       down

Ping check complete!

Total Number of interfaces checked: 135
Number of interfaces up: 134
Number of interfaces down: 1
Number of interfaces ignored: 14
</pre>
<p>Essentially, what happens is that the script logs into the router and captures the startup configuration. Then it leaves the router connection open while it starts to parse all the interfaces. For each interface, the script will check the physical and logical status and then try to ping the customer side of the interface (/30 or /31 supported). If the interface is not in a VRF, it sources the ping from the server it is run on. If the interface is in a VRF, it sources the ping from the router inside the VRF. In the above example, we checked 135 configured interfaces (plus 14 skipped interfaces because they had no IP Address). Out of those 135, only one was down. In our case, it&#8217;s likely from preprovisioning a customer. The script saves the status of the interfaces and the ping status in a CSV. When we use the recheck flag, it reads this file instead of having to reparse the configuration resulting in a much faster check. Now, let&#8217;s pretend we did some maintenance and recheck the router.</p>
<pre class="brush: plain;">
pts/2 jrowley@toolbox:/home/jrowley $&gt; sudo pingcheck -w recheck -r exampleca1
Beginning recheck
Connecting to exampleca1
Interface                              Local IP           Remote IP          Physical Logical  ICMP
Serial4/1/24:0                         xx.xxx.xx.51       xx.xxx.xx.50       up       up       up

Recheck complete!

Number that failed recheck: 0
</pre>
<p>If our down interface was a circuit issue that was corrected by the maintenance, it would show up in the recheck. Hopefully nothing fails recheck that worked before. If any do fail, troubleshoot them and keep rerunning the recheck until you see the failed recheck count get to zero.</p>
<h2>Hints</h2>
<p>If you get any weird errors, make sure you didn&#8217;t forget the -w and -r flags.</p>
<pre class="brush: plain;">
pts/2 jrowley@toolbox:/home/jrowley/d $&gt; sudo pingcheck -w init exampleca1
Beginning initial check
Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/site_perl/5.8.5/Net/Telnet/Cisco.pm line 39.
Use of uninitialized value in concatenation (.) or string at /APPS/sandbox/usr/local/bin/pingcheck line 393.

Connecting to
ERROR: Not a Cisco router!!!
</pre>
<p>This error is because -r was missing before the hostname we wanted to check. If you did include the -w and -r flags, you likely found a bug in the interface parser logic. Send me a message and I&#8217;ll include a fix in the next release.</p>
<h2>Cisco::Reconfig note</h2>
<p>In the current Cisco::Reconfig module, you will likely need to comment out 4 lines. Try without first. If you don&#8217;t receive any errors, comment these lines in Reconfig.pm</p>
<pre class="brush: plain;">
                                # this really shouldn&amp;#39;t happen.  But it does.
#                               die unless $prev eq &amp;quot;!\n&amp;quot; || $prev =~ /^!.*$/;
#                               die unless $indent == 0;
#                               $ciscobug = 1;
#                               $indent = $in;
</pre>
<p>They start on line 103, just after the comment &#8220;# this really shouldn&#8217;t happen.  But it does&#8221;. I guess it doesn&#8217;t really happen.</p>
<h2>Summary</h2>
<p>Hopefully this script makes your life simpler. It could help prevent outages when making configuration changes or doing upgrades. If it prevents even one outage, writing it was effort well spent. Let me know if it is useful or if you would like to see any features added.<br />
</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/&amp;title=Perl+script+to+check+customer+interface+status+on+Cisco+routers" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/&amp;title=Perl+script+to+check+customer+interface+status+on+Cisco+routers" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/&amp;title=Perl+script+to+check+customer+interface+status+on+Cisco+routers&amp;desc=This%20utility%20is%20a%20simple%20perl%20script%20that%20checks%20all%20interfaces%20in%20a%20Cisco%20router.%20It%20is%20useful%20to%20run%20before%20and%20after%20router%20maintenance%20to%20ensure%20customers%20that%20were%20up%20prior%2C%20are%20up%20after." rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/&amp;bm_description=Perl+script+to+check+customer+interface+status+on+Cisco+routers&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/&amp;title=Perl+script+to+check+customer+interface+status+on+Cisco+routers" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/&amp;title=Perl+script+to+check+customer+interface+status+on+Cisco+routers" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/&amp;title=Perl+script+to+check+customer+interface+status+on+Cisco+routers" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Perl+script+to+check+customer+interface+status+on+Cisco+routers+-+http://b2l.me/chtf3&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.synacknetworks.com/2009/10/25/perl-script-to-check-customer-interface-status-on-cisco-routers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
