Once you do server migration, You will definitively change the DNS records of the domain to the new server IP, But as you know, Such DNS update will take **8-24 hours for the DNS propagation**, and will cause an issue like some users with the old DNS recodrs in the DNS cache will be going to the OLD server it self.
Now, the question is how you can forward the traffic received at your OLD server to your NEW server, so that all your users requests should served by the NEW server Only. Here we are talking about a LAMP server which serves the website on port 80, and mysql on port 3306.
**In this scenario, The old server IP us 22.214.171.124 and the new server IP is 126.96.36.199**
Now, Just you need to apply the following rules on the OLD server IPTABLES chain.
### Run the following from a terminal,
iptables -t nat -A PREROUTING -p tcp -d 188.8.131.52 –destination-port 80 -j DNAT –to-destination 184.108.40.206:80
iptables -t nat -A POSTROUTING -p tcp -d 220.127.116.11 –destination-port 80 -j SNAT –to-source 18.104.22.168“`
iptables -t nat -A PREROUTING -p tcp -d 22.214.171.124 –destination-port 3306 -j DNAT –to-destination 126.96.36.199:3306
iptables -t nat -A POSTROUTING -p tcp -d 188.8.131.52 –destination-port 3306 -j SNAT –to-source 184.108.40.206“`
You are done, Now all the http and mysql traffic coming to the OLD server will be forwarded to the NEW server IP 220.127.116.11
Of course, You can change the Port numbers to any other service, Say you want to redirect email traffic, The you could replace 80 with 25.
Any Questions, Please comment. ![:)](https://www.jobnix.in/wp-includes/images/smilies/icon_smile.gif)