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 184.108.40.206 and the new server IP is 220.127.116.11**
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 18.104.22.168 –destination-port 80 -j DNAT –to-destination 22.214.171.124:80
iptables -t nat -A POSTROUTING -p tcp -d 126.96.36.199 –destination-port 80 -j SNAT –to-source 188.8.131.52“`
iptables -t nat -A PREROUTING -p tcp -d 184.108.40.206 –destination-port 3306 -j DNAT –to-destination 220.127.116.11:3306
iptables -t nat -A POSTROUTING -p tcp -d 18.104.22.168 –destination-port 3306 -j SNAT –to-source 22.214.171.124“`
You are done, Now all the http and mysql traffic coming to the OLD server will be forwarded to the NEW server IP 126.96.36.199
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)