Bind

NOTE: The below examples are generally for both an Authoritative and Caching DNS Servers but with a little working can become Authoritative Only or Forwarding Only DNS Servers.

Tasks

Installing and configuring

yum install bind bind-utils

  acl "trusted" {
        172.31.7.46; #IP on this machine
        172.31.33.14; #Secondary DNS Servers IP
        localhost;
  };
  allow-query     { trusted; any; };
  listen-on port 53 { 127.0.0.1; 172.31.7.46; };
  //listen-on-v6 port 53 { ::1; }; # This is commented out as this DNS server isn't configured to listen on IPV6 addresses.
  include "/etc/named/named.conf.local";

Configure a new Zone

  zone "test.marjamis.example.com" {
        type master; # Specifies this DNS Server is the Primary Authoritative for the zone
        file "/etc/named/zones/db.test.marjamis.example.com"; # Location of the file zone db
  };

  zone "31.172.in-addr.arpa" { # Network Octets in reverse order
        type master; # Specifies this DNS Server is the Primary Authoritative for the zone
        file "/etc/named/zones/db.172.31"; # Location of the file zone db
  };
chmod 755 /etc/named
  $TTL 86400 #
  @       IN      SOA     <ns> <email> ( # @ will substitute the set or generated $ORIGIN, ns is the primary name server for this zone and email is for the email address of who's responsible for this zone. **NOTE:** the @ in an email address is substituted for a dot in the configuration file.
              3         ; Serial # Identifier to BIND on whether to use the new settings. Must be higher than the previous version on reload to take effect.
             604800     ; Refresh # This is the refresh interval for the zone. This is the amount of time that the slave will wait before polling the master for zone file changes.
              86400     ; Retry # This is the retry interval for this zone. If the slave cannot connect to the master when the refresh period is up, it will wait this amount of time and retry to poll the master.
            2419200     ; Expire # This is the expiry period. If a slave name server has not been able to contact the master for this amount of time, it no longer returns responses as an authoritative source for this zone.
             604800 )   ; Negative Cache TTL # This is the amount of time that the name server will cache a name error if it cannot find the requested name in this file.
  <URL> IN A <ipv4 address> # A
  <URL> IN AAAA <ipv6 address> # AAAA
  <URL> IN CNAME www.google.com. # CNAME
  IN NS <URL> # NS, beginning URL for an NS isn't required as it's a zone wide parameter
  IN MX <URL> # Mail Record,  beginning URL for an NS isn't required as it's a zone wide parameter
  <URL> IN TXT "Whatever data you want" # TXT
* IN A <ipv4 address> # Resolves anything under the domain that isn't defined explicitly. Like a default.

  <host octets(reversed) IN PTR <URL> # PTR in reverse zone
named-checkconf
named-checkzone <zone> <location of db file>

Configure a Secondary DNS Server

allow-transfer { 172.31.33.14; };
zone "test.marjamis.example.com" {
    type slave;
    file "slaves/test.marjamis.example.com";
    masters { <IP_of_Primary>; };
};

zone "31.172.in-addr.arpa" {
    type slave;
    file "slaves/db.172.31";
    masters { <IP_of_Primary>; };
};
# named-checkconf

Updating DNS Records

  /etc/named.conf

Updating forwarders

  /etc/named.conf
  zone "new" {
    type forward;
    forwarders { <ip>; <ip>; };
  };

Backout Plan

Reload named

Examples are:

  AIX: # refresh -s named
  Linux: # systemctl reload named

General Information

Configurations / Definitions

Chroot and SetuidBIND can run in a chrooted and limited user id for added security precautions.
options statement: notifyA mechanism that allows master servers to notify their slave servers of changes to a zone’s data. Configuration options on the servers that can be notified/updated are available.
Load BalancingA primitive form of load balancing can be achieved in the DNS by using multiple records (such as multiple A records) for one name.
DNSSec
Glue recordsIn this case, the name server providing the delegation must also provide one or more IP addresses for the authoritative name server mentioned in the delegation. This information is called glue. The delegating name server provides this glue in the form of records in the additional section of the DNS response, and provides the delegation in the authority section of the response. A glue record is a combination of the name server and IP address.
options statement: recursionIf yes, will attempt to resolve every query.
options statement: querylogSpecify whether query logging should be started when named starts.
view statementThe view statement is a powerful feature of BIND 9 that lets a name server answer a DNS query differently depending on who is asking. It is particularly useful for implementing split DNS setups without having to run multiple servers.
INAs from the RFC1035, it means the Internet
$ORIGINExplicitly specified in the zone file or synthesized from the zone name from the zone configuration, it defines the base name from which ‘unqualified’ names (those without a terminating dot) substitutions are made when processing the zone file. $ORIGIN is used in two contexts during zone file processing: 1.The symbol @ forces substitution of the current (or synthesized) value of $ORIGIN. The @ symbol is replaced with the current value of $ORIGIN. 2. The current value of $ORIGIN is added to any ‘unqualified’ name (any name which does not end in a ‘dot’).
$GENERATEUsed to create a series of resource records that only differ from each other by an iterator.
@A placeholder that substitutes the contents of the $ORIGIN
Root DNS ServersTop of the DNS system are the “root servers” which are controlled by ICANN. Root servers, currently 13, use a broadcast system where all the mirrors of the 13 root servers have the same IP on the internet allowing requests to route to the closest copy of that root server. They handle details about TLD’s.
TLDTop Level Domain, e.g. .com and .au. Directed to from the Root DNS Servers to find the IP of a domain to be returned or to continue the search for the IP of a sub-domain.
RecursivePerforms recursive look-ups on a query to supply a response.
Iterative
HintThe initial set of root name servers is specified using a “hint zone”. When the server starts up, it uses the root hints to find a root name server and get the most recent list of root name servers. If no hint zone is specified for class IN, the server uses a compiled-in default set of root servers hints. Classes other than IN have no built-in defaults hints.
Dynamic DNS UpdatesDynamic Update is a method for adding, replacing or deleting records in a master server by sending it a special form of DNS messages. Any update via this process will be stored in the zone’s journal file.
Zone transferSecondary servers load the zone contents from another server using a replication process known as a zone transfer.
Stealth ServersA stealth server is a server that is authoritative for a zone but is not listed in that zone’s NS records. Stealth servers can be used for keeping a local copy of a zone to speed up access to the zone’s records or to make sure that the zone is available even if all the ”official” servers for the zone are inaccessible.
Built-in Empty ZonesNamed has some built-in empty zones (SOA and NS records only). These are for zones that should normally be answered locally and which queries should not be sent to the Internet’s root servers. These general follow the normal non-routable IP ranges.
Stub ZoneA stub zone is similar to a slave zone, except that it replicates only the NS records of a master zone instead of the entire zone. Stub zones are not a standard part of the DNS; they are a feature specific to the BIND implementation.
Types of DNS

NOTE: For greater details on any configurations use official documentation.

Type of DNSMeaningRequirements
AuthoritativeReturns the details of Resource Records for Forward/Reverse zones it controls. If configured for Authoritative Only, any request that it can’t provide and answer to from it’s zone will be responded without any recursive attempt. Route53 is an example of an Authoritative Only DNS server. Authoritative is zone specific, therefore one machine can be a primary for a particular zone and secondary for another zone.Has zone files and is configured to use them.
Caching/Resolver/RecursiveHandles recursive queries and generally can handle the grunt work of tracking down DNS data from other servers. Returns the answer to the client and stores the record in cache based on TTL.In /etc/named.conf, have recursion set to yes or allow-recursion specifying an ACL.
ForwardingA forwarding DNS server offers the same advantage of maintaining a cache to improve DNS resolution times for clients. However, it actually does none of the recursive querying itself. Instead, it forwards all requests to an outside resolving server and then caches the results to use for later queries. This may be an advantage in environments where external bandwidth transfer is costly, where your caching servers might need to be changed often, or when you wish to forward local queries to one server and external queries to another server.In /etc/named.conf, use the forwarders configuration to specify which other public/private DNS Servers any incoming request should be sent to and specify forward only. A typical scenario would involve a number of internal DNS servers and an Internet firewall. Servers unable to pass packets through the firewall would forward to the server that can do it, and that server would query the Internet DNS servers on the internal server’s behalf.
Stub ResolverThe resolver libraries provided by most operating systems are stub resolvers, meaning that they are not capable of performing the full DNS resolution process by themselves by talking directly to the authoritative servers. Instead, they rely on a local name server to perform the resolution on their behalf.
Split DNSSetting up different views, or visibility, of the DNS space to internal and external resolvers is usually referred to as a Split DNS setup. There are several reasons an organization would want to set up its DNS this way.Configurations of these views in ACL’s or some other configuration.

rndc operations

rndc is a BIND server control utility that allows to configure the run-time configurations of BIND. Many, if not all, of these will temporarily change how BIND operates but on a restart of the named process the defaults will be restored so permanent modifications requires updating the named configuration files.

CommandFunction
rndc querylogWill result in all queries being logged to /var/log/messages.
rndc dumpdb -cacheWill dump the cached addresses in the location specified in the named.conf file for the setting dump-file
rndc reloadWill reload the named server it’s connecting to, by default localhost.

Other commands

CommandFunction
named-compilezoneSimilar to named-checkzone, but it always dumps the zone content to a specified file (typically in a different format).
nsupdateA utility to submit Dynamic DNS Updates to a name server.

Files and their purpose

FileUsage
/etc/rndc.keyA shared secret key used by the rndc to communicate with a remote name server.