From time to time I come across something truly amazing that I just must share no matter how tired I am. Even though they are typically very simple it helps me remember in the future and I hope it also helps others out wfhen they have the same problems that I do. I recently migrated a server from Slicehost to Linode and I wanted to find a quick and easy way to forward web traffic on various ports to the new server while DNS caught up. The answer was simple… iptables. I found this in an article here.
echo "1" > /proc/sys/net/ipv4/ip_forward iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 1.2.3.4:80 iptables -t nat -A PREROUTING -p tcp --dport 3306 -j DNAT --to-destination 1.2.3.4:3306 iptables -t nat -A POSTROUTING -j MASQUERADE