]> git.ipfire.org Git - people/ms/dnsmasq.git/blame - dnsmasq.8
import of dnsmasq-2.6.tar.gz
[people/ms/dnsmasq.git] / dnsmasq.8
CommitLineData
9e4abcb5
SK
1.TH DNSMASQ 8
2.SH NAME
3dnsmasq \- A lightweight DHCP and caching DNS server.
4.SH SYNOPSIS
5.B dnsmasq
6.I [OPTION]...
7.SH "DESCRIPTION"
8.BR dnsmasq
9is a lightweight DNS and DHCP server. It is intended to provide coupled DNS and DHCP service to a
10LAN.
11.PP
12Dnsmasq accepts DNS queries and either answers them from a small, local,
13cache or forwards them to a real, recursive, DNS server. It loads the
14contents of /etc/hosts so that local hostnames
15which do not appear in the global DNS can be resolved and also answers
16DNS queries for DHCP configured hosts.
17.PP
18.BR dnsmasq
19supports IPv6.
20.PP
21.BR dnsmasq
22is lightweight and easy to configure. It is intended as be run on
23small router/firewalls and provide a DNS (and optionally, DHCP) service to a LAN.
24.SH OPTIONS
25Note that in general missing parameters are allowed and switch off
33820b7e
SK
26functions, for instance "--pid-file=" disables writing a PID file. On
27BSD, unless the GNU getopt library is linked, the long form of the
28options does not work on the command line; it is still recognised in
29the configuration file.
9e4abcb5
SK
30.TP
31.B \-h, --no-hosts
32Don't read the hostnames in /etc/hosts.
33.TP
34.B \-H, --addn-hosts=<file>
35Additional hosts file. Read the specified file as well as /etc/hosts. If -h is given, read
36only the specified file. At most one additional hosts file may be
37given.
38.TP
39.B \-T, --local-ttl=<time>
40When replying with information from /etc/hosts or the DHCP leases
41file dnsmasq by default sets the time-to-live field to zero, meaning
42that the requestor should not itself cache the information. This is
43the correct thing to do in almost all situations. This option allows a
44time-to-live (in seconds) to be given for these replies. This will
45reduce the load on the server at the expense of clients using stale
46data under some circumstances.
47.TP
48.B \-d, --no-daemon
49Debug mode: don't fork to the background, don't write a pid file,
50don't change user id, generate a complete cache dump on receipt on
51SIGUSR1, log to stderr as well as syslog.
52.TP
53.B \-q, --log-queries
54Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1.
55.TP
56.B \-x, --pid-file=<path>
57Specify an alternate path for dnsmasq to record its process-id in. Normally /var/run/dnsmasq.pid.
58.TP
59.B \-u, --user=<username>
60Specify the userid to which dnsmasq will change after startup. Dnsmasq must normally be started as root, but it will drop root
61priviledges after startup by changing id to another user. Normally this user is "nobody" but that
62can be over-ridden with this switch.
63.TP
64.B \-g, --group=<groupname>
65Specify the group which dnsmasq will run
66as. The defaults to "dip", if available, to facilitate access to
67/etc/ppp/resolv.conf which is not normally world readable.
68.TP
69.B \-v, --version
70Print the version number.
71.TP
72.B \-p, --port=<port>
73Listen on <port> instead of the standard DNS port (53). Useful mainly for
74debugging.
75.TP
76.B \-Q, --query-port=<query_port>
77Send outbound DNS queries from, and listen for their replies on, the specific UDP port <query_port> instead of using one chosen at runtime. Useful to simplify your
78firewall rules; without this, your firewall would have to allow connections from outside DNS servers to a range of UDP ports, or dynamically adapt to the
79port being used by the current dnsmasq instance.
80.TP
81.B \-i, --interface=<interface name>
82Listen only on the specified interface. More than one interface may be specified. Dnsmasq always listens on the loopback (local) interface. If no
83.B \-i
84flags are given, dnsmasq listens on all available interfaces unless overridden by
85.B \-a
86or
87.B \-I
8a911ccc
SK
88flags. If IP alias interfaces (eg "eth1:0") are used with
89.B --interface
90or
91.B --except-interface
92options, then the
93.B --bind-interfaces
94option will be automatically set. This is required for deeply boring
95sockets-API reasons.
9e4abcb5
SK
96.TP
97.B \-I, --except-interface=<interface name>
98Do not listen on the specified interface.
99.TP
44a2a316 100.B \-a, --listen-address=<ipaddr>
9e4abcb5
SK
101Listen only on the given IP address. As with
102.B \-i
103more than one address may be specified. Unlike
104.B \-i
105the loopback interface is not special: if dnsmasq is to listen on the loopback interface,
106it's IP, 127.0.0.1, must be explicitly given. If no
107.B \-a
108flags are given, dnsmasq listens on all available interfaces unless overridden by
109.B \-i
110or
111.B \-I
112flags.
113.TP
44a2a316
SK
114.B \-z, --bind-interfaces
115On systems which support it, dnsmasq binds the wildcard address,
116even when it is listening on only some interfaces. It then discards
117requests that it shouldn't reply to. This has the advantage of
118working even when interfaces come and go and change address. This
119option forces dnsmasq to really bind only the interfaces it is
120listening on. About the only time when this is useful is when
8a911ccc
SK
121running another nameserver on the same machine or using IP
122alias. Specifying interfaces with IP alias automatically turns this
123option on.
44a2a316 124.TP
9e4abcb5
SK
125.B \-b, --bogus-priv
126Bogus private reverse lookups. All reverse lookups for private IP ranges (ie 192.168.x.x, etc)
127which are not found in /etc/hosts or the DHCP leases file are resolved to the IP address in dotted-quad form.
128.TP
1cff166d
SK
129.B \-V, --alias=<old-ip>,<new-ip>[,<mask>]
130Modify IPv4 addresses returned from upstream nameservers; old-ip is
131replaced by new-ip. If the optional mask is given then any address
132which matches the masked old-ip will be re-written. So, for instance
133.B --alias=1.2.3.0,6.7.8.0,255.255.255.0
134will map 1.2.3.56 to 6.7.8.56 and 1.2.3.67 to 6.7.8.67. This is what
135Cisco PIX routers call "DNS doctoring".
136.TP
9e4abcb5
SK
137.B \-B, --bogus-nxdomain=<ipaddr>
138Transform replies which contain the IP address given into "No such
139domain" replies. This is intended to counteract a devious move made by
140Versign in September 2003 when they started returning the address of
141an advertising web page in response to queries for unregistered names,
142instead of the correct NXDOMAIN response. This option tells dnsmasq to
143fake the correct response when it sees this behaviour. As at Sept 2003
144the IP address being returnd by Verisign is 64.94.110.11
145.TP
146.B \-f, --filterwin2k
147Later versions of windows make periodic DNS requests which don't get sensible answers from
148the public DNS and can cause problems by triggering dial-on-demand links. This flag turns on an option
149to filter such requests. The requests blocked are for records of types SOA and SRV, and type ANY where the
150requested name has underscores, to catch LDAP requests.
151.TP
152.B \-r, --resolv-file=<file>
153Read the IP addresses of the upstream nameservers from <file>, instead of
154/etc/resolv.conf. For the format of this file see
155.BR resolv.conf (5)
156the only lines relevant to dnsmasq are nameserver ones. Dnsmasq can
157be told to poll more than one resolv.conf file, the first file name specified
158overrides the default, subsequent ones add to the list. This is only
159allowed when polling; the file with the currently latest modification
160time is the one used.
161.TP
162.B \-R, --no-resolv
163Don't read /etc/resolv.conf. Get upstream servers only from the command
b49644f3 164line or the dnsmasq configuration file.
9e4abcb5
SK
165.TP
166.B \-o, --strict-order
167By default, dnsmasq will send queries to any of the upstream servers
168it knows about and tries to favour servers to are known to
169be up. Setting this flag forces dnsmasq to try each query with each
170server strictly in the order they appear in /etc/resolv.conf
171.TP
172.B \-n, --no-poll
173Don't poll /etc/resolv.conf for changes.
174.TP
175.B \-D, --domain-needed
176Tells dnsmasq to never forward queries for plain names, without dots
177or domain parts, to upstream nameservers. If the name is not knowm
178from /etc/hosts or DHCP then a "not found" answer is returned.
179.TP
180.B \-S, --server=[/[<domain>]/[domain/]][<ipaddr>[#<port>][@<source>[#<port>]]]
181Specify IP address of upsream severs directly. Setting this flag does
182not suppress reading of /etc/resolv.conf, use -R to do that. If one or
183more
184optional domains are given, that server is used only for those domains
185and they are queried only using the specified server. This is
186intended for private nameservers: if you have a nameserver on your
187network which deals with names of the form
188xxx.internal.thekelleys.org.uk at 192.168.1.1 then giving the flag
189.B -S /internal.thekelleys.org.uk/192.168.1.1
190will send all queries for
191internal machines to that nameserver, everything else will go to the
192servers in /etc/resolv.conf. An empty domain specification,
193.B //
194has the special meaning of "unqualified names only" ie names without any
195dots in them. A non-standard port may be specified as
196part of the IP
197address using a # character.
198More than one -S flag is allowed, with
199repeated domain or ipaddr parts as required.
200
201Also permitted is a -S
202flag which gives a domain but no IP address; this tells dnsmasq that
203a domain is local and it may answer queries from /etc/hosts or DHCP
204but should never forward queries on that domain to any upstream
205servers.
206.B local
207is a synonym for
208.B server
209to make configuration files clearer in this case.
210
211The optional second IP address after the @ character tells
212dnsmasq how to set the source address of the queries to this
213nameserver. It should be an address belonging to the machine on which
214dnsmasq is running otherwise this server line will be logged and then
215ignored. The query-port flag is ignored for any servers which have a
216source address specified but the port may be specified directly as
217part of the source address.
218.TP
219.B \-A, --address=/<domain>/[domain/]<ipaddr>
220Specify an IP address to return for any host in the given domains.
221Queries in the domains are never forwarded and always replied to
222with the specified IP address which may be IPv4 or IPv6. To give
223both IPv4 and IPv6 addresses for a domain, use repeated -A flags.
224Note that /etc/hosts and DHCP leases override this for individual
225names. A common use of this is to redirect the entire doubleclick.net
226domain to some friendly local web server to avoid banner ads.
227.TP
228.B \-m, --mx-host=<mx name>
229Return an MX record named <mx name> pointing to the host specified in the --mx-target switch
230or, if that switch is not given, the host on which dnsmasq
231is running. This is useful for directing mail from systems on a LAN
232to a central server.
233.TP
234.B \-t, --mx-target=<hostname>
235Specify target for the MX record returned by dnsmasq. See --mx-host. Note that to turn on the MX function,
236at least one of --mx-host and --mx-target must be set. If only one of --mx-host and --mx-target
237is set, the other defaults to the hostname of the machine on which dnsmasq is running.
238.TP
239.B \-e, --selfmx
240Return an MX record pointing to itself for each local
241machine. Local machines are those in /etc/hosts or with DHCP leases.
242.TP
243.B \-L, --localmx
244Return an MX record pointing to the host given by mx-target (or the
245machine on which dnsmasq is running) for each
246local machine. Local machines are those in /etc/hosts or with DHCP
247leases.
248.TP
249.B \-c, --cache-size=<cachesize>
250Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching.
251.TP
252.B \-N, --no-negcache
253Disable negative caching. Negative caching allows dnsmasq to remember
254"no such domain" answers from upstream nameservers and answer
255identical queries without forwarding them again. This flag disables
256negative caching.
257.TP
44a2a316 258.B \-F, --dhcp-range=[network-id,]<start-addr>,<end-addr>[[,<netmask>],<broadcast>][,<default lease time>]
9e4abcb5 259Enable the DHCP server. Addresses will be given out from the range
44a2a316
SK
260<start-addr> to <end-addr> and from statically defined addresses given
261in
262.B dhcp-host
263options. If the lease time is given, then leases
9e4abcb5
SK
264will be given for that length of time. The lease time is on seconds,
265or minutes (eg 45m) or hours (eg 1h) or the literal "infinite". This
266option may be repeated, with different addresses, to enable DHCP
44a2a316
SK
267service to more than one network. For directly connected networks (ie,
268networks on which the machine running dnsmasq has an interface) the
269netmask is optional. It is, however, required for networks which
270recieve DHCP service via a relay agent. The broadcast address is
271always optional. On some broken systems, dnsmasq can listen on only
272one interface when using DHCP, and the name of that interface must be
273given using the
274.B interface
275option. This limitation currently affects OpenBSD. The optional
276network-id is a alphanumeric label which marks this network so that
33820b7e
SK
277dhcp options may be specified on a per-network basis. The end address
278may be replaced by the keyword
279.B static
280which tells dnsmasq to enable DHCP for the network specified, but not
281to dynamically allocate IP addresses. Only hosts which have static
282addresses given via
283.B dhcp-host
284or from /etc/ethers will be served.
9e4abcb5 285.TP
33820b7e 286.B \-G, --dhcp-host=[[<hwaddr>]|[id:<client_id>]][net:<netid>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
9e4abcb5
SK
287Specify per host parameters for the DHCP server. This allows a machine
288with a particular hardware address to be always allocated the same
289hostname, IP address and lease time. A hostname specified like this
290overrides any supplied by the DHCP client on the machine. It is also
291allowable to ommit the hardware address and include the hostname, in
292which case the IP address and lease times will apply to any machine
293claiming that name. For example
294.B --dhcp-host=00:20:e0:3b:13:af,wap,infinite
295tells dnsmasq to give
296the machine with ethernet address 00:20:e0:3b:13:af the name wap, and
297an infinite DHCP lease.
298.B --dhcp-host=lap,192.168.0.199
299tells
300dnsmasq to always allocate the machine lap the IP address
1ab84e2f 301192.168.0.199. Addresses allocated like this are not constrained to be
9e4abcb5
SK
302in the range given by the --dhcp-range option, but they must be on the
303network being served by the DHCP server. It is allowed to use client identifiers rather than
304hardware addresses to identify hosts by prefixing with 'id:'. Thus:
305.B --dhcp-host=id:01:02:03:04,.....
306refers to the host with client identifier 01:02:03:04. It is also
307allowed to specify the client ID as text, like this:
308.B --dhcp-host=id:clientidastext,.....
1ab84e2f
SK
309If a name appears in /etc/hosts, the associated address can be
310allocated to a DHCP lease, but only if a
311.B --dhcp-host
33820b7e
SK
312option specifying the name also exists. The special keyword "ignore"
313tells dnsmasq to never offer a DHCP lease to a machine. The machine
314can be specified by hardware address, client ID or hostname, for
315instance
316.B --dhcp-host=00:20:e0:3b:13:af,ignore
317This is
318useful when there is another DHCP server on the network which should
319be used by some machines. The net:<network-id> parameter enables DHCP options just
320for this host in the same way as the the network-id in
321.B dhcp-range.
44a2a316
SK
322.TP
323.B \-Z, --read-ethers
324Read /etc/ethers for information about hosts for the DHCP server. The
325format of /etc/ethers is a hardware address, followed by either a
326hostname or dotted-quad IP address. When read by dnsmasq these lines
327have exactly the same effect as
328.B --dhcp-host
329options containing the same information.
9e4abcb5 330.TP
44a2a316 331.B \-O, --dhcp-option=[network-id,]<opt>,[<value>[,<value>]]
9e4abcb5
SK
332Specfify different or extra options to DHCP clients. By default,
333dnsmasq sends some standard options to DHCP clients, the netmask and
334broadcast address are set to the same as the host running dnsmasq, and
335the DNS server and default route are set to the address of the machine
336running dnsmasq. If the domain name option has been set, that is sent.
337This option allows these defaults to be overridden,
338or other options specified. The <opt> is the number of the option, as
339specfied in RFC2132. For example, to set the default route option to
340192.168.4.4, do
341.B --dhcp-option=3,192.168.4.4
342and to set the time-server address to 192.168.0.4, do
343.B dhcp-option=42,192.168.0.4
1ab84e2f 344The special address 0.0.0.0 is taken to mean "the address of the
33820b7e
SK
345machine running dnsmasq". Data types allowed are comma seperated
346dotted-quad IP addresses, a decimal number, colon-seperated hex digits
347and a text string. If the optional network-id is given then
44a2a316
SK
348this option is only sent to machines on the network whose dhcp-range
349contains a matching network-id.
9e4abcb5
SK
350Be careful: no checking is done that the correct type of data for the
351option number is sent, and there are option numbers for which it is not
352possible to generate the correct data type; it is quite possible to
353persuade dnsmasq to generate illegal DHCP packets with injudicious use
354of this flag.
355.TP
356.B \-M, --dhcp-boot=<filename>,[<servername>[,<server address>]]
357Set BOOTP options to be returned by the DHCP server. These are needed
358for machines which network boot, and tell the machine where to collect
359its initial configuration.
360.TP
44a2a316
SK
361.B \-X, --dhcp-lease-max=<number>
362Limits dnsmasq to the specified maximum number of DHCP leases. The
363default is 150. This limit is to prevent DoS attacks from hosts which
364create thousands of leases and use lots of memory in the dnsmasq
365process.
366.TP
9e4abcb5 367.B \-l, --dhcp-leasefile=<path>
33820b7e
SK
368Use the specified file to store DHCP lease information. If this option
369is given but no dhcp-range option is given then dnsmasq version 1
370behaviour is activated. The file given is assumed to be an ISC dhcpd
371lease file and parsed for leases which are then added to the DNS
372system if they have a hostname. This functionality may have been
373excluded from dnsmasq at compile time, in which case an error will occur.
9e4abcb5
SK
374.TP
375.B \-s, --domain=<domain>
376Specifies the domain for the DHCP server. This has two effects;
377firstly it causes the DHCP server to return the domain to any hosts
378which request it, and secondly it sets the domain which it is legal
379for DHCP-configured hosts to claim. The intention is to constrain hostnames so that an untrusted host on the LAN cannot advertise it's name via dhcp as e.g. "microsoft.com" and capture traffic not meant for it. If no domain suffix is specified, then any DHCP hostname with a domain part (ie with a period) will be disallowed and logged. If suffix is specified, then hostnames with a domain part are allowed, provided the domain part matches the suffix. In addition, when a suffix is set then hostnames without a domain part have the suffix added as an optional domain part. Eg on my network I can set
380.B --domain-suffix=thekelleys.org.uk
381and have a machine whose DHCP hostname is "laptop". The IP address for that machine is available from
382.B dnsmasq
383both as "laptop" and "laptop.thekelleys.org.uk".
384.TP
385.B \-E, --expand-hosts
386Add the domain-suffix to simple names (without a period) in /etc/hosts
387in the same way as for DHCP-derived names.
388.SH CONFIG FILE
b49644f3 389At startup, dnsmasq reads /etc/dnsmasq.conf, if it exists. (On
33820b7e 390FreeBSD and OpenBSD, the file is /usr/local/etc/dnsmasq.conf) The format of this
9e4abcb5
SK
391file consists of one option per line, exactly as the long options detailed
392in the OPTIONS section but without the leading "--". Lines starting with # are comments and ignored. For
b49644f3 393options which may only be specified once, the configuration file overrides
9e4abcb5 394the command line. Use the --conf-file option to specify a different
33820b7e
SK
395configuration file. The conf-file option is also allowed in
396configuration files, to include multiple configuration files. Only one
397level of nesting is allowed.
9e4abcb5
SK
398.SH NOTES
399When it receives a SIGHUP,
400.B dnsmasq
401clears its cache and then re-loads /etc/hosts. If
402.B
403--no-poll
404is set SIGHUP also re-reads /etc/resolv.conf. SIGHUP
b49644f3 405does NOT re-read the configuration file.
9e4abcb5
SK
406.PP
407When it receives a SIGUSR1,
408.B dnsmasq
409writes cache statistics to the system log. It writes the cache size,
410the number of names which have had to removed from the cache before
411they expired in order to make room for new names and the total number
412of names that have been inserted into the cache. In
413.B --no-daemon
414mode or when full logging is enabled (-q), a complete dump of the contents of the cache is made.
415.PP
9e4abcb5
SK
416Dnsmasq is a DNS query forwarder: it it not capable of recursively
417answering arbitrary queries starting from the root servers but
418forwards such queries to a fully recursive upstream DNS server which is
419typically provided by an ISP. By default, dnsmasq reads
420/etc/resolv.conf to discover the IP
421addresses of the upstream nameservers it should use, since the
422information is typically stored there. Unless
423.B --no-poll
424is used,
425.B dnsmasq
426checks the modification time of /etc/resolv.conf (or
427equivalent if
428.B \--resolv-file
429is used) and re-reads it if it changes. This allows the DNS servers to
430be set dynamically by PPP or DHCP since both protocols provide the
431information.
432Absence of /etc/resolv.conf is not an error
433since it may not have been created before a PPP connection exists. Dnsmasq
434simply keeps checking in case /etc/resolv.conf is created at any
435time. Dnsmasq can be told to parse more than one resolv.conf
436file. This is useful on a laptop, where both PPP and DHCP may be used:
437dnsmasq can be set to poll both /etc/ppp/resolv.conf and
438/etc/dhcpc/resolv.conf and will use the contents of whichever changed
439last, giving automatic switching between DNS servers.
440.PP
441Upstream servers may also be specified on the command line or in
b49644f3 442the configuration file. These server specifications optionally take a
9e4abcb5
SK
443domain name which tells dnsmasq to use that server only to find names
444in that particular domain.
445.PP
446In order to configure dnsmasq to act as cache for the host on which it is running, put "nameserver 127.0.0.1" in
447.I /etc/resolv.conf
448to force local processes to send queries to
449dnsmasq. Then either specify the upstream servers directly to dnsmasq
450using
451.B \--server
452options or put their addresses real in another file, say
453.I /etc/resolv.dnsmasq
454and run dnsmasq with the
455.B \-r /etc/resolv.dnsmasq
456option. This second technique allows for dynamic update of the server
457addresses by PPP or DHCP.
458.SH FILES
b49644f3
SK
459.IR /etc/dnsmasq.conf
460
461.IR /usr/local/etc/dnsmasq.conf
9e4abcb5
SK
462
463.IR /etc/resolv.conf
464
465.IR /etc/hosts
466
b49644f3
SK
467.IR /var/lib/misc/dnsmasq.leases
468
469.IR /var/db/dnsmasq.leases
9e4abcb5
SK
470
471.IR /var/run/dnsmasq.pid
472.SH SEE ALSO
9e4abcb5
SK
473.BR hosts (5),
474.BR resolver (5)
475.SH AUTHOR
476This manual page was written by Simon Kelley <simon@thekelleys.org.uk>.
477
478