DNS Tricks and Tips

Here are some common tricks and some tips for common DNS problems. Also take a look at DNS Q & A Corner from Men & Mice.

Generating cache file with dig

From Paul Vixie and Ruediger Volk

Anyone with DiG installed (which includes anyone running BIND 4.9 or better) can generate a new cache file by typing

	% dig @a.root-servers.net. . ns >root.cache
Check this file by hand before installing it, of course.

Recovering from an SOA typo

From Steve Hubert

It's only hard to recover from a typo if you're running an old BIND. If your secondaries are 4.9 or later, then you should just need two serial number changes to get back in sync:

Also refer to RFC 1982.

Ultrix needs primaries in host file

From William Gianopoulos

With the stock Ultrix 4.3 name server (and possibly other releases), all primary nameservers must be in the /etc/hosts file. Look out for the indicative "address of primary server not in local db:" message in the logs.

SLIP and DNS

Based on a message from Cricket Liu

Cricket Liu recommends not running a name server at the site that connects via SLIP, but instead pointing the resolver at a single name server on the upstream side of the SLIP link. If the SLIP link isn't up, the resolver doesn't have a route to the server, and since there's only one name server in resolv.conf, the resolver quickly backs off to using /etc/hosts. This assumes a reasonable resolver, of course.

What is a Lame Delegation?

From Bryan Beecher

A lame delegation is an instance when a nameserver has been listed as authoritative for a domain, but does not seem to be performing authoritative service for that domain. That is, the nameserver appears to be answering out of its cache instead of out of its data. Note that even a server which is performing secondary service for a domain is still an authoritative server, and should be returning authoritative data.

Terminology: domain, zone, label

Based on a message from Paul Mockapetris

CNAMEs as RR targets

From RFC 1034, Domain Concepts and Facilities

Section 3.6.2, `Aliases and canonical names':

Domain names in RRs which point at another name should always point at the primary name and not the alias.

In other words, the names which are on the right hand side of a resource record (RR targets) should not be on the left hand side of a CNAME resource record. Depending on how smart the resolver software is CNAME targets may work fine, but depending on correct behaviour in resolvers all around the world is guaranteed to fail somewhere.

Local dummy zones

Based on a message from Dave Barr

To stop the DNS from doing a lookup when the request is to localhost, run a local caching-only nameserver which is set up to be a primary for "localhost" as well as "127.in-addr.arpa" and include the necessary DNS data in those zones to resolve the respective names/addresses. Then point your /etc/resolv.conf to your local machine. To be extra safe from DNS corruption set the server up as a primary for "255.in-addr.arpa" and "0.in-addr.arpa" also.

Legal characters in hostnames

Domain names can contain almost any characters. However, host names and mail domain names have restrictions which only allow the use of characters `a-z', `A-Z', `0-9', and `-' (dash or minus sign). The `/' and `_' (divide or slash and underscore) characters are not legal. Note that hostnames include the owners of A and MX records and .in-addr.arpa PTR records, and the data fields of MX and .in-addr.arpa PTR records: in other words, almost all currently used DNS entries! The current releases of the BIND name server software enforce these restrictions. 20-Nov-1997, 10-Apr-1996

Checking if a domain is registered already

Since the DNS database is highly distributed, DNS does not support wildcard searching, and extraction of a complete list of domains is extremely difficult. Note that a domain name may be reserved without appearing in the DNS--there is no effective way to find out which names are reserved except to try to register them. However, to check if a domain name has been registered and appears in the DNS, there are a couple of possible approaches.

Checking the DNS
Using DNS query tools like dig or nslookup with query types SOA, NS, MX or A, information about the existence of a domain name can be obtained. This is the most general method, although it requires an exact guess to be made both of the type of records associated with the domain name and the name itself. Using a query type ANY can sometimes be effective, but can also result in misleading answers.
WHOIS lookups
Many parts of DNS have associated contact information kept in a separate database called WHOIS. If the domain being sought is in one of the InterNIC maintained zones, information about the domain will be stored in the InterNIC WHOIS database. A standard whois client can be used to query this database, currently located at rs.internic.net (there should also be an option to search WHOIS at most of the websites that offer domain registration services). For some domains, information is kept in WHOIS-like services like RWHOIS or in domain-specific WHOIS registries.
Brute force search of DNS zone file
If the zone file corresponding to the domain is available, standard text searching tools can be used to check the file for the domain or variants. This procedure is flexible and quick once the file has been obtained since it is performed off line. The zones ARPA, COM, EDU, GOV, INADDR.ARPA, MIL, NET, and ORG are available at the InterNIC, but permission first has to be obtained. Other zones may be available via ftp, but will usually need to be downloaded using the zone transfer mechanism of DNS.
Checking directories of web sites
Many domains have an associated web server, and often the web server for example.com is just www.example.com. The Netcraft list of web servers is large and searchable, so it could be used to search for domain names that are associated with an active web server.

Setting up a resolver

Based on a question by Aidan N.R. Low

Setting up the client side of DNS depends on the operating environment of the client. For a Unix machine, the resolver is configured through a text file, usually /etc/resolv.conf which commonly contains the IP address of the name server or servers which will be used to do the actual work. An adequate resolv.conf file contains just the one line

nameserver x.y.z.w
where x.y.z.w is the IP address of a suitable name server. Often this will be a server provided by the Internet service provider. It is a bad idea to point resolvers to name servers controlled by organisations with which there is no organisational relationship: the name server could be configured to return bogus information, especially if permission was not sought first for using the server.

For PC type resolvers there is usually a network configuration option which specifies the same information as resolv.conf. Each network stack tends to have its own set of configuration information. However, on MacOS, there are moves towards central network configuration.

For SunOS 4.x, the resolver is by default not set up to use DNS. The standard operating procedure to get SunOS to use DNS is in the comp.sys.sun FAQ, last I looked these were questions 1 and 2. In short,

Of these, the BIND option is recommended.

Solaris 2.x is also not set up to use DNS by default. In the file /etc/nsswitch.conf there is a line

hosts: files
which needs to be changed to
hosts: files dns
for the machine to use DNS.

Given a choice of servers, which one is queried?

Based on a question by Mark A. Dohm and answer by Paul Vixie

Every recursive BIND name server (that is, one which is willing to go out and find something if asked something it doesn't know) will remember the measured round trip time (RTT) to each server it sends queries to. If it has a choice of several servers for some domain (like "." for example) it will use the one whose measured RTT is lowest.

Since the measured RTT of all NS RRs starts at zero (0), every one is tried once. Once all have responded, all RTT's will be nonzero, and the "fastest server" will get all queries henceforth, until it slows down for some reason.

To promote dispersion and good recordkeeping, BIND will penalize the RTT by a little bit each time a server is reused, and it will penalize the RTT a _lot_ if it ever has to retransmit a query. For a server to stay "#1", it has to keep on answering quickly and consistently.

Note that this is something BIND does that the DNS Specification does not mention at all. So other servers, those not based on BIND, might behave very differently.

Transferring zones from a server running Microsoft NT Server 4.0

Based on an answer by Stuart Kwan

If Microsoft's DNS server is integrated with WINS, it needs to be explicitly configured to interoperate with non-Microsoft name servers. Microsoft represents WINS information in the DNS using a nonstandard resource record type. This can cause a name server to fail when attempting a zone transfer from a Microsoft server. Older BIND servers may actually terminate when receiving such resource records in a zone transfer.

To correct the problem, ensure that the option "Zone Properties -> WINS Lookup -> Settings only affect local server" is set for each such zone on the Microsoft server.

How to do a zone transfer manually

Zone transfers can be done manually by using the ls command in the nslookup tool, or with the axfr pseudo-query-type in the dig tool. If a server is configured to disallow zone transfers, it may not be possible to easily obtain a copy of the zone file. 14-Jan-2000

Promoting a slave server to master

Based on a question by Flavien Bau

To promote a slave server (secondary) to be the master server (primary) for a zone, you need to

You can do the usual pre-change planning by reducing TTLs for the various records beforehand to speed up propagation and restoring them afterwards. But if your parent zone maintainer won't reduce TTLs of your NS records in their zone, the biggest delay is waiting for the parent to make the changes and to have these propagate, so tweaking TTLs is less effective. 30-May-2006


[Back to DNSRD]
Copyright 1994-2006 by András Salamon <andras@dns.net>

Last updated 30-May-2006