Imported Debian patch 1:1.05-8
[hcoop/zz_old/debian/djbdns.git] / debian / djbdns-man / dnscache.8
CommitLineData
b4588d5c
GP
1.TH dnscache 8
2
3.SH NAME
4dnscache \- a DNS cache.
5
6.SH DESCRIPTION
7This is a reference page.
8For tutorial information, see the instructions for
9.br
10.B workstations
11(http://cr.yp.to/djbdns/run-cache.html),
12.br
13.B home computers
14(http://cr.yp.to/djbdns/run-cache-home.html),
15.br
16.B external caches
17(http://cr.yp.to/djbdns/run-cache-x.html),
18or
19.br
20.B upgrading from BIND
21(http://cr.yp.to/djbdns/run-cache-bind-1.html).
22
23.B dnscache
24accepts recursive DNS queries
25from local clients such as web browsers and mail transfer agents.
26It collects responses from remote DNS servers.
27It caches the responses to save time later.
28
29.SH Configuration
30Normally
31.B dnscache
32is set up by the
33.BR dnscache-conf (8)
34program.
35
36.B dnscache
37runs chrooted in the directory
38specified by the
39.I $ROOT
40environment variable,
41under the uid and gid
42specified by the
43.I $UID
44and
45.I $GID
46environment variables.
47
48.B dnscache
49listens for incoming UDP packets and TCP connections
50addressed to port 53 of
51.IR $IP .
52Typically
53.I $IP
54is
55.IR 127.0.0.1 ,
56but it can also be an externally accessible IP address.
57
58.B dnscache
59accepts a packet or connection
60from IP address
61.I 1.2.3.4
62if it sees a file named
63.I ip/1.2.3.4
64or
65.I ip/1.2.3
66or
67.I ip/1.2
68or
69.IR ip/1 .
70
71.B dnscache
72sends outgoing packets from high ports of
73.IR $IPSEND .
74Typically
75.I $IPSEND
76is
77.IR 0.0.0.0 ,
78meaning the machine's primary IP address.
79
80.B dnscache
81reads a seed, up to 128 bytes,
82from standard input,
83and passes the seed to
84dns_random_init.
85
86.B dnscache
87reads a list of dotted-decimal root server IP addresses,
88one address per line,
89from
90.IR servers/@ .
91It also scans the
92.I servers
93directory
94for server IP addresses for other domains.
95If there are addresses listed in
96.IR servers/moon.af.mil ,
97for example,
98then
99.B dnscache
100will send queries for
101.I anything.moon.af.mil
102to those addresses,
103and will not cache records for
104.I anything.moon.af.mil
105from outside servers such as the root servers.
106
107Versions 1.03 and above:
108If
109.I $FORWARDONLY
110is set,
111.B dnscache
112treats
113.I servers/@
114as a list of IP addresses
115for other caches, not root servers.
116It forwards queries to those caches the same way that a client does,
117rather than contacting a chain of servers according to NS records.
118
119.SH Memory use
120
121.B dnscache
122uses a fixed-size table, under 256K,
123to keep track of as many as 200 simultaneous UDP queries
124and 20 simultaneous TCP connections.
125It also dynamically allocates memory,
126usually just a few bytes but occasionally much more,
127for each active query.
128If it runs out of memory handling a query, it discards that query.
129
130.B dnscache
131asks the operating system to reserve a 128K buffer
132for bursts of incoming UDP queries.
133In versions 1.03 and above,
134if a new UDP query arrives
135when
136.B dnscache
137is already handling 200 simultaneous UDP queries,
138.B dnscache
139drops the oldest query.
140If a new TCP connection arrives
141when
142.B dnscache
143is already handling 20 simultaneous TCP connections,
144.B dnscache
145drops the oldest connection.
146
147.B dnscache
148uses a fixed-size cache,
149as controlled by the
150.I $CACHESIZE
151environment variable.
152Roughly 5% of the cache is used for a hash table.
153The rest is used for cache entries
154(including 8-byte Y2038-compliant expiration times):
155
156.TP
157o
158A sets.
15922 bytes plus 4 bytes per address plus the length of the owner name.
160.TP
161o
162NS sets or PTR sets or CNAME sets.
16322 bytes plus the length of the owner name and all the data names.
164.TP
165o
166MX sets.
16722 bytes plus 2 bytes per MX plus the length of all the names.
168.TP
169o
170Other record sets.
17122 bytes plus 2 bytes per record
172plus the length of all the data strings
173plus the length of the owner name.
174.TP
175o
176Nonexistent domain or server failure.
17722 bytes plus the length of the owner name.
178
179.P
180Sets larger than 8192 bytes are not cached.
181
182.B dnscache
183does not exit when it runs out of space in its cache;
184it simply removes the oldest entries to make more space.
185
186.SH Resolution and caching policies
187
188.B dnscache
189relies on a configured list of root name servers.
190In contrast, BIND starts from a ``hint file'' listing name servers,
191and asks those name servers where the root name servers are.
192
193.B dnscache
194does not cache (or pass along) records outside the server's bailiwick;
195those records could be poisoned.
196Records for
197.IR foo.dom ,
198for example,
199are accepted only from the root servers,
200the
201.I dom
202servers, and the
203.I foo.dom
204servers.
205
206.B dnscache
207does not bypass its cache
208to obtain glue from the additional section of a response.
209In particular, it will not use glue outside the server's bailiwick,
210or glue with TTL 0,
211or glue that violates other caching policies.
212
213.B dnscache
214caches records for at most a week.
215It interprets TTLs above 2147483647 as 0.
216
217.B dnscache
218does not cache SOA records.
219However, it does use SOA TTLs to determine cache times (up to an hour)
220for zero-record responses and nonexistent domains.
221
222.SH Responses to DNS clients
223
224.BR dnscache 's
225responses are generally much smaller than BIND's responses.
226They do not include
227authority records
228(NS records of the source name servers
229and SOA records for negative answers)
230or additional records
231(A records relevant to NS or MX records).
232When the answer section is truncated by UDP length limits,
233it is eliminated entirely.
234
235.B dnscache
236tries to prevent local users from snooping on other local users.
237It discards non-recursive queries;
238it discards inverse queries;
239and it discards zone-transfer requests.
240If
241.I $HIDETTL
242is set,
243.B dnscache
244always uses a TTL of 0 in its responses.
245In versions before 1.03,
246.B dnscache
247always uses a TTL of 0 in its responses.
248
249According to RFC 1035,
250the AA bit ``specifies that the responding name server
251is an authority for the domain name in question section.''
252
253.B dnscache
254is not an authority for any domain names.
255
256.B dnscache
257never sets the AA bit
258(except in NXDOMAIN responses, as required by RFC 2308,
259to work around a common client bug).
260In contrast, BIND often sets AA for positive responses
261even when it is not an authority for the domain name.
262(This appears to have been fixed in BIND 9.)
263
264.SH Repeated IP addresses
265If a server
266sends
267.B dnscache
268a repeated IP address,
269.B dnscache
270passes the repeated IP address along to the client.
271The server's behavior violates RFC 2181, section 5.5,
272but there are reasonable uses of repeated IP addresses for load balancing,
273so
274.B dnscache
275does not go out of its way to remove repetitions when they occur.
276
277A widespread BIND server bug (apparently fixed in BIND 9.1)
278can unintentionally produce repeated IP addresses.
279Here is an example from one of the BIND company's servers (now fixed):
280
281 % dnsq a ns-ext.vix.com ns-ext.vix.com
282 1 ns-ext.vix.com:
283 117 bytes, 1+1+2+2 records, response, authoritative, noerror
284 query: 1 ns-ext.vix.com
285 answer: ns-ext.vix.com 3600 A 204.152.184.64
286 authority: vix.com 3600 NS ns-ext.vix.com
287 authority: vix.com 3600 NS ns1.gnac.com
288 additional: ns-ext.vix.com 3600 A 204.152.184.64
289 additional: ns1.gnac.com 130768 A 209.182.195.77
290
291This BIND bug is the most common reason
292for users to see repeated IP addresses from
293.BR dnscache .
294
295.SH Special names
296
297.B dnscache
298handles
299.I localhost
300internally,
301giving it an A record of 127.0.0.1.
302
303.B dnscache
304handles
305.I 1.0.0.127.in-addr.arpa
306internally,
307giving it a PTR record of
308.IR localhost .
309
310.B dnscache
311handles dotted-decimal domain names internally,
312giving (e.g.) the domain name
313.I 192.48.96.2
314an A record of
315.IR 192.48.96.2 .
316
317.SH SEE ALSO
318dnscache-conf(8)
319
320http://cr.yp.to/djbdns.html