DevOps Lab: Run Your Own DNS Server
By Sudheer S
As soon as you are ready to deploy services and applications on the Internet, the first thing you need is a registered domain and a DNS server. Often people just use the DNS service provided by the domain registrar or the hosting or cloud provider. Using the managed service is not a requirement. You can host your own DNS server and manage the DNS for your domains. There are many open source software using which you can build your own DNS servers. Bind is the traditional and probably the most popular DNS solution out there. There are other options such as Knot, PowerDNS and Unbound.
Your Own Self-Hosted DNS Server
Subscribe to a virtual machine(VM or a compute-instance) service from a hosting or cloud provider. Install the and configure Bind for your domain.
Start with the DNS clients. Get familiar with the commands:
- dig
- nslookup
- host
- Learn how to trick your OS to resolve fake DNS entries by editing
/etc/hosts
file - Learn how to use and manipulate
/etc/resolv.conf
file
Use virtual machines to install and configure Bind. Create a simple DNS server. You could use a fake domain to play with the DNS server. After you are satisfied with the local DNS setup on a virtual machine, proceed towards configuring it on a Linux server connected to the Internet using a hosting or cloud provider.
A real domain name costs money, about $US 12 per year. If you are investing your time and money in a DevOps career, it is well worth investing in a personal domain name.
Install the DNS server software and configure it. Point the NS records of your domain from the registrar’s portal. Serve the DNS records of your domain. Once this part works, start looking at the replication solution. Prepare yourself for outages of your DNS server. If one DNS server fails, the secondary should start serving the DNS queries.
IAC it: as with any other DevOps project, use IAC to manage the DNS servers. Ansible is a good option to configure the DNS server.
Master the DNS terminology by actually playing with them: DNS, FQDN, hostname, TLD, domain apex, naked domain, resolver, A record, NS record, SOA record, MX record, TXT record, glue record, record set, authoritative DNS server, recursive DNS server, caching DNS server, root nameservers, reverse lookup, TTL, DNS zone, DoH, DNSSEC etc.
Tech Chorus References:
Resources:
- Ubuntu Bind9 Server How-To
- Video by KodeKloud: DNS in Linux for the Absolute Beginners!