Nameserver Configuration
A Caching-only Nameserver
Here is an example of a caching-only named.conf file for use by internal clients. All queries from outside clients are refused.
// Subnets we wish to allow queries from. acl "intranet" { 192.168.1.0/224; 192.168.4.0/224; }; options { directory "/etc/named"; // Working directory pid-file "named.pid"; // Put pid file in working dir allow-query { "intranet"; }; }; // Root server hints zone "." { type hint; file "named.ca"; }; // Provide a reverse mapping for the loopback address 127.0.0.1 zone "0.0.127.in-addr.arpa" { type master; file "localhost.rev"; notify no; };
An Authoritative-only Nameserver
This /etc/named.conf is for an authoritative-only server that is the master server for "mn.acme.com" and a slave for the subdomain "www.setgetweb.com".
options { directory "/var/named"; // Working directory pid-file "named.pid"; // Put pid file in working dir allow-query { any; }; // This is the default recursion no; // Do not provide recursive service }; // Root server hints zone "." { type hint; file "named.ca"; }; // Provide a reverse mapping for the loopback address 127.0.0.1 zone "0.0.127.in-addr.arpa" { type master; file "localhost.zone"; notify no; }; // We are the master server for mn.acme.com zone "mn.acme.com" { type master; file "mn.acme.com.zone"; // IP addresses of slave servers allowed to transfer mn.acme.com allow-transfer { 192.168.1.190; }; }; // We are a slave server for mill.mn.acme.com zone "mill.mn.acme.com" { type slave; file "mill.mn.acme.com.zone"; // IP address of www.setgetweb.com master server masters { 192.168.1.180; };
Load Balancing
Primitive load balancing can be achieved in DNS using multiple A records for one name.
For example, if you have three WWW servers with network addresses of 10.0.0.1, 10.0.0.2 and 10.0.0.3, a set of records such as the following means that clients will connect to each machine one third of the time:
Name TTL CLASS TYPE Resource Record (RR) Data WWW 600 IN A 10.0.0.1 WWW 600 IN A 10.0.0.2 WWW 600 IN A 10.0.0.3 When a resolver queries for these records, BIND will rotate them and respond to the query with the records in a different order. In the example above, clients will randomly receive records in the order 1, 2, 3; 2, 3, 1; and 3, 1, 2. Most clients will use the first record returned and discard the rest.
For more detail on ordering responses, check the rrset-order (RRset Ordering)substatement in the options statement. This substatement is not supported in BIND 9, and only the ordering scheme described above is available.
NOTIFY
NOTIFY is a mechanism that allows master nameservers to notify their slave servers of changes to a zone's data. In response to a NOTIFY from a master server, the slave will check to see that its version of the zone is the current version and, if not, initiate a transfer.
DNS Notify is fully documented in RFC 1996. See also the description of the zone option also-notify,
Tools
dig
The domain information groper (dig) is a command line tool that can be used to gather information from the Domain Name System servers. Dig has two modes: simple interactive mode for a single query, and batch mode which executes a query for each in a list of several query lines. All query options are accessible from the command line.
dig [@server] domain [query-type] [query-class] [+query-option] [-dig-option] [%comment]The usual simple use of dig will take the form
dig @server domain query-type query-classFor example:
dig @e.root-servers.net www.ibm.com A +norec
host
The host utility provides a simple DNS lookup using a command-line interface for looking up Internet hostnames. By default, the utility converts between host names and Internet addresses, but its functionality can be extended with the use of options.
host [-aCdlrTwv] [-c class] [-N ndots] [-t type] [-W timeout] [-R retries] hostname [server]
nslookup
nslookup is a program used to query Internet domain nameservers. nslookup has two modes: interactive and non-interactive. Interactive mode allows the user to query nameservers for information about various hosts and domains or to print a list of hosts in a domain. Non-interactive mode is used to print just the name and requested information for a host or domain.
nslookup [-option...] [host-to-find | - [server]]Interactive mode is entered when no arguments are given (the default nameserver will be used) or when the first argument is a hyphen (`-') and the second argument is the host name or Internet address of a nameserver.
Non-interactive mode is used when the name or Internet address of the host to be looked up is given as the first argument. The optional second argument specifies the host name or address of a nameserver.
Due to its arcane user interface and frequently inconsistent behavior, we do not recommend the use of nslookup. Use dig instead.
rndc
The remote name daemon control (rndc) program allows the system administrator to control the operation of a nameserver.
rndc [-c config] [-s server] [-p port] [-y key] command [command...]command is one of the following:
reload Reload configuration file and zones. reload zone [class [view]] Reload the given zone. refresh zone [class [view]] Schedule zone maintenance for the given zone. stats Write server statistics to the statistics file. querylog Toggle query logging. dumpdb Dump the current contents of the cache (or caches if there are multiple views) into the file named by the dump-file option (by default, named_dump.zone). stop Stop the server, making sure any recent changes made through dynamic update or IXFR are first saved to the master files of the updated zones. halt Stop the server immediately. Recent changes made through dynamic update or IXFR are not saved to the master files, but will be rolled forward from the journal files when the server is restarted. In BIND 9.1, rndc does not yet support all the commands of the BIND 8 ndc utility. Additonal commands will be added in future releases.
A configuration file is required, since all communication with the server is authenticated with digital signatures that rely on a shared secret, and there is no way to provide that secret other than with a configuration file. The default location for the rndc configuration file is /etc/rndc.conf, but an alternate location can be specified with the -c option.
The format of the configuration file is similar to that of named.conf, but limited to only three statements, the options, key and server statements. These statements are what associate the secret keys to the servers with which they are meant to be shared. The order of statements is not significant.
The options statement has two clauses: default-server and default-key. default-server takes a host name or address argument and represents the server that will be contacted if no -s option is provided on the command line. default-key takes the name of key as its argument, as defined by a key statement. In the future a default-port clause will be added to specify the port to which rndc should connect.
The key statement names a key with its string argument. The string is required by the server to be a valid domain name, though it need not actually be hierarchical; thus, a string like "rndc_key" is a valid name. The key statement has two clauses: algorithm and secret. While the configuration parser will accept any string as the argument to algorithm, currently only the string "hmac-md5" has any meaning. The secret is a base-64 encoded string, typically generated with either dnssec-keygen or mmencode.
The server statement uses the key clause to associate a key-defined key with a server. The argument to the server statement is a host name or address (addresses must be double quoted). The argument to the key clause is the name of the key as defined by the key statement. A port clause will be added to a future release to specify the port to which rndc should connect on the given server.
A sample minimal configuration file is as follows:
key rndc_key { algorithm "hmac-md5"; secret "c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K"; }; options { default-server localhost; default-key rndc_key; };This file, if installed as /etc/rndc.conf, would allow the command:
$ rndc reloadto connect to 127.0.0.1 port 953 and cause the nameserver to reload, if a nameserver on the local machine were running with following controls statements:
controls { inet 127.0.0.1 allow { localhost; } keys { rndc_key; }; };and it had an identical key statement for rndc_key.
Signals
Certain UNIX signals cause the name server to take specific actions, as described in the following table. These signals can be sent using the kill command.
SIGHUP Causes the server to read named.conf and reload the database. SIGTERM Causes the server to clean up and exit. SIGINT Causes the server to clean up and exit.