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

No comments:

Post a Comment