<?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>Networking Blog</title>
	<atom:link href="http://blog.webdir.bg/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.webdir.bg</link>
	<description>Networking - Cisco, Juniper, Linux</description>
	<lastBuildDate>Tue, 22 Jun 2010 13:12:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PERL Apache Realtime Output From Script</title>
		<link>http://blog.webdir.bg/perl-apache-realtime-output-from-script/</link>
		<comments>http://blog.webdir.bg/perl-apache-realtime-output-from-script/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 13:10:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://blog.webdir.bg/?p=325</guid>
		<description><![CDATA[PERL Apache Realtime Output From Script, using  Net::Telnet]]></description>
			<content:encoded><![CDATA[<p>As of Apache 1.3, CGI scripts are essentially not buffered. Every time your script does a &#8220;flush&#8221; to output data, that data gets relayed on to the client. Some scripting languages, for example Perl, have their own buffering for output &#8211; this can be disabled by setting the $| special variable to 1. Of course this does increase the overall number of packets being transmitted, which can result in a sense of slowness for the end user.<br />
CGI scripts that generate their own headers are called nph  (non-parsed headers) scripts. The server must know in advance whether the particular CGI script intends to return a complete set of headers. Web servers handle this differently, but most recognize CGI scripts with a nph- prefix in their filename.<br />
When sending complete headers, you must at least send the   status line plus the Content-type and Server headers. You must print the entire status line; you should not print the Status header. As you will recall, the status line includes the protocol and version string (e.g., &#8220;HTTP/1.1&#8243;), but as you should recall, CGI provides this to you in the environment variable SERVER_PROTOCOL. Always use this variable in your CGI scripts, instead of hardcoding it, because the version in the SERVER_PROTOCOL may vary for older clients.<br />
For example the next perl script, is using telnet to connect to remote host and is executing traceroute. ( The source of this script is taken from freshmeat&#8217;s looking glass project). The most important lines are from 2 to 5. This script is using &#8220;Content-type: text/plain&#8221;, if you plan to use html tags chenged to &#8220;Content-type: text/html&#8221;.<br />
$| &#8211; If set to nonzero, forces a flush after every write or print.<br />
Example of nph-realtime-output.pl</p>
<pre class="brush: perl;">
#!/usr/bin/perl
print &quot;$ENV{SERVER_PROTOCOL} 200 OK\n&quot;;
print &quot;Server: $ENV{SERVER_SOFTWARE}\n&quot;;
print &quot;Content-type: text/plain\n\n&quot;;
$|=1;
use Net::Telnet;
$login=&quot;MyLogin&quot;;
$password=&quot;MySecret&quot;;
$port=&quot;23&quot;;
$host=&quot;xxx.xxx.xxx.xxx&quot;;
$command=&quot;traceroute www.google.com | no-more&quot;;
$telnet = new Net::Telnet;
$telnet-&gt;errmode( sub { print &quot;ERROR:&quot; . join('|', @_) . &quot;\n&quot;; } );
$telnet-&gt;timeout('10');
$telnet-&gt;option_callback( sub { return; } );
$telnet-&gt;option_accept(Do =&gt; 31);
$telnet-&gt;open(Host =&gt; $host, Port =&gt; $port);
if ($login ne &quot;&quot;) {
  $telnet-&gt;waitfor('/(ogin|name|word):.*$/');
  $telnet-&gt;print(&quot;$login&quot;);
}
if ($password ne &quot;&quot;) {
    $telnet-&gt;waitfor('/word:.*$/');
    $telnet-&gt;print(&quot;$password&quot;);
}
$telnet-&gt;waitfor(Match =&gt; '/.*[\$%&gt;] {0,1}$/',
                 Match =&gt; '/^[^#]*[\$%#&gt;] {0,1}$/');
$telnet-&gt;telnetmode(0);
$telnet-&gt;put(pack(&quot;C9&quot;,
                  255,                  # TELNET_IAC
                  250,                  # TELNET_SB
                  31, 0, 200, 0, 0,     # TELOPT_NAWS
                  255,                  # TELNET_IAC
                  240));                # TELNET_SE
$telnet-&gt;telnetmode(1);
my $telnetcmd = $command;
$telnet-&gt;print(&quot;$telnetcmd&quot;);
$telnet-&gt;getline;               # read out command line
while (1) {
  if ($#output &gt;= 0) {
    $_ = shift (@output);
  }
  elsif (! $telnet-&gt;eof) {
    my ($prematch, $match) = $telnet-&gt;waitfor(Match =&gt; '/\n/',
                                              Match =&gt; '/[\$%#&gt;] {0,1}$/',
                                              Errmode =&gt; &quot;return&quot;)
    or do {
    };
    if ($match =~ /[\$%#&gt;] {0,1}$/) {
      $telnet-&gt;print(&quot;quit&quot;);
      $telnet-&gt;close;
      last;
    }
    push @output, $prematch . $match;
    next;
  }
  else {
    last;
  }
  print $_;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.webdir.bg/perl-apache-realtime-output-from-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to upgrade Huawei Quidway S2300 series</title>
		<link>http://blog.webdir.bg/how-to-upgrade-huawei-quidway-s2300-series/</link>
		<comments>http://blog.webdir.bg/how-to-upgrade-huawei-quidway-s2300-series/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 08:11:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Huawei]]></category>

		<guid isPermaLink="false">http://blog.webdir.bg/?p=305</guid>
		<description><![CDATA[Mini howto to upgrade Huawei Quidway S3200 Series]]></description>
			<content:encoded><![CDATA[<p>First we need to copy system software to flash via ftp. Configure ftp access to flash:</p>
<pre>system-view
Enter system view, return user view with Ctrl+Z.
[Quidway]aaa
[Quidway]local-user root password simple MySecretPassword
[Quidway-aaa]local-user root service-type ftp ssh terminal
[Quidway-aaa]local-user root ftp-directory flash:
[Quidway-aaa]quit
[Quidway]ftp server enable
Info:FTP server has been started
</pre>
<p>View flash content:</p>
<pre>dir flash:
Directory of flash:/
<span id="more-305"></span>
   0   -rw-   6813684  Jan 01 2008 00:14:54   SV100R002C02B181SPC001_for_2352_3352.cc
   1   -rw-    107176  Jan 01 2008 00:00:51   matnlog.dat
   2   -rw-        60  Jan 01 2008 00:06:39   $_patchstate_a
   3   -rw-     10668  Jan 01 2008 01:01:53   vrpcfg.cfg
   4   -rw-       684  Jan 01 2008 00:33:20   hostkey
   5   -rw-       540  Jan 01 2008 00:33:28   serverkey
   6   -rw-   7236892  Jan 01 2008 00:15:31   s2352_s3352-v100r003c00spc301.cc
   7   -rw-        28  Jan 01 2008 00:42:31   private-data.txt
   8   -rw-         4  Jan 01 2008 00:07:35   notilogindex.txt

14632 KB total (748 KB free)
</pre>
<p>Tell the switch which firmware to boot after restart:</p>
<pre>startup system-software s2352_s3352-v100r003c00spc301.cc
</pre>
<p>View the startup options:</p>
<pre>display startup
[Unit 0]:
MainBoard:
  Configed startup system software:          flash:/s2352_s3352-v100r003c00spc301.cc
  Startup system software:                   flash:/s2352_s3352-v100r003c00spc301.cc
  Next startup system software:              flash:/s2352_s3352-v100r003c00spc301.cc
  Startup saved-configuration file:          flash:/vrpcfg.cfg
  Next startup saved-configuration file:     flash:/vrpcfg.cfg
  Startup license file:                      NULL
  Next startup license file:                 NULL
  Startup patch package:                     NULL
  Next startup patch package:                NULL
</pre>
<p>Delete the old firmware:</p>
<pre>delete flash:/SV100R002C02B181SPC001_for_2352_3352.cc
</pre>
<p>But after deleting the file you can see that the usage of flash is still the same &#8211; after deleting the old firmware, it is just send to recycle bin <img src='http://blog.webdir.bg/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<pre>reset recycle-bin
Squeeze flash:/SV100R002C02B181SPC001_for_2352_3352.cc ?[Y/N]:y
Clear file from flash will take a long time if needed...
Jan  1 2008 01:32:45 huawei-iz-bl74 %%01VFS/4/RST_RECYCLE(l): When deciding whether to permanently delete file flash:/SV100R002C02B181SPC001_for_2352_3352.cc, the user chose Y ...Done!.
%Cleared file flash:/SV100R002C02B181SPC001_for_2352_3352.cc
dir flash:
Directory of flash:/

   0   -rw-    107176  Jan 01 2008 00:00:51   matnlog.dat
   1   -rw-        60  Jan 01 2008 00:06:39   $_patchstate_a
   2   -rw-     10668  Jan 01 2008 01:01:53   vrpcfg.cfg
   3   -rw-       684  Jan 01 2008 00:33:20   hostkey
   4   -rw-       540  Jan 01 2008 00:33:28   serverkey
   5   -rw-   7236892  Jan 01 2008 00:15:31   s2352_s3352-v100r003c00spc301.cc
   6   -rw-        28  Jan 01 2008 00:42:31   private-data.txt
   7   -rw-         4  Jan 01 2008 00:07:35   notilogindex.txt

14632 KB total (7404 KB free)
</pre>
<p>If someone is looking for latest release of Huawei Quidway S2352P-EI ( Basic  BOOTROM  Version :  209 Compiled at Nov  4 2009, 14:50:43, Software Version : VRP (R) Software, Version 5.30 (S2300 V100R003C00SPC301) ) contact me : nyck [at] tvskat [dot] net</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webdir.bg/how-to-upgrade-huawei-quidway-s2300-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Huawei Quidway enable ssh</title>
		<link>http://blog.webdir.bg/huawei-quidway-enable-ssh/</link>
		<comments>http://blog.webdir.bg/huawei-quidway-enable-ssh/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 09:22:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Huawei]]></category>
		<category><![CDATA[Configure]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.webdir.bg/?p=279</guid>
		<description><![CDATA[Configure (enable) SSH server on Huawei Quidway switch]]></description>
			<content:encoded><![CDATA[<p>To enable ssh service on Huawei Quidway switch, generate rsa local public key pairs:</p>
<pre>&lt;Quidway&gt;system-view
Enter system view, return user view with Ctrl+Z.
[Quidway]rsa local-key-pair create
The key name will be: Quidway_Host
The range of public key size is (512 ~ 2048).
NOTES: If the key modulus is greater than 512,
 It will take a few minutes.
Input the bits in the modulus[default = 512]:1024
Generating keys...
......................................++++++
.....++++++
..++++++++
.........++++++++

[Quidway]
</pre>
<p>Create username and password:<span id="more-279"></span></p>
<pre>system-view
Enter system view, return user view with Ctrl+Z.
[Quidway]aaa
[Quidway-aaa]local-user root password cipher YourPassword
[Quidway-aaa]local-user root level 15
[Quidway-aaa]local-user root service-type ssh telnet
[Quidway-aaa]quit
[Quidway]
[Quidway]display current-configuration configuration aaa
#
aaa
 local-user root password cipher XXXXXXXXX
 local-user root service-type terminal ssh
 authentication-scheme default
 #
 authorization-scheme default
 #
 accounting-scheme default
 #
 domain default
 #
#
</pre>
<p>Configure SSH server:</p>
<pre>[Quidway]stelnet server enable
Info:Start STELNET server
[Quidway]ssh user root authentication-type password
Info:A new ssh user added
[Quidway]ssh user root service-type stelnet
</pre>
<p>Configure virtual user terminal interface:</p>
<pre>[Quidway]user-interface vty 0 4
[Quidway-ui-vty0-4]authentication-mode aaa
[Quidway-ui-vty0-4]protocol inbound ssh
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.webdir.bg/huawei-quidway-enable-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cisco ME3400 UNI/NNI Port Types</title>
		<link>http://blog.webdir.bg/cisco-me3400-uni-nni-port-types/</link>
		<comments>http://blog.webdir.bg/cisco-me3400-uni-nni-port-types/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 09:54:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cisco]]></category>

		<guid isPermaLink="false">http://blog.webdir.bg/?p=255</guid>
		<description><![CDATA[Cisco ME 3400 series switches are designed to meet the needs of Metro service providers. Introduce brand new concept and features to make the product easier to manage, deploy, and troubleshoot. One of new features is the new concept of UNI/NNI Port Types.

UNI &#8211; User Network Interface
NNI &#8211; Network Node Interface

Based on the port type, [...]]]></description>
			<content:encoded><![CDATA[<p>Cisco ME 3400 series switches are designed to meet the needs of Metro service providers. Introduce brand new concept and features to make the product easier to manage, deploy, and troubleshoot. One of new features is the new concept of UNI/NNI Port Types.</p>
<ul>
<li>UNI &#8211; User Network Interface</li>
<li>NNI &#8211; Network Node Interface</li>
</ul>
<p>Based on the port type, certain features/behaviors are enabled or disabled to ease configuration, deployment, and troubleshooting.</p>
<p>UNI ports will not do local switching by default,  for example no local switching on UNI protects customers from each other ( host A dosn&#8217;t see host B ), and Control Plane Security  (CPS) is enabled, CPS protects against DoS attacks.</p>
<p>By default UNI ports:</p>
<ul>
<li><strong>not switching local traffic</strong>, for example no local switching on UNI protects customers from each  other ( host A dosn&#8217;t see host B ).</li>
<li>Control Plane Security  (CPS) is enabled, CPS protects against DoS  attacks.</li>
<li>using multiple UNI ports on the same ME 3400, up to 8 UNI ports <strong><a href="#wp1">can be configured to do local switching.</a></strong></li>
</ul>
<p>NNI ports:</p>
<ul>
<li>For ME 3400-24TS, by default, the 2 SFP ports are NNI port-type</li>
<li>For ME 3400G-12CS and ME 3400G-2CS, by default, the SFP-only ports are NNI port-type</li>
<li>There can be a maximum of <strong>4 ports defined as NNI ports</strong> (applicable to ME 3400-24TS and ME 3400G-12CS, all 4 ports can be configured as NNI on ME 3400G-2CS)</li>
</ul>
<p><strong>NOTE</strong>: In 12.2(25)SEG and later releases—Metro IP Access Image, all ports can be optionally configured as NNI (<strong>not limited to 4</strong>).</p>
<p><a class="thickbox" href="http://blog.webdir.bg/wp-content/uploads/2010/02/me3400.png"><img class="aligncenter size-full wp-image-260" title="me3400" src="http://blog.webdir.bg/wp-content/uploads/2010/02/me3400.png" alt="me3400" width="389" height="75" /></a></p>
<p>To configure port type:</p>
<pre>me3400#conf t
me3400(config)#int gi0/10
me3400(config-if)#port-type ?
  nni  Set port-type to NNI
  uni  Set port-type to UNI</pre>
<p style="text-align: center;"><a name="wp1"></a></p>
<h2 style="text-align: center;">Configuring UNI ports to do local switching (forwarding traffic between UNI ports)</h2>
<p>Port Gi0/1 and Gi0/2 on Cisco me3400-12G are UNI ports, belongs to VLAN 2000, and Gi0/1 is not forwarding traffic to Gi0/2, and vice versa, but we wand to do local switching between them. Configuration:</p>
<pre>me3400(config)#vlan 1000
me3400(config-vlan)#uni-vlan community</pre>
<p>to be continued &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webdir.bg/cisco-me3400-uni-nni-port-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu Linux and Cisco switch link aggregation (load balancing, bonding)</title>
		<link>http://blog.webdir.bg/ubuntu-linux-and-cisco-switch-link-aggregation-load-balancing-bonding/</link>
		<comments>http://blog.webdir.bg/ubuntu-linux-and-cisco-switch-link-aggregation-load-balancing-bonding/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 15:19:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.webdir.bg/?p=201</guid>
		<description><![CDATA[Tutorial how to balance traffic between Cisco switch 3750 and Ubuntu linux with two NICs, using bonding and port channel interface.]]></description>
			<content:encoded><![CDATA[<p>Link aggregation between Cisco 3750 switch and Ubintu 9.10<br />
Ubuntu configuration:<br />
Install ifenslave — Attach and detach slave network devices to a bonding device.</p>
<pre>apt-get install  ifenslave</pre>
<p>Edit or create file /etc/modprobe.d/aliases.conf</p>
<pre>alias bond0 bonding
options bonding mode=4 miimon=100</pre>
<p>where mode 4 &#8211; IEEE 802.3ad Dynamic link aggregation.  Creates aggregation groups that share the same speed and<br />
duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.<br />
Edit /etc/network/interfaces.</p>
<pre>auto bond0
iface bond0 inet static
        address 192.168.200.5
        netmask 255.255.255.0
        network 192.168.200.0
        broadcast 192.168.200.255
        post-up ifenslave bond0 eth0 eth1
        gateway 192.168.200.1
        dns-nameservers 192.168.200.1
        dns-search example.com</pre>
<p>Cisco configuration ( Gi1/0/1 and Gi1/0/2 will be aggregated ):<span id="more-201"></span></p>
<pre>cisco-3750(config)#interface range GigabitEthernet 1/0/1, GigabitEthernet 1/0/2
cisco-3750(config-if-range)#switchport trunk encapsulation dot1q
cisco-3750(config-if-range)#switchport trunk allowed vlan 10,20
cisco-3750(config-if-range)#switchport mode trunk
cisco-3750(config-if-range)#<strong>channel-group 1 mode active</strong>
<strong>Creating a port-channel interface Port-channel 1</strong>
cisco-3750(config-if-range)#end
cisco-3750#</pre>
<p>Configuration of interface Port-Channel 1 must be exactly the same as Gi1/0/1 and Gi1/0/2.</p>
<pre>cisco-3750#sh ru int Po1
Building configuration...
Current configuration : 159 bytes
!
interface Port-channel1
 switchport trunk encapsulation dot1q
 switchport trunk allowed vlan 10,20
end</pre>
<p>If you want to modify configuration of aggregated interfaces, modify <strong>only configuration of Port-Channel</strong> interface.<br />
And the last step is to set <strong>load-balance</strong> algorithm:</p>
<pre>cisco-3750(config)#port-channel load-balance src-dst-ip
cisco-3750#sh etherchannel load-balance
EtherChannel Load-Balancing Operational State (src-dst-ip):
Non-IP: Source XOR Destination MAC address
  IPv4: Source XOR Destination IP address
  IPv6: Source XOR Destination IP address

cisco-3750#show etherchannel summary
Flags:  D - down        P - in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        U - in use      f - failed to allocate aggregator
        u - unsuitable for bundling
        w - waiting to be aggregated
        d - default port

Number of channel-groups in use: 1
Number of aggregators:           1

Group  Port-channel  Protocol    Ports
------+-------------+-----------+-----------------------------------------------
1      Po1(SU)         LACP      Gi1/0/1(P)  Gi1/0/2(P)

cisco-3750#
cisco-3750#show etherchannel protocol
                Channel-group listing:
                ----------------------
Group: 1
----------
Protocol:  LACP</pre>
<p>Traffic on Gi1/0/1</p>
<p style="text-align: center;"><a class="thickbox" href="http://blog.webdir.bg/wp-content/uploads/2010/01/gi1.png"><img class="size-full wp-image-233 aligncenter" title="gi1" src="http://blog.webdir.bg/wp-content/uploads/2010/01/gi1.png" alt="" width="603" height="242" /></a></p>
<p>Traffic on Gi1/0/2</p>
<p><a class="thickbox" href="http://blog.webdir.bg/wp-content/uploads/2010/01/gi2.png"><img class="aligncenter size-full wp-image-236" title="gi2" src="http://blog.webdir.bg/wp-content/uploads/2010/01/gi2.png" alt="" width="603" height="242" /></a></p>
<p>Traffic on Port-Channel1</p>
<p><a class="thickbox" href="http://blog.webdir.bg/wp-content/uploads/2010/01/po.png"><img class="aligncenter size-full wp-image-237" title="po" src="http://blog.webdir.bg/wp-content/uploads/2010/01/po.png" alt="" width="603" height="242" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webdir.bg/ubuntu-linux-and-cisco-switch-link-aggregation-load-balancing-bonding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cisco &#8220;gbic-invalid error detect&#8221;</title>
		<link>http://blog.webdir.bg/cisco-gbic-invalid-error-detect/</link>
		<comments>http://blog.webdir.bg/cisco-gbic-invalid-error-detect/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 12:57:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cisco]]></category>

		<guid isPermaLink="false">http://blog.webdir.bg/?p=189</guid>
		<description><![CDATA[Using third party SFP on Cisco switches. Cisco undocumented command - "service unsupported-transceiver"]]></description>
			<content:encoded><![CDATA[<p>After  putting SFP in GBIC, Cisco 3750 reports:</p>
<pre>%PM-4-ERR_DISABLE: gbic-invalid error detected on Gi0/2, putting Gi0/2 in err-disable state</pre>
<p>This can happen if you are using  third party SFP (non-cisco). The solution is to use undocumented command.<br />
First enter command:</p>
<pre>no errdisable detect cause gbic-invalid</pre>
<p>and second command:</p>
<pre>service unsupported-transceiver</pre>
<p>There is no autocomplete for this command and no guarantee, but try it &#8230; It works for me on Cisco 3750.<br /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webdir.bg/cisco-gbic-invalid-error-detect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More than two BGP neighbours on Juniper, and routing based on &#8220;Filter-Based Forwarding&#8221;, to control next-hop selection</title>
		<link>http://blog.webdir.bg/routing-based-on-filter-based-forwarding-to-control-next-hop-selection/</link>
		<comments>http://blog.webdir.bg/routing-based-on-filter-based-forwarding-to-control-next-hop-selection/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 15:23:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Juniper]]></category>

		<guid isPermaLink="false">http://blog.webdir.bg/?p=161</guid>
		<description><![CDATA[More than two BGP neighbours on Juniper router, and routing based on “Filter-Based Forwarding”, to control next-hop selection.]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s take a look at the following situation shown on Fig. 1. We have two BGP links with diffrent ISP &#8211; ISP1 ( primary and backup link) and ISP2, so we have actually three BGP links with full Internet routing table. If the three BGP links are active at the same time, the path selection of BGP will depend on the speed of the link, latency of link, IP address of the neighbour ( the higher or lower is IP ).<br />
First we&#8217;ll change the Local Preference of the received routes.<span id="more-161"></span></p>
<table border="0">
<tbody>
<tr>
<td>Fig. 1<a class="thickbox" href="http://blog.webdir.bg/wp-content/uploads/2010/01/fig1.jpg"><img class="alignleft size-thumbnail wp-image-160" title="click to zoom" src="http://blog.webdir.bg/wp-content/uploads/2010/01/fig1-150x150.jpg" alt="" width="150" height="150" /></a></td>
<td>
<pre>[edit policy-options]
show configuration policy-options policy-statement bgp-in

term local_pref_sp1 {
   from neighbor 192.168.1.1;
   then {
          local-preference 160;
  }
}
term local_pref_sp1_backup {
   from neighbor 192.168.2.1;
   then {
          local-preference 150;
  }

term local_pref_sp2 {
   from neighbor 192.168.3.1;
   then {
          local-preference 140;
  }
}
</pre>
</td>
</tr>
</tbody>
</table>
<p>BGP selects the path of route, based on the number of the Local Preference &#8211; the highest number of this parameter wins. In this case traffic will go trough neigbour 192.168.1.1, with the highest number, and traffic will be not forward trough SP2. There is a solution: to make a load balancing between ISP1 and ISP2, or to force some netwroks through ISP2, using Filter-Based Forwarding to control next-hop selection.</p>
<p>To use Filter-Based Forwarding we need routing-instance. A routing instance is a routing entity for a router. According Juniper&#8217;s official documentation you use routnig instances to:</p>
<p>» Create administrative separation in a large network to segregate customer traffic and associated settings. The customers see only the routes belonging to them.<br />
» Create overlay networks in which separate services are routed only towards routers participating in that service, such as voice. The overlay network isolates routes belonging to one service from another service by exporting routes, applying tags, and filtering based on tags.</p>
<p>Configuration of routing instance:</p>
<pre>show configuration routing-instances

isp2-route {
  instance-type forwarding;
  routing-options {
      static {
          route 0.0.0.0/0 next-hop 192.168.3.1;
      }
  }
}
</pre>
<p>Showing new routing table &#8220;isp2-route&#8221;</p>
<pre>root@border# run show route table isp2-route
isp2-route.inet.0: 250 destinations, 250 routes (249 active, 0 holddown, 1 hidden) + = Active Route, - = Last Active, * = Both

0.0.0.0/0 *[Static/5] 08:55:12
               &gt; to 192.168.3.1 via ge-1/3/0.4
10.0.3.0/24 *[Direct/0] 08:55:12
               &gt; via ge-0/1/0.18
10.0.8.0/24 *[Direct/0] 08:55:12
               &gt; via ge-0/1/0.19
</pre>
<p>Now we need to import interface routes into our new routing table. To define the routing tables into which interface routes are imported, we need to create a routing table group and associate it with the router&#8217;s interfaces.</p>
<pre>[edit routing-options]
root@border# show
interface-routes {
   rib-group inet filter-based-forwarding-group;
}
rib-groups {
   filter-based-forwarding-group {
      import-rib [ inet.0 isp2-route.inet.0 ];
   }
}
</pre>
<p>The option &#8220;rib-group&#8221;, basically allows two routing tables to share information. The &#8220;rib-group&#8221; we created, named &#8220;filter-based-forwarding-group&#8221;, exchanges  information between routing table inet.0 and new created table isp2-route from  the routing instance isp2-route.<br />
Fnally we&#8217;ll create the fliter list.</p>
<pre>root@border&gt; show configuration firewall family inet filter sp2-customers
term sp2_customers_networks {
   from {
      source-address {
          10.0.8.0/24;
   }
}
   then {
      routing-instance isp2-route;
   }
}
term default {
      then accept;
}
</pre>
<p>It&#8217;s not necessary to specify the networks going through isp1, and create routing table for isp1, just apply the filter on interface where client from network 10.0.8.0/24 are connected.</p>
<pre>root@border&gt; show configuration interfaces ge-0/1/0.19
description clients_to_sp2;
vlan-id 19;
    family inet {
        filter {
                input sp2-customers;
        }
        address 10.0.8.1/24;
}
</pre>
<p>Configuration of BGP, based on the Filter-Based Forwarding, to control next-hop selection:</p>
<pre>root@border&gt; show configuration protocols bgp
path-selection external-router-id;
import bgp-in;
group ISP_neighbours {
   type external;
   neighbor 192.168.1.1 {
      description ISP1_primary;
      export announce_to_isp1;
      peer-as 65000;
   }
   neighbor 192.168.2.1 {
      description ISP1_backup;
      export announce_to_isp1;
      peer-as 65000;
   }
   neighbor 192.168.3.1 {
      description ISP2;
      export announce_to_isp2;
      peer-as 65000;
   }
}

root@border&gt; show configuration policy-options policy-statement bgp-in
term local_pref_sp1 {
   from neighbor 192.168.1.1;
   then {
      local-preference 160;
   }
}
local_pref_sp1_backup {
   from neighbor 192.168.2.1;
   then {
      local-preference 150;
   }
term local_pref_sp2 {
   from neighbor 192.168.3.1;
   then {
          local-preference 140;
  }
}

root@border&gt; show configuration policy-options policy-statement announce_to_isp1
term 1 {
   from {
       prefix-list to_isp1;
   }
   then accept;
}
term deny {
   then reject;
}

root@border&gt; show configuration policy-options policy-statement announce_to_isp2
term 1 {
   from {
       prefix-list to_isp2;
   }
   then accept;
}
term deny {
   then reject;
}

root@border&gt; show configuration policy-options prefix-list to_isp1
10.0.3.0/24

root@border &gt; show configuration policy-options prefix-list to_isp2
10.0.8.0/24

root@border&gt; show configuration routing-instances
isp2-route {
  instance-type forwarding;
  routing-options {
      static {
          route 0.0.0.0/0 next-hop 192.168.3.1;
      }
  }
}

[edit routing-options]

root@border# show
interface-routes {
   rib-group inet filter-based-forwarding-group;
}

rib-groups {
   filter-based-forwarding-group {
      import-rib [ inet.0 isp2-route.inet.0 ];
   }
}

root@border&gt; show configuration firewall family inet filter sp2-customers
term sp2_customers_networks {
   from {
      source-address {
          10.0.8.0/24;
   }
}
   then {
      routing-instance isp2-route;
   }
}
term default {
      then accept;
}

root@border&gt; show configuration interfaces ge-0/1/0.19
description clients_to_sp2;
vlan-id 19;
    family inet {
        filter {
                input sp2-customers;
        }
        address 10.0.8.1/24;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.webdir.bg/routing-based-on-filter-based-forwarding-to-control-next-hop-selection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux PPPoE Server With RADIUS support</title>
		<link>http://blog.webdir.bg/linux-pppoe-server-with-radius-suuport/</link>
		<comments>http://blog.webdir.bg/linux-pppoe-server-with-radius-suuport/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 09:39:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.webdir.bg/?p=145</guid>
		<description><![CDATA[Read how to install and configure Roaring Penguin PPPoE server, with RADIUS plugin support on Ubuntu 9.10 .]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I&#8217;ll show you how to configure Roaring Penguin PPPoE server, on Ubuntu 9.10 server (amd64). Check if you have PPP development files.</p>
<pre>nas100 ~ # dpkg -l | grep ppp
ii  ppp                               2.4.5~git20081126t100229-0ubuntu2 Point-to-Point Protocol (PPP) - daemon
ii  pppconfig                         2.3.18ubuntu2                     A text menu based utility for configuring pp
ii  pppoeconf                         1.18ubuntu1                       configures PPPoE/ADSL connections</pre>
<p>and install ppp-dev:<span id="more-145"></span></p>
<pre> apt-get install ppp-dev</pre>
<p>Download rp-pppoer server from <a title="rp-pppoe" rel="nofollow" href="http://www.roaringpenguin.com/products/pppoe">http://www.roaringpenguin.com/products/pppoe</a>. Before compiling we need to install gcc:</p>
<pre>apt-get install gcc binutils</pre>
<p>Extract and install rp-pppoe:</p>
<pre>tar xvzf rp-pppoe-3.10.tar.gz
cd rp-pppoe-3.10/src/
 ./configure --enable-plugin
 make &amp;&amp; make install</pre>
<p>Don&#8217;t forget &#8220;&#8211;enable-plugin&#8221; &#8211; this will build pppd plugin.<br />
Now we need radiusclient support:</p>
<pre>apt-get  install radiusclient1</pre>
<p>PPPoE server configuration file ( /etc/ppp/pppoe-server-options ) :</p>
<pre># PPP options for the PPPoE server
# LIC: GPL
require-pap
ms-dns xxx.xxx.xxx.xxx
ms-dns xxx.xxx.xxx.xxx
lcp-echo-interval 10
lcp-echo-failure 5
plugin radius.so
plugin radattr.so
debug
kdebug 1</pre>
<p><strong>require-pap</strong> &#8211; you can use PAP, CHAP or MS-CHAP<br />
<strong>ms-dns</strong> &#8211; sepcify DNS servers<br />
<strong>lcp-echo-interval n </strong>-If  this option is given, pppd will send an LCP echo-request frame to the peer every n seconds.  Normally the peer should respond to the echo-request by sending an echo-reply.  This option can be used with the lcp-echo-failure option to detect that the peer is no longer connected.<br />
<strong>lcp-echo-failure n</strong> &#8211; If this option is given, pppd will presume the peer to be dead if n LCP echo-requests are sent without receiving a valid  LCP  echo-reply.   If  this happens,  pppd  will terminate the connection.  Use of this option requires a non-zero value for the lcp-echo-interval parameter.  This option can be used to enable pppd to terminate after the physical connection has been broken (e.g., the modem has hung up) in situations where  no  hardware  modem control lines are available.</p>
<p>Taken from syslog:</p>
<pre>
Feb  1 07:04:51 hostname pppd[1433]: No response to 5 echo-requests
Feb  1 07:04:51 hostname pppd[1433]: Serial link appears to be disconnected.
Feb  1 07:04:51 hostname pppd[1433]: Connect time 488.3 minutes.
Feb  1 07:04:51 hostname pppd[1433]: Sent 2157465 bytes, received 674186 bytes.
Feb  1 07:04:51 hostname pppd[1433]: sent [LCP TermReq id=0x2 "Peer not responding"]
</pre>
<p>In our configuration lcp-echo-interval is 10 sec. and lcp-echo-failure is 5 packets: if ppp cleint is dead, pppoe-server will disconnect ppp interface after 50 sec.</p>
<p><strong>plugin radius.so , plugin radattr.so</strong> &#8211; load RADIUS plugin and attributes.</p>
<p><strong>kdebug 1- </strong>Enable debugging code in the kernel-level PPP driver.  The argument values depend on the specific kernel driver, but in general a  value  of  1  will enable  general  kernel  debug  messages.</p>
<p><strong>debug -</strong> Enables  connection  debugging facilities.  If this option is given, pppd will log the contents of all control packets sent or received in a readable form.</p>
<p>Now we need ppp radius client support. Install :</p>
<pre>apt-get  install radiusclient1</pre>
<p>Configuration files are located in /etc/radiusclient/ :</p>
<p>First edit /etc/radiusclient/radiusclient.conf :</p>
<pre># General settings
auth_order      radius
login_tries     4 # maximum login tries a user has
login_timeout   60 # timeout for all login tries,  if this time is exceeded the user is kicked out
nologin /etc/nologin
issue   /etc/radiusclient/issue
authserver      xxx.xxx.xxx.xxx # set IP address of RADIUS authentication server
acctserver      xxx.xxx.xxx.xxx # set IP address of RADIUS  accounting server
servers         /etc/radiusclient/servers #  file holding shared secrets used for the communicationclient and server
dictionary      /etc/radiusclient/dictionary
login_radius    /usr/sbin/login.radius
seqfile         /var/run/radius.seq
mapfile         /etc/radiusclient/port-id-map
default_realm
radius_timeout  10 #  time to wait for a reply from the RADIUS server
radius_retries  3
login_local     /bin/login #  program to execute for local login
nas_identifier nas100 # set NAS indentifier name</pre>
<p>The seconf file we need to edit is /etc/radiusclient/servers :</p>
<pre># Make sure that this file is mode 600 (readable only to owner)!
#
#Server Name or Client/Server pair              Key
#----------------                               ---------------

xxx.xxx.xxx.xxx                                     RADIUS_server_secret</pre>
<p>That&#8217;s all, start the server :</p>
<pre>/usr/sbin/pppoe-server -L xxx.xxx.xxx.xxx -I vlan23 -I vlan25 -N 1200 -C rtr-nas100 -S nas100 -T 300 -k</pre>
<p>where:</p>
<p>-I if_name     &#8212; Specify interface (default eth0.)<br />
-T timeout     &#8212; Specify inactivity timeout in seconds.<br />
-C name        &#8212; Set access concentrator name.<br />
-L ip          &#8212; Set local IP address.<br />
-S name        &#8212; Advertise specified service-name.<br />
-N num         &#8212; Allow &#8216;num&#8217; concurrent sessions.<br />
-k             &#8212; Use kernel-mode PPPoE.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webdir.bg/linux-pppoe-server-with-radius-suuport/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compile 32 bit  MySQL C application on 64 bit Ubuntu</title>
		<link>http://blog.webdir.bg/compile-32-bit-mysql-c-application-on-64-bit-ubuntu/</link>
		<comments>http://blog.webdir.bg/compile-32-bit-mysql-c-application-on-64-bit-ubuntu/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 12:59:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.webdir.bg/?p=132</guid>
		<description><![CDATA[How to compile 32 bit application ( using MySQL C API ) on 64 bit Ubuntu. The articles shows step by step, how to install needed libraries.]]></description>
			<content:encoded><![CDATA[<p>I wrote a small program in C, using MySQL C API. This program was compiled on x86 machine. After a hardware upgrade and installing Ubuntu x64, compiling the program error occurred:</p>
<pre>segfault at 1 ip 00007fdcf44f4a29 sp 00007fff19659078 error 4 in libc-2.10.1.so[7fdcf4451000+166000]
</pre>
<p>After a research in diffrent forums, the solution is:<span id="more-132"></span><br />
Install:</p>
<pre>sudo apt-get install libc6-dev-i386
</pre>
<p>Now we need 32 bit version of MySQL development clien library. But there is a small utility, to help install libraries: <strong>getlibs</strong>. Download getlibs-all from <a rel="nofollow" href="http://frozenfox.freehostia.com/cappy/" target="_blank">http://frozenfox.freehostia.com/cappy/</a>.</p>
<pre>sudo  dpkg -i getlibs-all.deb</pre>
<p>32 bit libraries we needed: libmysqlclient-dev and zlib1g-dev.</p>
<pre>getlibs -w http://mirrors.kernel.org/ubuntu/pool/main/m/mysql-dfsg-5.1/libmysqlclient-dev_5.1.37-1ubuntu5_i386.deb</pre>
<p>The version of MySQL server is:</p>
<pre>mysql  Ver 14.14 Distrib 5.1.37, for debian-linux-gnu (x86_64)</pre>
<p>And last libruary:</p>
<pre>getlibs -w http://mirrors.kernel.org/ubuntu/pool/main/z/zlib/zlib1g-dev_1.2.3.3.dfsg-12ubuntu1_i386.deb</pre>
<p><br/><br />
Compiler ( gcc version 4.4.1, x86_64-linux-gnu) command line:</p>
<pre>
gcc -m32 -c radauth.c -L/usr/lib/mysql -lmysqlclient -lnsl -lm -lz
</pre>
<p>m32 &#8211; 32 bit application<br />
m64 &#8211; 64 bit application</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.webdir.bg/compile-32-bit-mysql-c-application-on-64-bit-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cisco backup configuration</title>
		<link>http://blog.webdir.bg/cisco-backup-configuration/</link>
		<comments>http://blog.webdir.bg/cisco-backup-configuration/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 09:28:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[backup config]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[snmp]]></category>

		<guid isPermaLink="false">http://blog.webdir.bg/?p=97</guid>
		<description><![CDATA[Detail tutorial how to automate backup of Cisco switch configuration, using MySQL, SNMP and PERL.]]></description>
			<content:encoded><![CDATA[<p>One simple method to backup Cisco&#8217;s configuration using SNMP and PERL. Download manually  from search.cpan.org  PERL library Cisco::CopyConfig  . Another way of installing:</p>
<pre>perl -MCPAN -e 'install Cisco::CopyConfig'</pre>
<p>Cisco::CopyConfig provides methods for manipulating the running-config of devices running IOS via SNMP directed TFTP. This module is essentially a wrapper for Net::SNMP and the CISCO-CONFIG-COPY-MIB-V1SMI.my MIB schema.<br />
It&#8217;s a good idea to store switch&#8217;s ip address ( if you have more switches ) in database like MySQL. The following perl script uses MySQL database. In MySQL database we store switch&#8217;s ip and snmp community.<br />
MySQL table:<span id="more-97"></span></p>
<pre> CREATE TABLE `sw_backup`.`switches` (
`id` BIGINT( 128 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`description` VARCHAR( 128 ) NOT NULL ,
`ip_address` VARCHAR( 128 ) NOT NULL ,
`community` VARCHAR( 128 ) NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_bin

insert into switches values('','core-switch','192.168.200.251','SNMPconfigCommunity1');
insert into switches values('','access-switch','192.168.200.252','SNMPconfigCommunity2');

mysql&gt; select * from switches;
+----+---------------+-----------------+----------------------+
| id | description   | ip_address      | community            |
+----+---------------+-----------------+----------------------+
|  1 | core-switch   | 192.168.200.251 | SNMPconfigCommunity1 |
|  2 | access-switch | 192.168.200.252 | SNMPconfigCommunity2 |
+----+---------------+-----------------+----------------------+
2 rows in set (0.00 sec)</pre>
<p>We need to istall TFTP server:</p>
<pre>on Debian: apt-get install atftp</pre>
<p>TFTP config file (/etc/default/atftpd):</p>
<pre>USE_INETD=true
OPTIONS="--tftpd-timeout 300 --retry-timeout 5  --maxthread 100 --verbose=5 /backup_switch"</pre>
<p>TFTP working directory is /backup_switch<br />
Configuring Cisco switch ( tested on C2960G, C3750G, 3400G ):<br />
A read-write SNMP community needs to be defined on each device, which allows the setting of parameters to copy or merge a running-config. Below is an example configuration that attempts to restrict read-write access to only the 192.168.200.10 (tftp server) host :</p>
<pre>access-list 70 remark tft-server-list
access-list 70 permit 192.168.200.10
access-list 70 deny   any</pre>
<p>SNMP configuration:</p>
<pre>snmp-server tftp-server-list 70
snmp-server view backup ciscoMgmt.96.1.1.1.1 included
snmp-server community SNMPconfigCommunity1 view backup RW 70</pre>
<p>Variables used in cisco backup script:<br />
/backup_switch &#8211; tftp root directory<br />
/storage/backup/daily/switches/ &#8211; backup directory<br />
Backup script:</p>
<pre class="brush: perl;">
#!/usr/bin/perl
use DBI;
use Cisco::CopyConfig;

my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)=localtime(time);
$year+=1900;
$mon  = sprintf(&quot;%02d&quot;,$mon+1);
$mday = sprintf(&quot;%02d&quot;,$mday);
$hour = sprintf(&quot;%02d&quot;,$hour);
$min  = sprintf(&quot;%02d&quot;,$min);
$sec  = sprintf(&quot;%02d&quot;,$sec);
$date_format=&quot;$mday.$mon.$year&quot;;

$sql=&quot;select ip_address,community,description from switches order by inet_aton(ip_address) asc&quot;;
$dbh = DBI-&gt;connect(&quot;dbi:mysql:sw_backup:xxx.xxx.xxx.xxx&quot;,&quot;username&quot;,&quot;password&quot;) or die &quot;Can't connect to MySQL: $DBI::errstr\n&quot;;
$sth = $dbh-&gt;prepare($sql);
$sth-&gt;execute();

$tftp_address   = '192.168.200.10';

while (@row=$sth-&gt;fetchrow_array) {
 $config     = Cisco::CopyConfig-&gt;new(
 Host =&gt; $row[0],   # host
 Comm =&gt; $row[1], # community
 Tmout =&gt; '10',       # timeout
 Retry =&gt; '2'           # retry
 );

 $tftp_file = &quot;$row[2].$date_format.conf&quot;;

 if ($config-&gt;copy($tftp_address, $tftp_file) ) {
 print &quot;OK -&gt; switch ip: $row[0], file: $tftp_file\n&quot;; }
 else {
 print &quot;ERROR -&gt; switch ip: $row[0], no backup file\n&quot;;
 }

}

system(&quot;mkdir /storage/backup/daily/switches/$date_format&quot;);
system(&quot;cp /backup_switch/cisco-* /storage/backup/daily/switches/$date_format&quot;);
</pre>
<p>Result:</p>
<pre>sns ~ # perl cisco-backup.pl
OK -&gt; switch ip: 192.168.200.251, file: core-switch.19.01.2010.conf
OK -&gt; switch ip: 192.168.200.252, file: access-switch.19.01.2010.conf

sns ~ # tail -n 100 /var/log/syslog | grep tftp
Jan 19 15:56:53 sns atftpd[7848]: Fetching from 192.168.200.251 to core-switch.19.01.2010.conf
Jan 19 15:56:55 sns atftpd[7848]: Fetching from 192.168.200.252 to access-switch.19.01.2010.conf</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.webdir.bg/cisco-backup-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
