How to configure name servers in cPanel-WHM via SSH
The Domain Name System, or DNS, is one of the most essential parts of the modern web. Whenever you enter a domain name into your browser’s URL bar, DNS facilitates the translation of this request by name servers into a server-routable IP address. This process is what makes browsing the web so easy to do.
A name server is a program that runs on a server and provides DNS information for that server in response to any requests. Without a properly configured name server, people will have trouble finding the websites you host. This guide will walk you through the steps for setting up name servers in cPanel/WHM and ensuring their correct functioning.
Here’s what you need to know before you start:
• You’ll need to have root access to the parent server (Cloud Server or Dedicated Server) in order to set up a name server.
• You will also need to have your name servers registered to your IP addresses at the registrar level. We’ll assume you will have two of them for the purposes of this guide. Take care of this before proceeding with the rest of the steps.
The first step will be to create the name servers. In order to do that, you must go to the “Basic cPanel and WHM setup” section of your cPanel instance. At the bottom of the page will be a couple of textboxes labeled as name servers. In these boxes you’ll write the name servers that you registered with at the registrar.
Now we should verify the name server registration. That will require clicking on the “Nameserver IP” option in the WHM menu on the left-hand side of the page. Note here whether both of the name servers are showing up without an IP address.
If they are, then it’s now time to log in using SSH and delete the cPanel name servers IP cache. Connect to your server and make sure that you have root access. Enter the command below in order to delete the name server ip cache file:
Edit cPanel Nameservers script file
Your next step is to edit the name servers script file. We’ll do this with nano, or you can use your preferred text editor:
For each name server in the file, manually replace the IP addresses with the ones you registered at the registar level for your name servers. See below for an example (using gtcomm.net and random IPs for the purpose of this guide):
Note: Replace 18.104.22.168 with the IP address of your first nameserver and 22.214.171.124 with the IP address of your second nameserver.
Save and close the file. The next file we’ll edit is /etc/nameserverips:
The below is an example of how we’d like you to alter the file. Make sure to replace the gtcomm.net domain and the IP addresses with your own domain and IP addresses.
Finally, it’s time to restart cPanel and named, which is our name server daemon. Use this command to do so:
/etc/init.d/named restart && /etc/init.d/cpanel restart
After having finished, if there are any zones configured to the server, you’ll have to verify that the dns entries for each name server in each zone matches the IP. Go back into your graphical cPanel/WHM interface and click on “Edit DNS Zones” in the left-hand menu. Select each zone and click the “modify” option, which will show you the values. If any of them are incorrect, you can update them and save your changes.
Now you know the proper procedure for configuring your name servers on a server using cPanel/WHM.