mattgadient.com

Nameservers, DNS, CPanel/WHM, VPS’s and addon domains (oh my!)

I recently pulled my sites off of a shared host and onto a VPS.  If you’re like me and the extent of your linux knowledge is “I know how to set up an .htaccess file”, then you just might be in for a few days of banging your head against the wall.

I know I sure was.

My VPS was through VPSlink, and I kid you not – I went through at least 5 reinstalls of CentOS and WHM/Cpanel per day for 3 days because something wasn’t working right each time (hangs on “Updating IP list from WHOIS database” in WHM for example) and I was convinced things were broken beyond repair.

The big problem was that I had tossed the basic understanding of DNS I had out the window.

 

Here’s what I had managed to believe: It’s in red, because it’s wrong

  • That I needed DNS servers on my VPS because I had multiple domains.
  • That the name servers on my VPS were the method that allowed my mutiple sites to share the same IP address – that without them, every site URL would go to the same public_html directory (effectively all pointing to one site)

Why did I believe this? Quite a few reasons including the following;

  • lack of knowledge – I’d spent a lot of time reading up beforehand, but it still wasn’t enough to prepare me completely for the step from shared to VPS.
  • learning a lot at once – I’ll go into details in another post, but I absorbed more information in 3 days then I had all year.
  • lack of guides – There’s info out there, but it’s very scattered. A “VPS for dummies” book would be great, although with all the different VM’s, Linux distros (not not mention Windows), control panels, hosts, etc, it would have to be one mighty thick book, or be named something like “VPS’s on VPSLink using CentOS 5.2 and WHM/CPanel through Xen for Dummies”.  I know…. Not gonna happen.

 

In any case, In regards to that particular problem, here’s the shining realization I needed to come to:

  • DNS nameservers are not required to be hosted on the VPS.
  • Many VPS hosts (such as VPSLink) will let you use their nameservers. Simply set up all your gagillion websites in their own built-in control panel to point at your IP address. This is perfectly fine. Domain providers may offer the same (namecheap does for example). Use them instead if you prefer.
  • Again, all you really have to do is point all your websites at your 1 IP.
  • You may very well not need to even set up BIND or NSD (or any of the others) on your server. It’s worth noting I haven’t played with having both actually disabled though, and I’ve heard that CPanel tends to like one of them there, so I’d keep ’em. Just don’t feel like you’ve gotta actually use them.
  • Figuring out what URL shows what website is up to the webserver (Apache for example). As long as www.MYWEBSITE.com is being pointed to your IP, it takes care of the rest.
  • The webserver has it’s OWN file (apache’s is called httpd.conf for example) that “keeps track” of what website “becomes” what directory on the server. In fact, if you’re using CPanel, you’ll probably never even have to touch or manually edit that file. Every time you add an account, addon domain, or subdomain, it automatically fills in those entries for you behind the scenes.

I split those up into 2 colors because I was effectively believing that the DNS server did all of that, when really it’s split up between 2 entirely different things.

——-sidenote——

If you’re absolutely determined to set up your own DNS servers, by all means, go ahead. If you only own 1 VPS though, it’s probably not the greatest idea though. Here’s why:

When a DNS lookup happens, the result is usually cached. This means if your site ever goes down (or you restart it), if something or someone tries to do a DNS lookup, it’s going to fail and that failed result may be cached for a long period of time. This is bad because the failed result basically says “I didn’t find the DNS server, so I don’t know the IP address” and even if your site was only down for a few seconds, people go for up to 24-48 hours without being able to access your site because the cached result doesn’t have your IP. On the other hand, if your DNS records are hosted elsewhere, (assuming a reliable DNS host) you can let your site go up-and-down like crazy – when it’s down for 20 seconds, it won’t mess up anyone’s DNS cache, and the moment you’re back up, people will be able to get on.

I’ll leave you with this….

If you really want your own name servers, do them on a separate server that *only* does DNS. Better yet, do them on 2 different servers – that way, even if 1 goes down, hopefully the other is still up and DNS lookups will resolve properly. Remember, because DNS results are cached, reliability is important. If you’re reselling, this is really your only viable option if you want to be known as a reliable host (unless you can somehow guarantee your VPS stays up 100% of the time).

If you’re intent on keeping your own name servers on your 1 VPS, do yourself a favor – look around the web for free (or paid) DNS hosting and set up some backup DNS servers (remember to setup all your domains with the DNS host, and include those extra nameservers in your DOMAIN host/provider’s setup for each domain you own though!). That way, if there’s an attempt to pull your DNS info and your own ns1 and ns2 are down, the others should be able to fill in.

  • Kevin

    Great stuff. I have been searching all over for this type of info. Just got a VPS myself and I can certainly understand the ‘banging your head against the wall’ part. Thanks for the info.

  • Joel

    # Figuring out what URL shows what website is up to the webserver (Apache for example). As long as www. MYWEBSITE.com is being pointed to your IP, it takes care of the rest.

    Thank you! Just what I needed to know! This article has been very helpful, and I’m glad I’m not the only one who needs a reinstall when getting started on a VPS.

  • Nick Bignell

    I think I’m just as confused as you were when you started, think you can give me a hand setting this up? I’ve got 3 IP addresses attached to my NIC but thats as far as I can get.