2009-09-30

FreeBSD - Download ports simultaneously with multiple connections

By default, ports uses 1 connection to download and thus unbearably slow when a server rate limit the connection. Alternatively, we can tell ports to use external utility in order to open multiple connections and download simultaneously.

2009-09-25

vim - Commenting multiple lines, block comment

Perl does not have block comment feature. The Acme::Comment module was the easiest way to make Perl do block commenting, with additional features, it allows customization of open & close punctuation mark.

Until yesterday, my first Perl code got some problem and had to seek help from the IRC channel perl-help @ irc.perl.org (these guys are really helpful, thanks dudes!). Just when they were helping me to solve the problem, Caelum tip me on how to block comment in Perl using vim. I thought it was a good idea as it doesn't need to load additional module to handle the block comment thing, which save some CPU processing.

Here it is :

2009-09-17

Network IP address calculator - for subnet and range of host

One of the task installing a new FreeBSD box was dealing with IP addresses. Usually, google a web based calculator would do the trick. But today's task is a bit different.

IPv6. A whole row of hexadecimal spinning in front of my eyes, just to figure out what is the range of IP that is usable. Web based IP calculator (based on java script) are not accessible using console based internet browser (links & lynx).

Spontaneously, searching the apt repository return some very interesting stuff.

Console based IP calculator. sipcalc.

Not only it is intelligent enough to figure out the input but also it is intelligent enough to generate useful output. Surprisingly, the output is scripting friendly (using grep and sed will parse the output).

These are the steps to install it under FreeBSD & Debian based distribution (e.g. Ubuntu) :

2009-09-14

Perl - How to install Perl module using CPAN shell

One of Perl's strength is it's repository of modules, thousands of modules. No need to re-invent the wheel, just think of what you wanna do and search for it (http://cpan.perl.org).

The CPAN modules are available through the CPAN shell. In this post, we will talk briefly about how to install the CPAN shell and show an example of installing a module.

2009-09-10

The Perl Ironman Challenge

Ironman Challenge. An effort to promote Perl within its community.

Accidentally stumble upon the challenge while searching for Perl's mailing lists and blogs.

I have always wanted to pick up a programming language. To buck up my system administration skill by scripting daily routines and system monitoring. And most importantly, write some web application with this much fascinated programming language that is well known for its TMTOWTDI (There's more than one way to do it !!!) flexibility.

This is my first post on the Ironman Challenge.

Why did I pick up the Challenge? A way to force myself to document what i have learn and also reminder myself to practice more. 1 post every week but no more then 10 days in between. I'll have to cough up with something i've learn, and i must learn. :p

At the same time, hopefully someone can spot what i have been missing or did wrong during my learning process. All constructive comments and suggestion is much appreciated.

Currently, i am working on converting the bash scripts i have, to perl. Reason to do so is getting a chance to familiarize myself with perl, with a goal. With this purpose, at least i don't bang around like a headless fly. Also, i think my bash scripts are some fast & dirty approach to accomplish things, which i think "use strict;" & "use warnings;" can fix/correct most of it. After a few days or so meddling around, manage to try out some condition & loop statements, date/time functions, database connections modules & some array operations. Huh, this is one topic for blogging.

At this stage, I am still trying to get around the documentation, perldoc. Most of the time, i'll be browsing "perldoc perltoc" to find out which functions and/or modules i can use. Still trying to figure out how to search for modules or functions.

CPAN. Comprehensive Perl Archive Network. There's definitely something for me to use, so that i don't have to "re-invent" the wheel. This is another nature of me, laziness. Re-using other people's code not only fulfill my laziness, but also make me write shorter code to accomplish my task.

The next post i will be talking about how to install & use modules.

That's all for now...

Adios !!!

2009-09-06

BIND - name server error "the working directory is not writable"

Recently, there has been a few incident on vulnerabilities of DNS server being exploited. Fortunately, Bind have release patches soon enough for the rest of us to start covering up the loop holes.

After an upgrade or installations of ISC Bind DNS server 9.6 on a FreeBSD box, we will need to stop and start "named" service. As usual, running the below command will restart it :
/etc/rc.d/named stop
/etc/rc.d/named start

During the restart of the service, a few lines of text pops up saying that the permission of some directories in "/var/named" was altered. By default, the named files will need to be owner and group of "bind" in order for it to run properly. But the script in "/etc/rc.d/named" seems to change some directories ownership to "root" and group ownership to "wheel". This actually causes some errors reported in the log file :
Sep  3 02:44:26 nameserver named[9999]: the working directory is not writable

Naturally, we would issued the command :
chown -R bind:bind /var/name/etc

to fix the permission problem. But after another restart of "named" service using the command :
/etc/rc.d/named restart

the permission revert back to "root" and "wheel". This causes problem when the DNS server transfer zone files from the Master DNS server. The "named" service would not be able to write the latest zone info into the file in the directories "/var/named", then it would create some temporary files.

After some investigation, it seems like the ownership define in "/etc/mtree/BIND.chroot.dist" was set in this way. We will need to redefine the ownership of the directories so that it stop changing the directories ownership back to "root" whenever the "named" service is started so that "named" service owner, "bind" user, which runs the DNS server will be able to write the zones files in "/var/named".

2009-09-04

Technorati blog claim fail error

This post is to record how to claim your blog in Technorati. The instruction received was to create a post with the codes provided then the claim process should complete. But it does not. The error below was showed when checking the status :
There was a problem finding your claim code.
If you have already verified above, please contact Technorati support with the following information :

* Please include the following error code: 400
* URL you are claiming : http://scratching.psybermonkey.net
* The name of your blog : Scratching My Needs
* Your contact info : myself@psybermonkey.net
* A short description of your blog and the type of content you like to write about. : This blog is all about Open Source, specifically about Freebsd, Linux and Perl.
* Does your blog have a RSS feed? Please see if you can supply us with an example URL of your feed. : Yes, the url is http://feeds2.feedburner.com/ScratchingMyNeeds

The instruction given from technorati when the codes was provided, did not work. There is a alternative way to claim the blog. That is, create a link on the post with the below html example :

<a href="http://technorati.com/claim/<the blog claim codes>" rel="me">Technorati Profile</a>

Which the "the blog claim codes" is the codes from Technorati, without the angle brackets (<>).

e.g.

<a href="http://technorati.com/claim/abc123xyx" rel="me">Technorati Profile</a>

Technorati should correct its instruction on how to claim the blog. Also, the support should actually buck up. If there wasn't any human(s) behind the support link, don't even put it up there. This confusion wasted 1 week of my time trying all kinds of post with the codes and figuring why the process does not work. Technorati, are you hearing???