Domain Name Servers (DNS) are essential for the Internet, matching domain names with IP addresses. You will need to set appropriate DNS entries for all the domains and subdomains hosted on your server in order to make them accessible on the web.
In general, the registrar of your domain name(s) (such as namecheap.com) offers free DNS services. There are situations in which the hosting company offering VPSs or dedicated servers also offers free DNS services (such as linode.com). It’s recommended to use the DNS services offered by the registrar or by the hosting company. This is because these free DNS services are in general of good enough quality and by using them you’ll avoid installing and maintaining your own BIND servers, which will use around 20 MB of RAM memory continuously (you must have at least two DNS servers: one master and one slave DNS server, each with a separate IP and on a separate VPS or dedicated server, preferably in different geographic locations). However, in the situation where neither the registrar, nor the hosting company offers free DNS services, you have to consider installing and maintaining your own DNS servers (by installing BIND as described in the Install BIND chapter of this guide). Using the paid DNS services of a third party is not optimal and since this guide is concerned with the optimal solution for everything, it won’t describe this option.
If neither the registrar of your domain name(s), nor the hosting company offers free DNS services and you don’t want to install and maintain BIND on two of your servers, you can use the free DNS services offered by Hurricane Electric, as we’ll describe below. Their servers are fast, stable and secure.
If you use the DNS services offered by your registrar or hosting provider, you can set the DNS records in a similar manner to what we’ll describe for Hurricane Electric, although the web interface for Hurricane Electric is quite different from that of other DNS services providers.
13.1. Add DNS records using Hurricane Electric’s free DNS services
As explained in the Domain hosting strategy chapter, you should choose a domain hosted on your server as your main domain. Let’s say the main domain is example.com . Then you can set up all the subdomains necessary for the applications described in this guide, as subdomains of the main domain like this: mail.example.com as subdomain for Roundcube, lists.example.com for phpList, mailman.example.com for Mailman, doli.example.com for Dolibarr, cloud.example.com for Nextcloud, office.example.com for LibreOffice Online, roundpin.example.com for Roundpin, stats.example.com for Matomo, friendica.example.com for Friendica, forum.example.com for MyBB. Each subdomain should have its own A and AAAA DNS records, that you can set up as explained below.
First register for an account on: https://dns.he.net/ (by clicking on ‘Register!’ in the upper left corner). Then log in to your free account by entering the username and password that you have set at registration.
Next, click on ‘Add a new domain’, in the left panel, under ‘Zone Functions’. You’ll be prompted to enter your domain. First of all enter your main domain example.com . Then click on ‘Add Domain!’. Please note: if the domain is not registered yet, you’ll receive an error when trying to add it, so the domain that you want to add must be bought in advance from a registrar (such as namecheap.com). Also, when you buy a domain, you’ll have to set the Hurricane Electric’s name servers (ns1.he.net, ns2.he.net, ns3.he.net, ns4.he.net, ns5.he.net) as name servers for that domain in your registrar’s client account.
If you used Namecheap to register your domain(s), you can set up Hurricane Electric’s DNS servers for them as explained below.
Set Hurricane Electric’s DNS servers as DNS servers for a domain in a Namecheap client account
Once you log in to your namecheap.com client account, on the Dashboard click on ‘Manage’ next to the domain name for which you want to set up DNS servers, then on the ‘Domain’ tab, in the ‘NAME SERVERS’ section, select ‘Custom DNS’ from the drop-down list, then click on ‘ADD NAMESERVER’, enter ns1.he.net, then save the server by clicking on the green tick sign in the upper right corner. In the same manner enter the following DNS servers:
Repeat the process for all the domains registered with Namecheap, for which you want to set up Hurricane Electric’s DNS servers.
Then, in the window of your newly added domain you must first enter the A record for example.com, as well as for www.example.com (this is regardless of which one you want to use as your canonical domain name; if you use www.example.com as the official domain name for your website, then you will configure Nginx to redirect requests for example.com to www.example.com; if you use example.com, you will configure Nginx to redirect requests for www.example.com to example.com , as we’ll describe further down below). You will also need to add A records for all your subdomains, such as mail.example.com, cloud.example.com, lists.example.com, office.example.com, etc. Then you’ll have to add similar AAAA records. The AAAA records will be identical with the A records, with the exception of the IP address, which will be the public IPv6 address of your server. The A and AAAA records for the main domain should look similar to the following:
Where 126.96.36.199 is the public IPv4 address, and 2bc6:4ce0:2:9::4728 is the public IPv6 address of your server. You can find both addresses by running:
In the output of this command you will find the two IPs as shown below:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 188.8.131.52 netmask 255.255.255.0 broadcast 184.108.40.206
inet6 2bc6:4ce0:2:9::4728 prefixlen 64 scopeid 0x0<global>
When you want to add an A record click on ‘New A’ in the upper bar and fill the fields as follows:
Similarly, for an AAAA record click on ‘New AAAA’; in the ‘Name’ field write the whole domain or subdomain, and in the ‘IPv6 Address’ field enter your server’s public IPv6 address.
That’s it. So, the settings for example.com should look similar to the following:
Although they don’t appear in the image from above, you’ll have to add similar A and AAAA records for doli.example.com, stats.example.com, friendica.example.com and forum.example.com.
Please note that for every other domain apart from the main domain that you host on your server, you’ll have to add all the above mentioned DNS records, with the exception of the entries for the subdomains that are ‘reserved’ for the main domain (namely mail.example.com, lists.example.com, mailman.example.com, doli.example.com, cloud.example.com, office.example.com, roundpin.example.com, stats.example.com, friendica.example.com, forum.example.com). Of course, you can add a forum subdomain to any of your other domains if you wish.