How to change web hosting without breaking DNS

If you’ve ever been tasked with moving a website to a new hosting provider, you have no doubt run into this issue. For those of you considering making a hosting switch, there are a few fundamentals you should understand first.

Imagine the internet as a big library full of books. Each book represents a website, and all of the books have Dewey numbers assigned to them. Think of these like IP addresses. Your website is one of these books. It sits on a shelf (a hosting company’s servers), waiting for someone to come pick it up and read it (browse to it in their browser). Suppose someone only knows the title of a book they want. How do they find it among the millions of other books? They look in the library’s card catalog. Each book has a card in the catalog that lists the book’s Dewey number and where to find the book in the library.  The library’s card catalog is like the Internet’s DNS system. When you try to open an address in your browser, for example “http://google.com”, your computer asks DNS where to find “google.com”. DNS tells your computer the IP address to use to find the site, much like the Dewey number in the library. The simplified conversation looks like this:

Computer->DNS: Hey DNS, I’m trying to find “google.com”, can you help?
DNS->Computer: Sure, you can talk to “google.com” at this address:  74.125.224.128
Computer->74.125.224.128:  Show me “google.com”
74.125.224.128->Computer: Here you go…

Say you decide you want to move a book from its current shelf to a new and better shelf. The Dewey number will change when you do this, so how do you tell the library patrons where to find your book? After you move the book, you would modify the card in the catalog to update the Dewey number. In DNS, this is called an “A record”. It maps the name of the site to an IP address. So to move a site between servers, after the new site is set up, you would change your A record to list the new server’s IP address, In the DNS manager for your domain, you simply change the A record’s old IP address out for the IP address of your new website.

“That’s easy!” you say, but wait! There’s a catch. Imagine our make-believe library now has multiple card catalogs all run by different companies. These catalogs are maintained by web hosting providers, universities, big corporations, ISPs, malicious hackers, you name it. Some of them may contain the same records but with different addresses. So who do you trust to point you to the right catalog and on to the right book? You ask the librarian which card catalog to query. In the same way, a system of root nameservers on the internet serve as the trusted librarian to point you in the right direction. So now, our example from above looks like this:

Computer->Root nameserver: Hey, who should I ask to find “google.com”?
Root nameserver->Computer: You should ask  one of these authoritative name servers: ns1.google.com, ns2.google.com
Computer->ns1.google.com: Where can I find “google.com”?
ns1.google.com->You can find “google.com” at this address: 74.125.224.128
Computer->74.125.224.128: Show me “google.com”
74.125.224.128->Computer: Here you go…

When you purchase a domain from a company like NameCheap, Network Solutions, or GoDaddy, they set up these records for you automatically. The registrars tell the root nameservers to refer any queries for your new domain to their DNS servers, and they host the DNS records for your domain. Perhaps you also purchased hosting from them at the same time. In this case, they will usually create the appropriate DNS records, and your job is done. In many cases, however, you will have purchased hosting from another company (InMotion, Bluehost, FatCow). Some of these hosting companies run their own DNS servers and will try to make your life easier by managing all of your DNS records for you. In this case, you’ll probably need to perform a DNS nameserver update. Proceed with caution!

A DNS nameserver update is how you tell the root nameservers to point to your web host’s DNS servers instead of your current registrar’s servers. Use extreme caution when doing this, because the new DNS records on your new DNS servers likely won’t match what you currently have set up. Consider the following example:

John purchased a domain from NameCheap and is using their nameservers to host his DNS. He runs a small web server from his home, and uses Google gMail for his domain-branded email. He has configured his DNS on NameCheap with an A record pointing to the IP of his home server, and an MX (mail exchange) record pointing to Google’s servers so his email is delivered to gMail. He gets tired of hosting his own server, and decides to purchase hosting from CheapCo Hosting. He signs up, and begins following their instructions on configuring his site and DNS. He completes the instructions, and his new website is running just fine on the new platform. After a few days he realizes he’s not receiving email in his gMail inbox and he starts to panic…

What happened? CheapCo’s instructions were clear and easy to follow, but they led him to peril. You see, many bargain hosting companies package up email, web hosting, and everything else into one simple offering. To make life easy, CheapCo sets all of the DNS records automatically for the sites they host. Their instructions had John update his nameservers to point to CheapCo’s. When he did that, he lost his custom MX record that told everyone on the Internet to deliver email to his gMail account. Instead, his email is now being delivered to CheapCo’s server. What’s worse is that he likely didn’t configure mailboxes on his new hosting account to match his gMail account, so any email that does get to the server is being discarded permanently. John’s two options: attempt to configure his DNS on the new hosting account to match what he previously had, or switch his nameservers back and update only his A record for his website address.

There’s another scenario I haven’t covered, and that’s DNS zone transfers. Suppose you bought a domain from GoDaddy and host DNS with them, but now prefer the prices or management interface of NameCheap. You can transfer the DNS records from GoDaddy to your account at NameCheap, without affecting the underlying A, MX, and CNAME records. The  process varies from registrar to registrar, so make sure to follow each registrar’s instructions closely.

So, to avoid breaking DNS for your domain, be very cautious about changing nameservers unless you know exactly what you’re doing. If you’re not 100% sure, and your employment or well-being depends on your sites being up, ask someone for help before diving in.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.