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:
This should download the installer. It’s quite small. Now, make it executable:
chmod +x latest-dnsonly
And execute it:
This should run the installer and it should look like this:
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.
Log in with your root account, which should send you to the setup process.
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 ;-)
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.
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.
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.
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.
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’.
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”.
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.
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:
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!
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!