LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Handle DNS properly with cPanel

lowendtutorial

After a couple of very busy weeks (got married, went on our honeymoon and took over from Liam) it’s finally time for a tutorial again! The tutorials are going to be released in a more natural flow now. Saturday will not always be tutorial day any longer.

So, on-topic! cPanel is a well-known, almost de-facto standard, hosting control panel. Most shared hosting providers use it, but it’s also popular amongst people that either want to run their own server but don’t have the technical knowledge to do everything on the CLI or by people that want to give people they know easy shared hosting.  With special pricing for VPS, a cPanel license costs about $15. If you’re lucky, your provider can even provide it to you cheaper. The cheapest I have personally seen is $17, for a full 2GB VPS with cPanel included (that’s $10 for the cPanel license)!

But, by using cPanel, a new problem arises: the need for DNS. cPanel includes BIND and other DNS software, but single cPanel user with DNS is a single point of failure. So, the natural choice would be to buy a second server and install cPanel or cPanel DNSONLY. But, with just one secondary DNS server, some other issues may arise: the primary of your cPanel server (which is often used for shared hosting) can get “tainted” and when you want to move your cPanel server, it includes moving your primary DNS as well. All in all, not an ideal combination.

So, my solution to this problem is as follows: get two small VPS and install cPanel DNSONLY on both of them. Then, you get have any number of cPanel servers send over the records to them and you’ve basically got a dedicated DNS cluster. Of course, you can use more than 2 DNS servers (3 is often a recommended minimum). But two is quite common and shouldn’t have to cost too much.

You don’t need heavy hardware for a DNS server. A 128MB VPS should me sufficient for a small to medium DNS cluster. There’s plenty of offers with annual deals for those, so you can get two of such machine for as little as $20-$30/year.

Anyway, on to the good stuff: the installation!

Installing cPanel DNSONLY

cPanel DNSONLY is free and it’s easy to install. It does require CentOS. I would recommend using CentOS 6. A clean install is also recommended.

To download cPanel DNSONLY, run:

wget http://httpupdate.cpanel.net/latest-dnsonly

This should download the installer. It’s quite small. Now, make it executable:

chmod +x latest-dnsonly

And execute it:

./latest-dnsonly

This should run the installer and it should look like this:

root@cpns1_023

Let it run, grab a cup of coffee, walk you dog, go grocery shopping. When you’re back, grab a beer. It should be done by then! Jokes aside: it could take 20-30 minutes depending on the speed of the VPS. Once it’s done, open up your browser and surf to https://YOURIP:2087. This should open the login screen of cPanel.

WHM-Login 2013-10-14 08-28-02

Log in with your root account, which should send you to the setup process.

Web-Host-Manager-11-38-2-7 2013-10-14 08-29-07

First up is accepting the license agreement. Please read this, even though it’s boring. Just like Terms of Service, there’s stuff in there that could be important. Once you find out is actually is important, it’s usually to late. So better read it upfront ;-)

Web-Host-Manager-11-38-2-7 2013-10-14 08-32-20

Next up is some basic configuration and networking setup. Two things that you have to fill out here:

  • Server Contact E-mail Address: this is where cPanel sends notifications, logs, etc.
  • This Server’s Hostname: the hostname of this server

The resolvers should have been filled automatically. If not, find out what your resolvers are and fill out those fields.

Web-Host-Manager-11-38-2-7 2013-10-14 08-33-54

Next, it fives you an overview of IP addresses your server has. Usually it’s just the one and cPanel will use that. Otherwise, you can choose.

Web-Host-Manager-11-38-2-7 2013-10-14 08-34-42

Final step is the name server software selection and configuration. I usually go for BIND here, because it’s the default. I advise you to do the same. Fill out the name servers this server will use (usually the hostname of this server and the hostname of your other DNS server). Optionally, you can add A records for this domain. If you’re planning to use this server as the DNS for the hostname’s domain name, you should do this.

That’s it! Click ‘Finished Setup Wizard’ and you’ll be sent to the WHM interface.

Configure cPanel DNSONLY

Now everything is set up, let’s configure this server as a DNS server for a cPanel server. From the WHM interface, click on ‘Cluster/Remote Access’ and ‘Setup Remote Access Key’. Click ‘Generate new key’ and copy the entire key.

WebHost-Manager-cpns1 2013-10-14 08-38-06

Now, head over to your cPanel server and go to ‘Cluster/Remote Access’ and click on ‘Configure Cluster’. Under ‘Modify Cluster Status’ (which should be disabled) you should click the ‘Enable’ radio button and click ‘Change’. This should enable the DNS clustering.

WebHost-Manager-cpanel 2013-10-14 08-40-27

Now, scroll down. Under ‘Add a new server to the cluster’ you can add a new server. The ‘Backend Type’ should remain cPanel. Click ‘Configure’.

WebHost-Manager-cpanel 2013-10-14 08-40-50

This should open up a new window where you can fill out the details for the new server. Start by filling out the hostname, the username (root) and paste the remote access key we’ve just copied into the field “Remove server access hash”. Also check the box “Setup Reverse Trust Relationship”.

WebHost-Manager-cpanel 2013-10-14 08-56-11

Scroll down again. There should be a select box “DNS Role”. Select “Write-only” here. You do not want to synchronize the changes, but you want changes from your cPanel server to be sent to the DNS server. Not the other way around.

WebHost-Manager-cpanel 2013-10-14 08-56-04

Finally, click ‘Submit’. You’ll get a confirmation message telling you everything has been set up! To check this, go do “Configure Cluster” once more and confirm that everything is good:

WebHost-Manager-cpns1 2013-10-14 08-56-52

And you’re all done! You should do this for your second DNS server exactly the same way. Once you’re done with that, you’ve got a cPanel server with two independent DNS servers!

Final notes

There’s various other configuration options to set up a DNS cluster with cPanel. For instance, you can also use several full cPanel servers with multiple IPs for your DNS cluster. However, the solution of this tutorial is one of the fastest ones in replication terms and gives you most flexibility. Enjoy cPanel!

Up next time: getting started with OpenVZ!

mpkossen

47 Comments

  1. imtiax:

    What is the host that sells 2gb vps with cpanel for 17

    October 19, 2013 @ 1:11 am | Reply
    • Maarten Kossen:

      HighSpeedWeb, check LowEndTalk.com for the offer (it’s in the offer section a couple of pages down I believe).

      October 19, 2013 @ 4:18 am | Reply
      • BlueVM do $10/mo External licenses! so any VM can be used.

        October 19, 2013 @ 12:14 pm | Reply
        • comeback:

          I did not find this offer on the site.

          how to have cpanel for $ 10?

          thank you

          October 26, 2013 @ 11:36 am | Reply
          • I think Hostigation.com does it $10/mo internally and BlueVM.com offers $10/mo external licenses.

            October 26, 2013 @ 11:39 am | Reply
          • DalComp:

            Register and submit a ticket with BlueVM. Last time I checked it’s raised to $11, though.

            October 26, 2013 @ 7:07 pm | Reply
      • I’m curious, what exactly are the differences between Hostigation and HighSpeedWeb?

        October 20, 2013 @ 9:48 pm | Reply
  2. Let say we have the following situation:

    ns1.domain.com – 1 DNSONLY cpanel
    ns2.domain.com – 1 DNSONLY cpanel
    domain.com – main cpanel server

    What happens when the main cpanel server goes down? Does that mean that the ns1 and ns2 will also be down since it is a subdomain (a records in main server) of the main server? Thus the dns cluster won’t work?

    Please enlighten me on this!

    October 19, 2013 @ 1:33 am | Reply
    • Maarten Kossen:

      Then both name servers will keep working. cPanel just pushes the records to the name servers when they change. The name servers save them in order to be able to respond to requests. So, cPanel server down means your DNS cluster is still up :-)

      October 19, 2013 @ 4:19 am | Reply
      • David:

        Can you expand on this? Why would NS1 and NS2 still work? How can they be resolved if domain.com is down? How does my browser find the IP address for a subdomain if the domain is down?

        November 13, 2013 @ 3:58 am | Reply
        • Parth:

          Because your nameserver IP addresses and hostnames are submitted to your domain registrar. It updates the DNS root servers directly with your DNS hostnames’ IP addresses, so even if the server hosting the TLD goes down, access to your DNS servers is unaffected.

          December 13, 2013 @ 2:07 am | Reply
  3. Lucas:

    Not all screenshots may be enlarged, can you please re upload or fix for enlarge?

    October 19, 2013 @ 10:12 am | Reply
    • Maarten Kossen:

      Sorry, having that looked at.

      October 21, 2013 @ 12:45 am | Reply
  4. Tarek:

    why i need to install cpanel-dnsonly on my server ?

    October 19, 2013 @ 1:12 pm | Reply
    • Maarten Kossen:

      Because without additional DNS servers, your cPanel server would be your sole DNS server. In case of downtime, your domain names, MX records, etc. wouldn’t resolve anymore, making your downtime only worse.

      October 21, 2013 @ 12:45 am | Reply
  5. DalComp:

    Heheh, Maarten should have started with cPanel installation, or other tricks related to cPanel. Because cPanel DNS-Only, without a main cPanel server, is useless…

    October 19, 2013 @ 6:52 pm | Reply
    • Maarten Kossen:

      The reason I didn’t do that is that most providers already offer cPanel VPS templates which are optimized and loaded with some proper extensions.

      But, true: without cPanel, cPanel DNSONLY is quite useless :-)

      October 21, 2013 @ 12:44 am | Reply
      • DalComp:

        Nah, most LEB providers only provide initial cPanel template. No optimizations whatsoever.
        Some optimization tips (cPanel or not) would be nice.

        October 21, 2013 @ 7:42 am | Reply
        • Maarten Kossen:

          That should have been: most LEB providers I’ve been with :-)

          October 22, 2013 @ 5:26 am | Reply
  6. black:

    Congrats on the marriage Maarten :)

    October 20, 2013 @ 12:47 am | Reply
    • Maarten Kossen:

      Thanks very much!

      October 21, 2013 @ 12:42 am | Reply
  7. Lost_Packets:

    Images are broken at the top.

    October 20, 2013 @ 2:35 pm | Reply
    • Maarten Kossen:

      Sometimes the images don’t load completely. I’m having that looked at.

      October 21, 2013 @ 12:42 am | Reply
  8. Nice guide Maarten *thumbs up*. Congrats on the marriage as well.

    October 21, 2013 @ 5:00 pm | Reply
  9. In my experience, 128MB is enough RAM to run one of these, but not enough to install it. The installer uses CPAN, which OOMs on 128 MB.

    So there are two choices. One is to use a VPS with 256 MB. You could probably install it, disable MySQL and a few other services you never use (easier than it used to be now we have the RPM system), then downgrade to a 128 MB if the provider allows you to downgrade. (Is that a bit cheeky?!)

    Or, find a provider who offers an OpenVZ template that comes with cPanel DNSOnly pre-installed and optimised to make it fit onto a 128. The only two I know who do this are BuyVM and Server Dragon, but there may be others – there’s certainly a need-case for offering templates like that.

    October 22, 2013 @ 5:16 am | Reply
    • Or use a 128mb RAM & 128mb vSwap VPS?

      October 26, 2013 @ 5:02 am | Reply
      • Maarten Kossen:

        I did indeed use VPS with 128MB vSwap for this.

        October 28, 2013 @ 4:31 am | Reply
    • Chicago VPS has ready containers with cPanel DNS only template. Costs around a $1 a month for their annual package.

      June 10, 2014 @ 6:49 am | Reply
  10. Guest:

    Can i use one cPanel DNSONLY for multiple cPanel Server ? Thanks for answer.

    October 26, 2013 @ 1:33 am | Reply
  11. Mai Danh Hao:

    But I’m looking for a web-base scripts to manage DNS record. Have any solutions?

    October 29, 2013 @ 5:24 am | Reply
  12. How much cPanel DNS-only costs? If it was used for DNS only, it seems cPanel should release it as free product. :)

    November 2, 2013 @ 1:32 am | Reply
  13. cPanel DNS Only is a free product :)

    November 13, 2013 @ 10:49 am | Reply
  14. Lucas:

    What default DNS cPanel login and pass?

    November 19, 2013 @ 4:32 pm | Reply
    • DalComp:

      root and your root password

      November 19, 2013 @ 8:18 pm | Reply
  15. Lucas:

    On final step got a error – The specified IP address would create a cyclic trust relationship: – IP address – whats wrong?

    November 20, 2013 @ 3:35 am | Reply
  16. Just mentioning there’s now a simpler alternative to cPanel’s own DNS clustering. This cPanel plugin replicates to an external, geographically sparse DNS cluster: http://applications.cpanel.net/appcat/buddyns-dns-replication .

    Plugin and replication service are free of charge up to 0.3 Million DNS queries/month.

    February 3, 2014 @ 7:59 am | Reply
  17. DR:

    Michele:
    Just mentioning there’s now a simpler alternative to cPanel’s own DNS clustering. This cPanel plugin replicates to an external, geographically sparse DNS cluster: http://applications.cpanel.net/appcat/buddyns-dns-replication .

    Plugin and replication service are free of charge up to 0.3 Million DNS queries/month.

    February 3, 2014 @ 7:59 am

    What I am wondering is if I can run cPanel DNSONLY on a single VPS and then use BuddyNS DNS replication that Michelle mentions.

    To be specific, there would be no cPanel running a webserver, ONLY cPanel DNSONLY running a standalone DNS server with the web servers located on other machines.

    Will this work? Thanks!

    February 7, 2014 @ 12:35 pm | Reply
    • Hi DR,

      It is easier with a full cPanel server, but, if you know how to edit zone records, you only need cPanel DNSONLY server(s) and don’t need a cPanel server, or BuddyNS DNS replication, etc.

      cPanel DNSONLY does not have a DNS Zone editor, but you can find the DNS Zone files at:

      /var/named (*.db)

      After you edit/add zone files run:

      /scripts/dnscluster

      which will sync the server with the rest of the cluster.

      Run a ‘dig @nsXX.yournameserver.com newdomain.com’ against each of the nameservers in your cluster to verify it worked.

      You might also have to restart the DNS Server (BIND/NSD/MyDNS) to load the changes, but usually not.

      And as an FYI, you should also install ConfigServer Security & Firewall (CSF), or your favorite software providing the same.

      Best,
      Michael

      PS: I don’t actually recommend this, just think about one typo…

      April 28, 2014 @ 1:32 am | Reply
  18. Vizius:

    wondering if there’s advantage of installing cPanel DNS only rather than using external free DNS provider?

    May 24, 2014 @ 10:46 pm | Reply
  19. matt:

    I am running 3 of these servers. The number of domains, is very small, yet currently on 2 servers they are using over 400mb, and on one specific server, (part of the same cluster so no reason why its different) its using 668mb.
    All servers are using the same configuration (centos 6, with CSF installed). I am certain that I can trim the fat and get them down so that I can prolong the need for any upgrades, but I think its important for people to start off with 512 and be prepared to upgrade when they need to.

    I know the guy above says he has done these servers on 128 / 256 mb vps, and while that is possible, realistically a standard out-of-the-box installation for the average joe blo is going to need 512mb vps.

    June 16, 2014 @ 8:11 am | Reply
  20. Hi

    Thanks for the article.
    Can we have multiple Cpanel Servers using the same 2 DNS Servers?
    Will there be any change in the process or it remains the same

    Best Regards

    June 22, 2014 @ 6:00 am | Reply
  21. Russ Miller:

    I assume that cPanel can be the primary DNS, while only having one additional installation of DNSONLY as the secondary DNS. This way, you only need 2 servers versus 3 as I noticed that the article talks about creating 2 separate DNS servers.

    May 30, 2015 @ 12:00 am | Reply
  22. Anon:

    New Requirements min 768MB Ram

    cPanel, Inc. requires a minimum of 768 MB of RAM for your operating system.
    Increase the server’s total amount of RAM, and then reinstall cPanel & WHM.
    Removing /root/installer.lock.

    July 22, 2015 @ 9:13 am | Reply
  23. Fred Aliew:

    hello Maarten Kossen,
    Sorry for my Bad English.
    I follow your instructions and now i would like to confirm that my process is Right or Wrong . i eman i took 2 VPS for DNS Server Setup and i already have 1 Cpanel Main Server.
    I install DNS Only Cpanel on my new 2 VPS then i have done everything by following your Post. But i dont know dns server is working or not ..
    Also i use ns1.mydomain.com ns2.mydomain.com on my new 2 VPS including Main Cpanel Also and put ip for every server ip. i mean
    Example : How i configure each server..
    #DNS Only Server1(main IP of This Server is 1.1.1.1):dns1.mydomain.com
    ns1.mydomain.com 1.1.1.1
    ns2.mydomain.com 1.1.1.1

    #DNS Only Server2(main IP of This Server is 2.2.2.2):hostname : dns2.mydomain.com
    ns1.mydomain.com 2.2.2.2
    ns2.mydomain.com 2.2.2.2

    #Main Cpanel Server(main IP of This Server is 3.3.3.3): hostname : server.mydomain.com
    ns1.mydomain.com 3.3.3.3
    ns2.mydomain.com 3.3.3.3

    then i have added both DNS Server to my Main Cpanel Server ..

    Now please let me know that my DNS Server is Workign or Not and How i can test that i configure everything correctly or not ..

    Please ! Help Me ….

    August 7, 2015 @ 10:07 am | Reply
  24. Hi there! can I use Ubuntu version for the DNSONLY instead of CentOS

    April 23, 2016 @ 7:36 am | Reply
  25. Can I use Ubuntu version for DNSONLY instead of CentOs?
    Thanks in advance

    April 23, 2016 @ 7:39 am | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

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