Saturday, June 20, 2009

Minimize Downtime(DNS propagation) using tcp packet forwarding using TCPPROXY

A TCP proxy is a server that acts as an intermediary between a client and another server, called the destination server. Clients establish connections to the TCP proxy server, which then establishes a connection to the destination server. The proxy server sends data received from the client to the destination server and forwards data received from the destination server to the client.

It can be used to forward all the tcp connections to another ports in another server. This can be very effective during server migration time when we may face downtime due to DNS propagation delay. The DNS update in the nameservers will sometimes take more than 24 hours to fully propagate in the internet and as a result all the requests from the nameservers that are not updated will be accessing the old server. The old server might be either not accessible or showing old contents or we may be updating the old server with new data. This is especically critical when it comes to emails. We may sent emails to the wrong server which may become unavailable.

In these kind of circumstances we can initiate a forwarding setting which will forward all the requests that were sent to the old server to be forwarded to the new server. This can be accomplished by many free softwares licensed by GPL. In my case I used TCPPROXY a C++ application simple to install and setup as a proxy.

Installation and setup of tcpproxy for redirecting all traffic to another server


tar zxf tcpproxy-2.0.0-beta15.tar.gz

cd tcpproxy-2.0.0-beta15

make all

Setup tcpproxy as a proxy:

Suppose I have a old server and new server then I will have to forward all http requests to port 80 in old server to port 80 in new server. This can be accomplished using the command in the old server.

tcpproxy -b 80

General syntax:

Whatever maybe the service that you are using the general syntax would be

tcpproxy -b source port destination server:destination port

Suppose I want to use SMTP then the syntax would be

tcpproxy -b 25

Service not supported:

* FTP is not supported because it uses a second TCP connections for data transmission

Wednesday, June 10, 2009

Xen with grub2

This is small article to configure xen boot in grub2. First install xen in the machine using yum. I used centos and hence used yum to install it.

yum install xen virt-manager kernel-xen

Now xen and xen kernel is installed in the machine. Now you have to configure grub2 to recognize xen.

In my case I installed xen in another partition other than boot partition. My centos was in /dev/sda1 and boot partition was /dev/sda4

I had to mount that partition and configure the grub configuration to recognize XEN.

mount /dev/sda4 /test
vi /test/boot/grub/grub.cfg

Add the following lines to the end of the configuration.
menuentry "CentOS (2.6.18-128.1.10.el5xen)"{
set root=(hd0,1)
multiboot /xen.gz-2.6.18-128.1.10.el5
module /vmlinuz-2.6.18-128.1.10.el5xen ro root=LABEL=/ rhgb quiet
module /initrd-2.6.18-128.1.10.el5xen.img

Now the xen kernel will be available in the grub 2 menu.