60

I'm moving my web application to another server and in the next few days I'll refresh the DNS to point to the new IP location.

Unfortunately some browsers and SOs keep a DNS cache that will make users point to the old IP location. Some users are rookies and they'll not refresh the DNS cache manually and I know we'll lose a lot of them in the first weeks after this change.

Is there anyway to force this DNS cache to refresh so it'll be transparent for our final users?

Adriano Castro
  • 1,411
  • 4
  • 19
  • 33

5 Answers5

50

As far as I know, a forced update like this is not directly possible. You might be able to reduce the DNS downtime by reducing the TTL (Time-To-Live) value of the entries before changing them, if your name server service provider allows that.

Here's a guide for less painful DNS changes.

A fair warning, though - not all name servers between your client and the authoritative (origin) name server will enforce your TTL, they might have their own caching time.

positivew
  • 700
  • 7
  • 14
16

There's no guaranteed way to force the user to clear the DNS cache, and it is often done by their ISP on top of their OS. It shouldn't take more than 24 hours for the updated DNS to propagate. Your best option is to make the transition seamless to the user by using something like mod_proxy with Apache to create a reverse proxy to your new server. That would cause all queries to the old server to still return the proper results and after a few days you would be free to remove the reverse proxy.

Jammerx2
  • 794
  • 4
  • 12
  • The closest option would be a 301 Redirect Moved Permanently, which only really applies with a domain switch. You can't force a user to clear the DNS cache, and in many cases they couldn't even if they wanted to (as ISPs cache as well). If you can the best option I can see is to temporarily reverse proxy from the old server to the new one so all queries to that domain will be sent to the new server. – Jammerx2 Jan 13 '14 at 12:48
  • 13
    Another good idea would be to lower the TTL on the DNS a few days before you make the change. This will cause ISPs to check for updates the the DNS more frequently so the migration will go smoother. You should set the TTL to the lowest possible value (and then increase it again a while after the change has been made). – Jammerx2 Jan 13 '14 at 12:57
12

you can't force refresh but you can forward all old ip requests to new one. for a website:

replace [OLD_IP] with old server's ip

replace [NEW_IP] with new server's ip

run & win.

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

iptables -t nat -A PREROUTING -d [OLD_IP] -p tcp --dport 80 -j DNAT --to-destination [NEW_IP]:80

iptables -t nat -A PREROUTING -d [OLD_IP] -p tcp --dport 443 -j DNAT --to-destination [NEW_IP]:443

iptables -t nat -A POSTROUTING -j MASQUERADE

  • 1
    If you don't have access to your DNS' TTL (which with many hosted servers is the case), this is a perfect solution -- if the old server does not need to have a Webserver on Port 80 still running... – Rainer Keller Aug 29 '17 at 17:51
  • how can I revert this? – Stephan Hoyer Dec 03 '20 at 23:42
  • Isn't it easier to modify your hosts.conf file, and, in case of using a computer doing NAT, install there a DNS server and, again, modify the hosts.conf? – Rastersoft Jan 11 '21 at 11:52
0

So if the issue is you just created a website and your clients or any given ISP DNS is cached and doesn't show new site yet. Yes all the other stuff applies ipconfig reset browser etc. BUT here's an Idea and something I do from time to time. You can set an alternate network ISP's DNS in the tcpip properties on the NIC properties. So if your ISP is say telstra and it hasn't propagated or updated you can specify an alternate service providers dns there. if that isp dns is updated before your native one hey presto you will see new site.But there is lots of other tricks you can do to determine propagation and get mail to work prior to the DNS updating. drop me a line if any one wants to chat.

-1

It might be possible to delete the Zone Record entirely, then recreate it exactly as you want it. Perhaps this will force a full propagation. If I'm wrong, somebody tell me and I'll delete this suggestion. Also, I don't know how to save a Zone Record and recreate it using WHM or any other tool.

I do know that when I deleted a hosting account today and recreated it, the original Zone Record seemed to be propagated instantly to a DNS resolver up the line from my computer. That is good evidence it works.

David Spector
  • 1,520
  • 15
  • 21