Configuring DNS with the etcresolv.conf File


Configuring DNS with the /etc/resolv.conf File

To use true DNS, you need access to at least one domain name server. It doesn't matter where this server ismost name servers are configured to allow queries from anywhere on the Internet, with no restrictions on who makes the queries. This practice is on the wane, however, and in most circumstances you will want to use only the name server addresses provided by your ISP or enterprise network administrator.

Name servers are specified in the /etc/resolv.conf file, an example of which follows:

search example.com nameserver 64.41.131.132 nameserver 207.78.98.20 nameserver 64.40.111.102


The nameserver keyword specifies a name server's IP address; you can have as many of these as you like, and the order in which they're listed is the order in which they're consulted. If one times out, the next server is queried. Many applications have their own internal timeouts on a DNS query that gets passed to the operating system to handle, though, so servers beyond the third or fourth probably won't provide much additional benefit.

The search keyword specifies the search domainthe string appended to hostnames that aren't fully qualified. For instance, if you were to do an nslookup www, the resolver would attach the search domain and perform the actual query on www.example.com. You can list multiple search paths on the same line:

search example.com foobar.com cslab.ivyleague.edu


Technically, /etc/resolv.conf is just a backup and override file, like /etc/hosts. Ideally, or at least according to design, a system should be running its own DNS daemon, which inherits its information from a master name server upstream. DNS queries, by default, are always checked against the local system's DNS if it's running. However, in the real world, DNS is just another service to administer with more potential security risks, and thus you don't want to be running DNS unless you have to. It's necessary these days to have an accurate resolv.conf file containing two or three remote name servers against which to perform name lookups. If you want to run DNS on your own machine, we'll cover how to do it in Chapter 32, "The Domain Name Server."

Tip

Fortunately, /etc/resolv.conf can be edited and modified at any time, without any special tools to update any databases or anything. DNS lookups are only done upon request by network applications, and the resolv.conf table is consulted only at those times and opened from the file on disk, not held in memory and queried constantly, as with IP interface configuration. You can open /etc/resolv.conf in your favorite text editor, change or add nameserver enTRies, shuffle the order in which they're queried, and so on. The next DNS query you make through any application will query against the newly modified /etc/resolv.conf.





FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net