What is a name server?
The word nameserver is used interchangeably for both a piece of software that runs on most web servers, and as a setting in every domain’s DNS (Domain Name System) configuration.
As a piece of a domain’s DNS configuration, nameservers are the place where everyone trying to access your website will go to look up your DNS information. It is very important to note that these are defined both at the domain registrar, and in a domain’s zone file, and that they need to match in both places.
As a piece of software, nameserver references the program that serves DNS information in response to queries. On your cPanel server you are offered the choice between three of the most common nameserver software: Bind, MyDNS, and NSD. Each has advantages and disadvantages, which are outlined for you in the WHM interface.
Why are nameservers important?
Accurate and stable nameservers are crucial to your site’s uptime and functionality. A misconfiguration in your DNS information will cause your web traffic to be improperly routed, resulting in downtime. Ensuring everything is configured and working properly is absolutely critical to your website’s functionality.
How to: Setting up nameservers on your cPanel server
This tutorial assumes, for the sake of simplicity, that you will be using two nameservers that are run on the same physical server. This is a common configuration, though it is not recommended due to its lack of redundancy.
— A linux server with cPanel installed, and at least two IPs.
— An understanding of how to interact with WHM’s interface.
— A base understanding of terminal and command-line interfacing.
The nameserver (or nameservers) that hold the correct information for a given domain.
A nameserver that holds a cached version of DNS information to help speed up query times and reduce query load on the authoritative servers.
The process through which DNS information spreads from authoritative nameservers to caching nameservers.
The act of asking a nameserver for DNS information regarding a given domain.
The process of translating a domain name to an IP address or an IP address to a domain.
DNS Zone record types:
While these are beyond the scope of this tutorial, if you’re going to run a nameserver you should be familiar with at least this list of
zone record types.
Step one: Select a nameserver software on your server in WHM
In WHM navigate to Service Configuration, and then Nameserver Selection. You are offered a few choices of cPanel’s supported nameservers. The advantages and disadvantages of each are outline in WHM to help you in deciding which one is best for you.
Step two: Configure your nameservers
Before you can configure your nameservers you must first decide what you will call your nameservers. The most common options are some variant of ns.yourhost.com. For example, if your hostname were yourhostname.com you might choose to use ns1.yourhostname.com and ns2.yourhostname.com. You can also use other, less obvious subdomains. As an example, cPanel’s nameservers are hg.cpanel.net, c.cpanel.net, and fe.cpanel.net.
To configure your nameservers, you first log in to WHM and navigate to Server Configuration, and then to Basic cPanel & WHM Setup. Scroll to the bottom of that page and you will see the nameserver fields. In those fields enter your chosen nameserver names.
Note: The information entered into these fields will be used as the default nameservers for all domains that are added to your server from this point forward.
The next step is to assign each of them an IP address. By clicking on ‘Assign IP’ cPanel will do so automatically. Your screen will look something like this:
The next thing you need to do is make sure that your nameserver has an A record. Click the button next to the nameserver and your screen will look something like the screenshot below. As long as you have already assigned an IP address to the nameserver through WHM then the IP address displayed should be correct.
Note: If the DNS for your hostname is not hosted on your server then you will need to configure A records that match the assigned IPs wherever the DNS for your hostname is hosted. This is absolutely necessary for you to be able to register your nameservers successfully.
The best way to quickly verify that your nameserver software is delivering information correctly is to use a command line tool called ‘dig’. By default your nameserver, depending on which software you chose, will very likely not be configured to resolve domains for which it isn’t authoritative, so make sure that you are using a domain that the server is authoritative for in your testing. For this example we will assume that your server is serving the DNS for your hostname, and we will use the server’s hostname for our testing.
Connect to your server via SSH and run this command:
[~]# dig +short @localhost $HOSTNAME
Here we are using the ‘dig’ command with one optional addition, the ‘@localhost’. In this context adding the ‘@localhost’ is indicating to dig that it should attempt to resolve the domain at your local nameserver, rather than using the nameservers defined in /etc/resolv.conf. The last part of the command is an environment variable $HOSTNAME, which will pull the hostname of your server and the command will attempt to resolve it. If we add in the ‘+short’ option to reduce the output to just the IP address, the output should look something like this:
[~]# dig +short @localhost $HOSTNAME 192.168.1.119
If you don’t get a response, or see an error, you should attempt to resolve the problem. The first place to look if you don’t get an IP as your response would be the log file at /var/log/messages. If you run into any problems or errors that you can’t resolve, your system administrator should be able to resolve them, or you can open a ticket with our technical support team.
Step three: Register your nameservers
Nameservers, like domains, need to be registered at a registrar. Nameservers must be registered at the same place as the base domain was registered. So, if our example domain yourhostname.com was registered at GoDaddy, your nameservers (ns1.yourhostname.com and ns2.yourhostname.com) must also be registered at GoDaddy.
You can find more information about registering private nameservers here.
Step four: Test and verify your nameserver is working
Since nameserver configuration can is so crucial to uptime, testing and verifying the configuration before you put mission critical sites live on your new server is just good server administration practices. One of the most common tools is intodns.com.
With IntoDNS you can get a good, quick look for some of the most common errors and vulnerabilities nameservers might have, as well as a quick error-checking for your existing DNS zone. In this case, we will use cpanel.net to look for errors:
If you see any warnings or errors there you should work to resolve them with your datacenter or system administrator. If you are seeing errors that you can’t get resolved, feel free to open a ticket with our software support team, and we will do our best.