Skip to main content

Posts

Showing posts from 2008

Route summarization script

I've been searching the internet for a script/program that can automatically summarize CIDR classes that I pass to it. I haven't found one, but I found a perl module ( Net::CIDR::Lite ) that does just this. I wrote a small script that takes the CIDR classes and summarizes them and then outputs the summarized classes. This is useful for generating a routing table for a management server and basically you have to copy the classes from a router, summarize them and paste them on the server. Here's the script - copy/paste it in a perl file and make it executable: #!/usr/bin/perl use strict; use warnings; use Net::CIDR::Lite; my $ipv4String='[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'; if(defined $ARGV[0] && $ARGV[0] eq '-h'){ print "usage: $0 This script summarizes your IP classes (if possible). Input IPs with mask one per line. End with CTRL+D. Optionally, redirect a file to stdin like so: $0 < cidr.txt "; exit; } print "Enter IP/

Editing crontab on Solaris

I wanted to edit the crontab on a Solaris 10 box, but when I tried to execute crontab -e, it didn't take me to the vi editor. This is what I got instead: # crontab -e 434 No matter what I typed, I couldn't use this edit mode. Turns out my terminal wasn't exported properly and vi started in 'one line' mode. Here's how to get the default vi back - you need to have the properly variables set in your shell: # EDITOR=vi # export EDITOR # TERMINAL=xterm # export TERMINAL (for bash). Now, try crontab -e again, and vi should be 'full screen'.

Long delays in mysql because of DNS

Recently I experienced very long delays while connecting to remote mysql databases, without any apparent reason. The connect would stall while connecting, before issuing querries and would wait for about 15-20 seconds before working. I managed to find out why: The mysqld server uses reverse DNS queries to find out the name of the calling host. If the DNS is unavailable at the server side (as was my case), it takes a while for the query to time out. To solve this, you must add your ip and hostname in the /etc/hosts of your mysql server, so it is able to resolve your IP (or get the DNS working). More info here: http://dev.mysql.com/doc/refman/5.0/en/dns.html