Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

So here is the situation, I have people using our service and they have A records in their DNS which point to an IP address that I cannot move to the new server-cluster.

This was an old set up, and moving the servers was never thought of in advance.

So, I have folks out there with A records and Cname records pointing our servers, the Cnames are not a problem, as I'll just update the DNS on our end to send those to the new cluster IP, but the A's are where I am stuck.

Is there a way with my current Centos LAMP set up to keep the old server alive, accept the IP traffic, then force it to the new IP?

THen that would buy me time to migrate everyone to the new (movable) ip ...

Thanks,

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Yup. The easiest way I've done this is with iptables. From:

http://www.simplehelp.net/2009/04/15/how-to-redirect-traffic-to-another-machine-in-linux/

The first step is to set your Linux box to allow this kind of forwarding to take place.

# echo 1 >/proc/sys/net/ipv4/ip_forward

The next step is to tell IPTables to redirect the traffic to the new server:

# iptables -t nat -D PREROUTING -p tcp –dport 80 -j DNAT –to-destination 122.164.34.240

Here’s where the IPTables magic happens. With the third and final step we tell IPTables to rewrite the origin of connections to the new server’s port 80 to appear to come from the old server.

# iptables -t nat -D POSTROUTING -p tcp -d 122.164.34.240 –dport 80 -j MASQUERADE
share|improve this answer
    
That looks too easy! Awesome, I'll set up a couple test cloud boxes to test that out... I was looking at a million and one things from Mod_proxy to crazy redirections... this looks perfect! –  Joe Aug 29 '11 at 2:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.