Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
25
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

...............................................................................................

# dig AbsoluteBSD.com +norecurse

...............................................................................................

Try this one now, with a domain that you're pretty certain your local nameserver has never looked at. My favorite DNS server test site is http://www.moo.com/, simply because it's cool, obscure, cute, mostly harmless, and nobody ever looks at it. You're almost guaranteed that nobody on your nameserver has looked at http://moo.com/ lately.

If your nameserver doesn't have this information cached, or if this information has expired from the cache, your first section will look much like that of our previous example. The authority section, however, will look quite different:

...............................................................................................

;; AUTHORITY SECTION:

com.

18h9m59s IN NS A.GTLD−SERVERS.NET.

com.

18h9m59s IN NS G.GTLD−SERVERS.NET.

com.

18h9m59s IN NS H.GTLD−SERVERS.NET.

com.

18h9m59s IN NS C.GTLD−SERVERS.NET.

com.

18h9m59s IN NS I.GTLD−SERVERS.NET.

com.

18h9m59s IN NS B.GTLD−SERVERS.NET.

com.

18h9m59s IN NS D.GTLD−SERVERS.NET.

com.

18h9m59s IN NS L.GTLD−SERVERS.NET.

com.

18h9m59s IN NS F.GTLD−SERVERS.NET.

com.

18h9m59s IN NS J.GTLD−SERVERS.NET.

com.

18h9m59s IN NS K.GTLD−SERVERS.NET.

com.

18h9m59s IN NS E.GTLD−SERVERS.NET.

com.

18h9m59s IN NS M.GTLD−SERVERS.NET.

...............................................................................................

The nameservers under GTLD−SERVERS.NET are the root servers. They contain the master lists of which nameservers control which domains. By giving you this output, your local nameserver is saying, "I don't know, I'll have to go ask someone else, but you told me to not recurse so I'm stopping here."

To query a root nameserver, combine the norecurse option and server name dig commands and try your query again:

...............................................................................................

# dig @a.gtld−servers.net +norecurse www.moo.com

...............................................................................................

Follow the chain of information for a site or two, and you'll start to really understand how DNS works.

Configuring a DNS Client: The Resolver

Before you can have your system use a DNS server, you must tell the computer which nameserver to use, and how it should be used. Even a DNS server needs to have the client portion of

273

nameservice set up, because the computer won't know it has a nameserver running unless you tell it! Just about anything you do on a network will require a working nameservice client. Use keywords in /etc/resolv.conf to tell your system's resolver where to look for information.

Domain or Search Keywords

When you're working on machines on your own network, you don't want to have to type the whole hostname. (If you have 30 Web servers, typing ssh www19.mycompany.com gets old.) To tell the resolver which domains to check by default, use either a domain or a search keyword in /etc/resolv.conf.

Specifying the Local Domain

The domain keyword tells the resolver which local domain name to check, by default, for hosts. For example, to specify http://absolutebsd.com/ as the local domain, enter this:

...............................................................................................

domain AbsoluteBSD.com

...............................................................................................

Once the local domain is specified, any command that would ordinarily require a domain name will be assumed to be pointing to http://absolutebsd.com/. Were I to ping www, the resolver would append the name http://www.absolutebsd.com/ to that and tell ping to try http://www.absolutebsd.com/.

Specifying a List of Domains with Search

Alternatively, I can use the search keyword to specify a list of domains to try. Perhaps my company has several domain names in use in different parts of the network—I could enter the following:

...............................................................................................

search http://absolutebsd.com/ blackhelicopters.org stenchmaster.org

...............................................................................................

In this case, the resolver will check these three domain names in the order written, until it finds a match.

For example, if I enter ping petulance, it will try to find petulance.AbsoluteBSD.com. If that fails, it will check for petulance.blackhelicopters.org, the next domain in order. Finally, it will check for petulance.stenchmaster.com. If no such host exists in any of these domains, the command will eventually fail.

Note If you don't list either a domain or a search keyword, the resolver will use the local machine's domain name.

274