Maybe you have had enough of the unreliable service that often comes with shared hosting. Or maybe your monthly bandwidth costs are just too high. Whatever the reason that you are planning to move to your own Linux web server, you are going to need to know how to set up the DNS to create your own nameserver(s) and DNS Zone. To setup your own DNS, you will also need to use a domain registrar that allows you to create “glue records.” They are what links the IP and the domain name together. For the most part, as long as your provider is not a reseller, you should be good to go.
Why DirectAdmin (DA)?
Most shared hosting companies offer an admin control panel called Control Panel or CP for short. CP is great for beginners as it makes things easy to find. But, that ease of use comes at the cost of performance and leaves you at the mercies of your web host for updates.
I prefer using DirectAdmin to manage my sites. It’s fast, frequently updated and there are updates for the latest PHP and MySQL versions. I’m sure there are more reasons to use DA just as there are more powerful control panel systems available.
Setting up the DNS for a DirectAdmin web server
For this tutorial, we will be using domain.com as our domain name and 188.8.131.52 & 184.108.40.206 for our IP addresses. You will need to replace all three with your own.
- Login to your DirectAdmin control panel and click on “IP management.” You should see the first server IP address already in the list. Enter the second IP addresses one beneath it.
- After entering the IP addresses, go to “User level” and click on “DNS Management.” Enter the DNS records you need for your domain name/host. Most people use the naming convention ns1.domain.com. and ns2.domain.com. for the two name server entries – make sure you include the trailing dot.
- Now we’ll set up the glue record. Using the same name you used in step 2 and the IP addresses you used in step 1, now you’ll need to setup the DNS and name servers for your server with your domain registrar. You’ll need to configure the domain with your “global” DNS (domain) provider as follows (use the two IP addresses you configured within DirectAdmin):
ns1.domain.com -> 220.127.116.11
ns2.domain.com -> 18.104.22.168
As with any DNS change, these server entries may take 24-48 hours to populate to the Internet.
- Log back into DirectAdmin and click “Administrator Settings.” Enter a server name with the field “Server’s Hostname” You can use any letter (a-z), 0-9 and hyphens. I like to use something simple like srv01. Enter the names you used in steps 2 and 3 to fill in the fields for NS1 and NS2.
- Connect to your server via SSH (use Putty) and login as root (sudo) and enter:
Hopefully, your distro includes the text editor Nano. If not, you might want to use Pico or the more adventurous Vi (check the Linux MAN pages on how to insert text with the editor VI if you need a bit of a refresher). Add the following line to the file:
22.214.171.124 srv01.domain.com srv01
(don’t forget to make the appropriate changes to add your own server and not my dummy one)
Save the file via ctrl+x (confirm to save the file) or :wq if you were forced to edit the file with Vi.
The alternative way to handle your server’s DNS
The main reason why people host their DNS on their own server is because it’s easy. The local DNS Zone is automatically created by the control panel. And, after the virtual host on your server with DA installed is created, you’ll only need to change the name server entries for the specific domain name(s).
There are also reasons to use a DNS zone for your domain names from your domain name provider or a professional DNS provider.
- If your VPS or dedicated server is down, all DNS is down too. If you use, for example Google Apps for your email, you will be able to receive email only for a short time before it goes down too.
- If you move your website to a different server you need to change the nameservers for your domain name too. For several TLD’s does this change take hours.
- A professional DNS provider resolves often much faster than your own server.
- Most providers have a large staff and can more quickly respond to DDOS and other attacks.
There is additional work you’ll need to do to create a DNS zone for each website on your server (local DNS) and the public DNS via the DNS account from your domain name provider. Most service providers are able to provide DNS templates, which make the work much easier and faster. A DNS zone is often a free service from your domain provider. If not or if you like use additional features like virtual DNS, a web application firewall and a CDN for your static files, try Cloudflare. They offer a great service and their free plan is complete enough for most websites.
Published in: Web Hosting