Introduction
DNS is a big player on the internet. It gives us a way to assign names to all those IP addresses out there. This howto is going to cover installing DNS and 3 configuration examples. Keep in mind that one server can encompass all three configurations at the same time.
Setup New Server (Optional)
I like to have dedicated DNS servers. So you can start with a fresh server install. Follow the HOWTO below to setup a new server. Otherwise move on to install software.
HOWTO Ubuntu 16.04 LTS Base Server Setup
Introduction All of our servers will start with this install. This base server is based on Ubuntu 16.04 LTS Server. I don’t explain much in the howto so if you have a question leave a comment or use Google. Downloading … Continue readingInstall Software
We will be using BIND for our DNS server. Software is a quick install. Type the following.
> sudo apt-get install bind9 bind9utils bind9-doc
Three DNS Configurations
I’m going to cover 3 common DNS configurations. They are:
Caching DNS Server:
Usually a local server. It helps speed up the DNS lookup process by storing a local cache of frequently looked up host names by clients.
Primary DNS Server:
This type of server provides authoritative answers for domains and sub domains. Zone files contain information about the domain.
Secondary DNS Server:
This type of server is known as a slave server. It provides redundancy to the primary DNS server.
Caching only DNS Server
Out of the box the Bind package for Ubuntu has been configured as a caching DNS server. We can speed up lookups by forwarding them to your ISP’s DNS servers, Googles DNS server and / or other fast DNS server. In this example I’m going to use Google’s DNS server. We are also going to limit the clients that can use the server.
Make a backup of /etc/bind/named.conf.options
> sudo cp /etc/bind/named.conf.options /etc/bind/named.conf.options.save
Change /etc/bind/named.conf.options to look like the text below.
> sudo nano -w /etc/bind/named.conf.options
// caching only DNS server config // acl localclients { 192.168.0.0/16; 10.0.0.0/8; localhost; localnets; }; options { directory "/var/cache/bind"; recursion yes; allow-query { any; }; allow-query-cache { any; }; allow-recursion { localclients; }; forwarders { 0.0.0.0; 8.8.4.4; }; dnssec-validation auto; auth-nxdomain no; # conform to RFC1035 listen-on-v6 { any; }; };
Restart bind
> sudo service bind9 restart
Primary DNS Server
This configuration is for providing DNS for your domain name(s). I’m only going to cover a basic domain setup. There are a lot of configuration options for zone files.
Make a backup of /etc/bind/named.conf.options
> sudo cp /etc/bind/named.conf.options /etc/bind/named.conf.options.save
Change /etc/bind/named.conf.options to look like the text below.
> sudo nano -w /etc/bind/named.conf.options
// caching only DNS server config // acl localclients { 192.168.0.0/16; 10.0.0.0/8; localhost; localnets; }; options { directory "/var/cache/bind"; recursion yes; allow-query { any; }; allow-query-cache { any; }; allow-recursion { localclients; }; forwarders { 0.0.0.0; 8.8.4.4; }; dnssec-validation auto; auth-nxdomain no; # conform to RFC1035 listen-on-v6 { any; }; allow-transfer { none; }; };
Edit /etc/bind/named.conf.local and add the text below.
> sudo nano -w /etc/bind/named.conf.local
zone "example.com" { type master; file "/etc/bind/db.example.com"; };
Now create /etc/bind/db.example.com and use the text below.
> sudo nano -w /etc/bind/db.example.com
$TTL 604800 @ IN SOA dns1.example.com. admin.example.com. ( 10 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; ; Name servers example.com. IN NS dns1.example.com. ; A records for name servers dns1 IN A 192.168.1.1 ; Other A records @ IN A 192.168.1.2 www IN A 192.168.1.2
Restart bind
> sudo service bind9 restart
Secondary DNS Server
This configuration is for providing DNS for your domain name(s). I’m only going to cover a basic domain setup. There are a lot of configuration options for zone files.
Make a backup of /etc/bind/named.conf.options
> sudo cp /etc/bind/named.conf.options /etc/bind/named.conf.options.save
Change /etc/bind/named.conf.options to look like the text below.
> sudo nano -w /etc/bind/named.conf.options
// caching only DNS server config // acl localclients { 192.168.0.0/16; 10.0.0.0/8; localhost; localnets; }; options { directory "/var/cache/bind"; recursion yes; allow-query { any; }; allow-query-cache { any; }; allow-recursion { localclients; }; forwarders { 0.0.0.0; 8.8.4.4; }; dnssec-validation auto; auth-nxdomain no; # conform to RFC1035 listen-on-v6 { any; }; allow-transfer { none; }; };
Edit /etc/bind/named.conf.local and add the text below.
> sudo nano -w /etc/bind/named.conf.local
zone "example.com" { type slave; file "db.example.com"; masters { 192.168.1.1; } };
Restart bind
> sudo service bind9 restart
Conclusion
This howto was focused on configuring Bind on Ubuntu. You will need to do research on all the options that Bind offers.