June 22nd, 2010 | Tags: ,

As of Apache 1.3, CGI scripts are essentially not buffered. Every time your script does a “flush” to output data, that data gets relayed on to the client. Some scripting languages, for example Perl, have their own buffering for output – 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.
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.
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., “HTTP/1.1″), 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.
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’s looking glass project). The most important lines are from 2 to 5. This script is using “Content-type: text/plain”, if you plan to use html tags chenged to “Content-type: text/html”.
$| – If set to nonzero, forces a flush after every write or print.
Example of nph-realtime-output.pl

#!/usr/bin/perl
print "$ENV{SERVER_PROTOCOL} 200 OK\n";
print "Server: $ENV{SERVER_SOFTWARE}\n";
print "Content-type: text/plain\n\n";
$|=1;
use Net::Telnet;
$login="MyLogin";
$password="MySecret";
$port="23";
$host="xxx.xxx.xxx.xxx";
$command="traceroute www.google.com | no-more";
$telnet = new Net::Telnet;
$telnet->errmode( sub { print "ERROR:" . join('|', @_) . "\n"; } );
$telnet->timeout('10');
$telnet->option_callback( sub { return; } );
$telnet->option_accept(Do => 31);
$telnet->open(Host => $host, Port => $port);
if ($login ne "") {
  $telnet->waitfor('/(ogin|name|word):.*$/');
  $telnet->print("$login");
}
if ($password ne "") {
    $telnet->waitfor('/word:.*$/');
    $telnet->print("$password");
}
$telnet->waitfor(Match => '/.*[\$%>] {0,1}$/',
                 Match => '/^[^#]*[\$%#>] {0,1}$/');
$telnet->telnetmode(0);
$telnet->put(pack("C9",
                  255,                  # TELNET_IAC
                  250,                  # TELNET_SB
                  31, 0, 200, 0, 0,     # TELOPT_NAWS
                  255,                  # TELNET_IAC
                  240));                # TELNET_SE
$telnet->telnetmode(1);
my $telnetcmd = $command;
$telnet->print("$telnetcmd");
$telnet->getline;               # read out command line
while (1) {
  if ($#output >= 0) {
    $_ = shift (@output);
  }
  elsif (! $telnet->eof) {
    my ($prematch, $match) = $telnet->waitfor(Match => '/\n/',
                                              Match => '/[\$%#>] {0,1}$/',
                                              Errmode => "return")
    or do {
    };
    if ($match =~ /[\$%#>] {0,1}$/) {
      $telnet->print("quit");
      $telnet->close;
      last;
    }
    push @output, $prematch . $match;
    next;
  }
  else {
    last;
  }
  print $_;
}
April 13th, 2010 | Tags:

First we need to copy system software to flash via ftp. Configure ftp access to flash:

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

View flash content:

dir flash:
Directory of flash:/
 Read more...
February 18th, 2010 | Tags: , ,

To enable ssh service on Huawei Quidway switch, generate rsa local public key pairs:

<Quidway>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]

Create username and password: Read more…

February 3rd, 2010 | Tags:

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 – User Network Interface
  • NNI – Network Node Interface

Based on the port type, certain features/behaviors are enabled or disabled to ease configuration, deployment, and troubleshooting.

UNI ports will not do local switching by default,  for example no local switching on UNI protects customers from each other ( host A dosn’t see host B ), and Control Plane Security  (CPS) is enabled, CPS protects against DoS attacks.

By default UNI ports:

  • not switching local traffic, for example no local switching on UNI protects customers from each other ( host A dosn’t see host B ).
  • Control Plane Security  (CPS) is enabled, CPS protects against DoS attacks.
  • using multiple UNI ports on the same ME 3400, up to 8 UNI ports can be configured to do local switching.

NNI ports:

  • For ME 3400-24TS, by default, the 2 SFP ports are NNI port-type
  • For ME 3400G-12CS and ME 3400G-2CS, by default, the SFP-only ports are NNI port-type
  • There can be a maximum of 4 ports defined as NNI ports (applicable to ME 3400-24TS and ME 3400G-12CS, all 4 ports can be configured as NNI on ME 3400G-2CS)

NOTE: In 12.2(25)SEG and later releases—Metro IP Access Image, all ports can be optionally configured as NNI (not limited to 4).

me3400

To configure port type:

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

Configuring UNI ports to do local switching (forwarding traffic between UNI ports)

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:

me3400(config)#vlan 1000
me3400(config-vlan)#uni-vlan community

to be continued …

February 2nd, 2010 | Tags: ,

Link aggregation between Cisco 3750 switch and Ubintu 9.10
Ubuntu configuration:
Install ifenslave — Attach and detach slave network devices to a bonding device.

apt-get install  ifenslave

Edit or create file /etc/modprobe.d/aliases.conf

alias bond0 bonding
options bonding mode=4 miimon=100

where mode 4 – IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and
duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.
Edit /etc/network/interfaces.

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

Cisco configuration ( Gi1/0/1 and Gi1/0/2 will be aggregated ): Read more…

January 29th, 2010 | Tags:

After putting SFP in GBIC, Cisco 3750 reports:

%PM-4-ERR_DISABLE: gbic-invalid error detected on Gi0/2, putting Gi0/2 in err-disable state

This can happen if you are using third party SFP (non-cisco). The solution is to use undocumented command.
First enter command:

no errdisable detect cause gbic-invalid

and second command:

service unsupported-transceiver

There is no autocomplete for this command and no guarantee, but try it … It works for me on Cisco 3750.

January 26th, 2010 | Tags:

Let’s take a look at the following situation shown on Fig. 1. We have two BGP links with diffrent ISP – 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 ).
First we’ll change the Local Preference of the received routes. Read more…

January 25th, 2010 | Tags:

In this tutorial I’ll show you how to configure Roaring Penguin PPPoE server, on Ubuntu 9.10 server (amd64). Check if you have PPP development files.

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

and install ppp-dev: Read more…

January 21st, 2010 | Tags:

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:

segfault at 1 ip 00007fdcf44f4a29 sp 00007fff19659078 error 4 in libc-2.10.1.so[7fdcf4451000+166000]

After a research in diffrent forums, the solution is: Read more…

January 19th, 2010 | Tags: , , , ,

One simple method to backup Cisco’s configuration using SNMP and PERL. Download manually  from search.cpan.org  PERL library Cisco::CopyConfig  . Another way of installing:

perl -MCPAN -e 'install Cisco::CopyConfig'

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.
It’s a good idea to store switch’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’s ip and snmp community.
MySQL table: Read more…