Sumatera shaken by earthquake

A strong earthquake measuring 7.6 on the Richter scale rocked Sumatra at 5.16 pm Western Indonesian Standard Time.The earthquake occurred at 5.16 pm with its epicenter in West Sumatra at 0.84 degrees southern latitude, 99.65 degrees eastern longitude at a depth of 71 km below sea level.It was about 78…

gethostbyname() vs getaddrinfo()

In IPv4 environment(usually) we used to call function gethostbyname() to do DNS lookups.then the information is load into a struct hostent.

#include <netdb.h>
struct hostent *gethostbyname(const char *name);

struct  hostent {
        char    *h_name;        /* official name of host */
        char    **h_aliases;    /* alias list */
        int     h_addrtype;     /* host address type */
        int     h_length;       /* length of address */
        char    **h_addr_list;  /* list of addresses from name server */
};
#define h_addr  h_addr_list[0]  /* address, for backward compatibility */

So, the easiest way to get information from gethostbyname() call is by extracting hostent structure.

Using VIM as stream editor

Every person associated with the unix / linux would be familiar with the text editor called vi / vim. but not many people know that vi / vim can be used as a stream editor. This is one example of how to use vi / vim as a text editor.…

vmware ESXi 4 + centos 5.3 guest OS + zimbra

I’ve been playing around with Zimbra opensource edition on my development server. Zimbra is a full-featured, open source collaboration suite for  email, group calendaring, contacts, and web document management and authoring. web interface is equipped with AJAX and it is compatible with clients such as Outlook, Apple Mail, and Novell Evolution so that mail, contacts, and calendar items can be synchronised from these to the ZCS server. It also can be synchronized to many mobile devices. ZCS makes use of many existing open source projects such as Postfix, MySQL, and OpenLDAP.

In this experiment i was using Zimbra 64bit_x86 opensource edition

DNs setting

mail.domain.tld.        A    192.168.1.2
domain.tld.             MX   10    mail.domain.tld.

Download the installer

# wget http://h.yimg.com/lo/downloads/6.0.1_GA/zcs-6.0.1_GA_1816.RHEL5_64.20090911174852.tgz

Extract the installer tarball, make sure we have enough space.

# tar xvzf  6.0.1_GA/zcs-6.0.1_GA_1816.RHEL5_64.20090911174852.tgz
# cd zcs-6.0.1_GA_1816.RHEL5_64.20090911174852

Querying Visitor IP address

There are many ways, scripting/language to obtain remote IP address of the user who is browsing our website.

PERL

#!/usr/bin/perl
use CGI;
print "Content-type: text/plain; charset=iso-8859-1\n\n";
my $q = new CGI;
print "<b>Your Remote IP Address :" . $q->remote_host() . "</b>";

PHP

<?php
echo "<b>Your Remote IP Address :" . $_SERVER['REMOTE_ADDR'] . "</b>";
?>

Setup Google Apps For your Personal eMail

I was realy surprised on how easy it was to set up hosting using google apps. Fisrt of all, all we need is just go here and fill out the application.

if you’re using it for family, private user or non-profit organisation google apps is freely to use. Of course we can Upgrade to Google Apps Premier Edition for bigger storage at 25 GB per user.

The first step of the application is to enter your domain name, if you already have one. Or you can buy a new domain name through Google which automatically sets everything up for you.

 

Securing MySQL traffic with stunnel

To encrypt a connection between a mysql client and a mysql server, run two instances of stunnel, one on client site and other on MySQL remote site

Here’s steps how to do it

# wget http://www.stunnel.org/download/stunnel/src/stunnel-4.27.tar.gz
# rpmbuild -ta stunnel-4.27.tar.gz
# rpm -ivh /usr/src/redhat/RPMS/stunnel-4.27-1.i386.rpm

Create stunnel.pem cert on server site

# openssl genrsa -out privkey.pem 2048
# openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
# cat privkey.pem cacert.pem >> /etc/stunnel/stunnel.pem

Set the proper permissions on the resulting private key:

# chmod 0400 /etc/stunnel/stunnel.pem

Set the proper ownership of the stunnel chroot dir

# chown nobody:nobody /var/run/stunnel

Defining delegated route /48 from Hurricane Electric in Appropriate way.

I’ve been thinking on how to create reverse zone for /64 subnet from delegated routed /48 from Hurricane Electric. First when i was first time request delegation for routed /48 i’ve defined this configuration on my nameservers

In named.conf

zone "7.e.8.f.0.7.4.0.1.0.0.2.ip6.arpa" {
type master;
file "reverse-2001-470-f8e7_48.IP6.ARPA";
};

Sending HTML mail via sendmail cli

Here’s how to do it

# ( cat <<HEADERS; cat /root/file.html) | sendmail -oi -t
From: sender@domain.tld
To: recipients@domain.tld
Subject: we send HTML instead of plain text
Mime-Version: 1.0
Content-type: text/html
Content-transfer-encoding: 8bit

HEADERS <- type CTRL+D then press ENTER

We should set Mime-Version , Content-Transfer-Encoding and Content-Type headers properly. The issue of correct MIME transfer encoding is one of the many possible complexities which is simply ignored here.