]> git.ipfire.org Git - people/ms/dnsmasq.git/blame - man/dnsmasq.8
Don't treat SERVFAIL as a recoverable error.....
[people/ms/dnsmasq.git] / man / 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
34d0a36a 9is a lightweight DNS, TFTP, PXE, router advertisement and DHCP server. It is intended to provide
5aabfc78 10coupled DNS and DHCP service to a LAN.
9e4abcb5
SK
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
ee415867
SK
16DNS queries for DHCP configured hosts. It can also act as the
17authoritative DNS server for one or more domains, allowing local names
18to appear in the global DNS. It can be configured to do DNSSEC
19validation.
9e4abcb5 20.PP
73a08a24
SK
21The dnsmasq DHCP server supports static address assignments and multiple
22networks. It automatically
3be34541 23sends a sensible default set of DHCP options, and can be configured to
f2621c7f 24send any desired set of DHCP options, including vendor-encapsulated
1b7ecd11 25options. It includes a secure, read-only,
34d0a36a 26TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP. The PXE support is full featured, and includes a proxy mode which supplies PXE information to clients whilst DHCP address allocation is done by another server.
9e4abcb5 27.PP
81925ab7
SK
28The dnsmasq DHCPv6 server provides the same set of features as the
29DHCPv4 server, and in addition, it includes router advertisements and
30a neat feature which allows nameing for clients which use DHCPv4 and
834f36fe 31stateless autoconfiguration only for IPv6 configuration. There is support for doing address allocation (both DHCPv6 and RA) from subnets which are dynamically delegated via DHCPv6 prefix delegation.
34d0a36a
SK
32.PP
33Dnsmasq is coded with small embedded systems in mind. It aims for the smallest possible memory footprint compatible with the supported functions, and allows uneeded functions to be omitted from the compiled binary.
9e4abcb5
SK
34.SH OPTIONS
35Note that in general missing parameters are allowed and switch off
832af0ba 36functions, for instance "--pid-file" disables writing a PID file. On
33820b7e
SK
37BSD, unless the GNU getopt library is linked, the long form of the
38options does not work on the command line; it is still recognised in
39the configuration file.
9e4abcb5 40.TP
7622fc06
SK
41.B --test
42Read and syntax check configuration file(s). Exit with code 0 if all
43is OK, or a non-zero code otherwise. Do not start up dnsmasq.
44.TP
9e4abcb5
SK
45.B \-h, --no-hosts
46Don't read the hostnames in /etc/hosts.
47.TP
48.B \-H, --addn-hosts=<file>
49Additional hosts file. Read the specified file as well as /etc/hosts. If -h is given, read
fd9fa481 50only the specified file. This option may be repeated for more than one
7622fc06 51additional hosts file. If a directory is given, then read all the files contained in that directory.
9e4abcb5 52.TP
832af0ba
SK
53.B \-E, --expand-hosts
54Add the domain to simple names (without a period) in /etc/hosts
1f15b81d
SK
55in the same way as for DHCP-derived names. Note that this does not
56apply to domain names in cnames, PTR records, TXT records etc.
832af0ba 57.TP
9e4abcb5
SK
58.B \-T, --local-ttl=<time>
59When replying with information from /etc/hosts or the DHCP leases
60file dnsmasq by default sets the time-to-live field to zero, meaning
c72daea8 61that the requester should not itself cache the information. This is
9e4abcb5
SK
62the correct thing to do in almost all situations. This option allows a
63time-to-live (in seconds) to be given for these replies. This will
64reduce the load on the server at the expense of clients using stale
65data under some circumstances.
66.TP
824af85b
SK
67.B --neg-ttl=<time>
68Negative replies from upstream servers normally contain time-to-live
69information in SOA records which dnsmasq uses for caching. If the
70replies from upstream servers omit this information, dnsmasq does not
71cache the reply. This option gives a default value for time-to-live
72(in seconds) which dnsmasq uses to cache negative replies even in
73the absence of an SOA record.
74.TP
8ef5ada2
SK
75.B --max-ttl=<time>
76Set a maximum TTL value that will be handed out to clients. The specified
77maximum TTL will be given to clients instead of the true TTL value if it is
78lower. The true TTL value is however kept in the cache to avoid flooding
79the upstream DNS servers.
80.TP
1d860415
SK
81.B --max-cache-ttl=<time>
82Set a maximum TTL value for entries in the cache.
83.TP
28de3876
R
84.B --min-cache-ttl=<time>
85Extend short TTL values to the time given when caching them. Note that
86artificially extending TTL values is in general a bad idea, do not do it
87unless you have a good reason, and understand what you are doing.
88Dnsmasq limits the value of this option to one hour, unless recompiled.
89.TP
333b2ceb
SK
90.B --auth-ttl=<time>
91Set the TTL value returned in answers from the authoritative server.
92.TP
3be34541
SK
93.B \-k, --keep-in-foreground
94Do not go into the background at startup but otherwise run as
3d8df260
SK
95normal. This is intended for use when dnsmasq is run under daemontools
96or launchd.
3be34541 97.TP
9e4abcb5
SK
98.B \-d, --no-daemon
99Debug mode: don't fork to the background, don't write a pid file,
100don't change user id, generate a complete cache dump on receipt on
3be34541 101SIGUSR1, log to stderr as well as syslog, don't fork new processes
83b2198e
SK
102to handle TCP queries. Note that this option is for use in debugging
103only, to stop dnsmasq daemonising in production, use
104.B -k.
9e4abcb5
SK
105.TP
106.B \-q, --log-queries
25cf5e37
SK
107Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1. If the argument "extra" is supplied, ie
108.B --log-queries=extra
109then the log has extra information at the start of each line.
110This consists of a serial number which ties together the log lines associated with an individual query, and the IP address of the requestor.
9e4abcb5 111.TP
849a8357
SK
112.B \-8, --log-facility=<facility>
113Set the facility to which dnsmasq will send syslog entries, this
f2621c7f 114defaults to DAEMON, and to LOCAL0 when debug mode is in operation. If
9e038946 115the facility given contains at least one '/' character, it is taken to
f2621c7f 116be a filename, and dnsmasq logs to the given file, instead of
8ef5ada2
SK
117syslog. If the facility is '-' then dnsmasq logs to stderr.
118(Errors whilst reading configuration will still go to syslog,
f2621c7f 119but all output from a successful startup, and all output whilst
5aabfc78
SK
120running, will go exclusively to the file.) When logging to a file,
121dnsmasq will close and reopen the file when it receives SIGUSR2. This
122allows the log file to be rotated without stopping dnsmasq.
f2621c7f
SK
123.TP
124.B --log-async[=<lines>]
125Enable asynchronous logging and optionally set the limit on the
126number of lines
127which will be queued by dnsmasq when writing to the syslog is slow.
128Dnsmasq can log asynchronously: this
129allows it to continue functioning without being blocked by syslog, and
130allows syslog to use dnsmasq for DNS queries without risking deadlock.
131If the queue of log-lines becomes full, dnsmasq will log the
132overflow, and the number of messages lost. The default queue length is
1335, a sane value would be 5-25, and a maximum limit of 100 is imposed.
849a8357 134.TP
9e4abcb5
SK
135.B \-x, --pid-file=<path>
136Specify an alternate path for dnsmasq to record its process-id in. Normally /var/run/dnsmasq.pid.
137.TP
138.B \-u, --user=<username>
139Specify the userid to which dnsmasq will change after startup. Dnsmasq must normally be started as root, but it will drop root
b8187c80 140privileges after startup by changing id to another user. Normally this user is "nobody" but that
9e4abcb5
SK
141can be over-ridden with this switch.
142.TP
143.B \-g, --group=<groupname>
144Specify the group which dnsmasq will run
145as. The defaults to "dip", if available, to facilitate access to
146/etc/ppp/resolv.conf which is not normally world readable.
147.TP
148.B \-v, --version
149Print the version number.
150.TP
151.B \-p, --port=<port>
824af85b
SK
152Listen on <port> instead of the standard DNS port (53). Setting this
153to zero completely disables DNS function, leaving only DHCP and/or TFTP.
9e4abcb5 154.TP
feba5c1d
SK
155.B \-P, --edns-packet-max=<size>
156Specify the largest EDNS.0 UDP packet which is supported by the DNS
316e2730 157forwarder. Defaults to 4096, which is the RFC5625-recommended size.
feba5c1d 158.TP
9e4abcb5 159.B \-Q, --query-port=<query_port>
1a6bca81
SK
160Send outbound DNS queries from, and listen for their replies on, the
161specific UDP port <query_port> instead of using random ports. NOTE
162that using this option will make dnsmasq less secure against DNS
163spoofing attacks but it may be faster and use less resources. Setting this option
164to zero makes dnsmasq use a single port allocated to it by the
165OS: this was the default behaviour in versions prior to 2.43.
166.TP
167.B --min-port=<port>
168Do not use ports less than that given as source for outbound DNS
169queries. Dnsmasq picks random ports as source for outbound queries:
170when this option is given, the ports used will always to larger
171than that specified. Useful for systems behind firewalls.
9e4abcb5
SK
172.TP
173.B \-i, --interface=<interface name>
feba5c1d
SK
174Listen only on the specified interface(s). Dnsmasq automatically adds
175the loopback (local) interface to the list of interfaces to use when
176the
177.B \--interface
178option is used. If no
179.B \--interface
9e4abcb5 180or
feba5c1d
SK
181.B \--listen-address
182options are given dnsmasq listens on all available interfaces except any
183given in
184.B \--except-interface
309331f5 185options. IP alias interfaces (eg "eth1:0") cannot be used with
8a911ccc
SK
186.B --interface
187or
188.B --except-interface
49333cbd
SK
189options, use --listen-address instead. A simple wildcard, consisting
190of a trailing '*', can be used in
191.B \--interface
192and
193.B \--except-interface
194options.
9e4abcb5
SK
195.TP
196.B \-I, --except-interface=<interface name>
feba5c1d
SK
197Do not listen on the specified interface. Note that the order of
198.B \--listen-address
199.B --interface
200and
201.B --except-interface
202options does not matter and that
203.B --except-interface
204options always override the others.
34d0a36a
SK
205.TP
206.B --auth-server=<domain>,<interface>|<ip-address>
81925ab7 207Enable DNS authoritative mode for queries arriving at an interface or address. Note that the interface or address
34d0a36a
SK
208need not be mentioned in
209.B --interface
210or
211.B --listen-address
212configuration, indeed
213.B --auth-server
f25e6c6d
SK
214will overide these and provide a different DNS service on the
215specified interface. The <domain> is the "glue record". It should
216resolve in the global DNS to a A and/or AAAA record which points to
217the address dnsmasq is listening on. When an interface is specified,
218it may be qualified with "/4" or "/6" to specify only the IPv4 or IPv6
219addresses associated with the interface.
c8a80487
SK
220.TP
221.B --local-service
222Accept DNS queries only from hosts whose address is on a local subnet,
223ie a subnet for which an interface exists on the server. This option
224only has effect is there are no --interface --except-interface,
225--listen-address or --auth-server options. It is intended to be set as
226a default on installation, to allow unconfigured installations to be
227useful but also safe from being used for DNS amplification attacks.
9e4abcb5 228.TP
3d8df260 229.B \-2, --no-dhcp-interface=<interface name>
832af0ba 230Do not provide DHCP or TFTP on the specified interface, but do provide DNS service.
3d8df260 231.TP
44a2a316 232.B \-a, --listen-address=<ipaddr>
feba5c1d
SK
233Listen on the given IP address(es). Both
234.B \--interface
235and
236.B \--listen-address
237options may be given, in which case the set of both interfaces and
238addresses is used. Note that if no
239.B \--interface
240option is given, but
241.B \--listen-address
242is, dnsmasq will not automatically listen on the loopback
243interface. To achieve this, its IP address, 127.0.0.1, must be
244explicitly given as a
245.B \--listen-address
246option.
9e4abcb5 247.TP
44a2a316
SK
248.B \-z, --bind-interfaces
249On systems which support it, dnsmasq binds the wildcard address,
250even when it is listening on only some interfaces. It then discards
251requests that it shouldn't reply to. This has the advantage of
252working even when interfaces come and go and change address. This
253option forces dnsmasq to really bind only the interfaces it is
254listening on. About the only time when this is useful is when
f6b7dc47 255running another nameserver (or another instance of dnsmasq) on the
309331f5 256same machine. Setting this option also enables multiple instances of
f6b7dc47
SK
257dnsmasq which provide DHCP service to run in the same machine.
258.TP
54dd393f
SK
259.B --bind-dynamic
260Enable a network mode which is a hybrid between
261.B --bind-interfaces
a2ce6fcc 262and the default. Dnsmasq binds the address of individual interfaces,
54dd393f
SK
263allowing multiple dnsmasq instances, but if new interfaces or
264addresses appear, it automatically listens on those (subject to any
265access-control configuration). This makes dynamically created
266interfaces work in the same way as the default. Implementing this
a2ce6fcc 267option requires non-standard networking APIs and it is only available
05ff1ed7 268under Linux. On other platforms it falls-back to --bind-interfaces mode.
54dd393f 269.TP
f6b7dc47
SK
270.B \-y, --localise-queries
271Return answers to DNS queries from /etc/hosts which depend on the interface over which the query was
b8187c80 272received. If a name in /etc/hosts has more than one address associated with
f6b7dc47
SK
273it, and at least one of those addresses is on the same subnet as the
274interface to which the query was sent, then return only the
275address(es) on that subnet. This allows for a server to have multiple
276addresses in /etc/hosts corresponding to each of its interfaces, and
277hosts will get the correct address based on which network they are
278attached to. Currently this facility is limited to IPv4.
44a2a316 279.TP
9e4abcb5
SK
280.B \-b, --bogus-priv
281Bogus private reverse lookups. All reverse lookups for private IP ranges (ie 192.168.x.x, etc)
feba5c1d
SK
282which are not found in /etc/hosts or the DHCP leases file are answered
283with "no such domain" rather than being forwarded upstream.
9e4abcb5 284.TP
73a08a24 285.B \-V, --alias=[<old-ip>]|[<start-ip>-<end-ip>],<new-ip>[,<mask>]
1cff166d
SK
286Modify IPv4 addresses returned from upstream nameservers; old-ip is
287replaced by new-ip. If the optional mask is given then any address
288which matches the masked old-ip will be re-written. So, for instance
289.B --alias=1.2.3.0,6.7.8.0,255.255.255.0
290will map 1.2.3.56 to 6.7.8.56 and 1.2.3.67 to 6.7.8.67. This is what
73a08a24
SK
291Cisco PIX routers call "DNS doctoring". If the old IP is given as
292range, then only addresses in the range, rather than a whole subnet,
293are re-written. So
294.B --alias=192.168.0.10-192.168.0.40,10.0.0.0,255.255.255.0
295maps 192.168.0.10->192.168.0.40 to 10.0.0.10->10.0.0.40
1cff166d 296.TP
9e4abcb5
SK
297.B \-B, --bogus-nxdomain=<ipaddr>
298Transform replies which contain the IP address given into "No such
299domain" replies. This is intended to counteract a devious move made by
b8187c80 300Verisign in September 2003 when they started returning the address of
9e4abcb5
SK
301an advertising web page in response to queries for unregistered names,
302instead of the correct NXDOMAIN response. This option tells dnsmasq to
303fake the correct response when it sees this behaviour. As at Sept 2003
b8187c80 304the IP address being returned by Verisign is 64.94.110.11
32fc6dbe
GH
305.TP
306.B \-B, --ignore-address=<ipaddr>
307Ignore replies to A-record queries which include the specified address.
308No error is generated, dnsmasq simply continues to listen for another reply.
309This is useful to defeat blocking strategies which rely on quickly supplying a
310forged answer to a DNS request for certain domain, before the correct answer can arrive.
9e4abcb5
SK
311.TP
312.B \-f, --filterwin2k
313Later versions of windows make periodic DNS requests which don't get sensible answers from
314the public DNS and can cause problems by triggering dial-on-demand links. This flag turns on an option
315to filter such requests. The requests blocked are for records of types SOA and SRV, and type ANY where the
316requested name has underscores, to catch LDAP requests.
317.TP
318.B \-r, --resolv-file=<file>
319Read the IP addresses of the upstream nameservers from <file>, instead of
320/etc/resolv.conf. For the format of this file see
7de060b0
SK
321.BR resolv.conf (5).
322The only lines relevant to dnsmasq are nameserver ones. Dnsmasq can
9e4abcb5
SK
323be told to poll more than one resolv.conf file, the first file name specified
324overrides the default, subsequent ones add to the list. This is only
325allowed when polling; the file with the currently latest modification
326time is the one used.
327.TP
328.B \-R, --no-resolv
329Don't read /etc/resolv.conf. Get upstream servers only from the command
b49644f3 330line or the dnsmasq configuration file.
9e4abcb5 331.TP
ad094275 332.B \-1, --enable-dbus[=<service-name>]
3d8df260
SK
333Allow dnsmasq configuration to be updated via DBus method calls. The
334configuration which can be changed is upstream DNS servers (and
b8187c80 335corresponding domains) and cache clear. Requires that dnsmasq has
ad094275
SK
336been built with DBus support. If the service name is given, dnsmasq
337provides service at that name, rather than the default which is
338.B uk.org.thekelleys.dnsmasq
3d8df260 339.TP
9e4abcb5
SK
340.B \-o, --strict-order
341By default, dnsmasq will send queries to any of the upstream servers
824af85b 342it knows about and tries to favour servers that are known to
9e4abcb5
SK
343be up. Setting this flag forces dnsmasq to try each query with each
344server strictly in the order they appear in /etc/resolv.conf
345.TP
824af85b
SK
346.B --all-servers
347By default, when dnsmasq has more than one upstream server available,
348it will send queries to just one server. Setting this flag forces
349dnsmasq to send all queries to all available servers. The reply from
c72daea8 350the server which answers first will be returned to the original requester.
824af85b 351.TP
b5ea1cc2
SK
352.B --dns-loop-detect
353Enable code to detect DNS forwarding loops; ie the situation where a query sent to one
354of the upstream server eventually returns as a new query to the dnsmasq instance. The
355process works by generating TXT queries of the form <hex>.test and sending them to
356each upstream server. The hex is a UID which encodes the instance of dnsmasq sending the query
357and the upstream server to which it was sent. If the query returns to the server which sent it, then
358the upstream server through which it was sent is disabled and this event is logged. Each time the
359set of upstream servers changes, the test is re-run on all of them, including ones which
360were previously disabled.
361.TP
824af85b
SK
362.B --stop-dns-rebind
363Reject (and log) addresses from upstream nameservers which are in the
364private IP ranges. This blocks an attack where a browser behind a
365firewall is used to probe machines on the local network.
366.TP
8ef5ada2
SK
367.B --rebind-localhost-ok
368Exempt 127.0.0.0/8 from rebinding checks. This address range is
369returned by realtime black hole servers, so blocking it may disable
370these services.
371.TP
372.B --rebind-domain-ok=[<domain>]|[[/<domain>/[<domain>/]
373Do not detect and block dns-rebind on queries to these domains. The
374argument may be either a single domain, or multiple domains surrounded
375by '/', like the --server syntax, eg.
376.B --rebind-domain-ok=/domain1/domain2/domain3/
377.TP
9e4abcb5
SK
378.B \-n, --no-poll
379Don't poll /etc/resolv.conf for changes.
380.TP
1697269c 381.B --clear-on-reload
d9fb0be8
SK
382Whenever /etc/resolv.conf is re-read or the upstream servers are set
383via DBus, clear the DNS cache.
1697269c
SK
384This is useful when new nameservers may have different
385data than that held in cache.
386.TP
9e4abcb5 387.B \-D, --domain-needed
7de060b0 388Tells dnsmasq to never forward A or AAAA queries for plain names, without dots
3d8df260 389or domain parts, to upstream nameservers. If the name is not known
9e4abcb5
SK
390from /etc/hosts or DHCP then a "not found" answer is returned.
391.TP
824af85b 392.B \-S, --local, --server=[/[<domain>]/[domain/]][<ipaddr>[#<port>][@<source-ip>|<interface>[#<port>]]
5aabfc78 393Specify IP address of upstream servers directly. Setting this flag does
9e4abcb5
SK
394not suppress reading of /etc/resolv.conf, use -R to do that. If one or
395more
396optional domains are given, that server is used only for those domains
397and they are queried only using the specified server. This is
398intended for private nameservers: if you have a nameserver on your
399network which deals with names of the form
400xxx.internal.thekelleys.org.uk at 192.168.1.1 then giving the flag
b8187c80 401.B -S /internal.thekelleys.org.uk/192.168.1.1
9e4abcb5
SK
402will send all queries for
403internal machines to that nameserver, everything else will go to the
404servers in /etc/resolv.conf. An empty domain specification,
405.B //
406has the special meaning of "unqualified names only" ie names without any
407dots in them. A non-standard port may be specified as
408part of the IP
409address using a # character.
410More than one -S flag is allowed, with
8ef5ada2
SK
411repeated domain or ipaddr parts as required.
412
413More specific domains take precendence over less specific domains, so:
414.B --server=/google.com/1.2.3.4
415.B --server=/www.google.com/2.3.4.5
416will send queries for *.google.com to 1.2.3.4, except *www.google.com,
417which will go to 2.3.4.5
418
419The special server address '#' means, "use the standard servers", so
420.B --server=/google.com/1.2.3.4
421.B --server=/www.google.com/#
422will send queries for *.google.com to 1.2.3.4, except *www.google.com which will
423be forwarded as usual.
9e4abcb5
SK
424
425Also permitted is a -S
426flag which gives a domain but no IP address; this tells dnsmasq that
427a domain is local and it may answer queries from /etc/hosts or DHCP
428but should never forward queries on that domain to any upstream
429servers.
430.B local
431is a synonym for
432.B server
433to make configuration files clearer in this case.
434
7de060b0
SK
435IPv6 addresses may include a %interface scope-id, eg
436fe80::202:a412:4512:7bbf%eth0.
437
824af85b
SK
438The optional string after the @ character tells
439dnsmasq how to set the source of the queries to this
440nameserver. It should be an ip-address, which should belong to the machine on which
9e4abcb5 441dnsmasq is running otherwise this server line will be logged and then
824af85b
SK
442ignored, or an interface name. If an interface name is given, then
443queries to the server will be forced via that interface; if an
444ip-address is given then the source address of the queries will be set
445to that address.
446The query-port flag is ignored for any servers which have a
9e4abcb5 447source address specified but the port may be specified directly as
824af85b
SK
448part of the source address. Forcing queries to an interface is not
449implemented on all platforms supported by dnsmasq.
9e4abcb5 450.TP
de73a497
SK
451.B --rev-server=<ip-address>/<prefix-len>,<ipaddr>[#<port>][@<source-ip>|<interface>[#<port>]]
452This is functionally the same as
453.B --server,
454but provides some syntactic sugar to make specifying address-to-name queries easier. For example
455.B --rev-server=1.2.3.0/24,192.168.0.1
456is exactly equivalent to
457.B --server=/3.2.1.in-addr.arpa/192.168.0.1
458.TP
9e4abcb5
SK
459.B \-A, --address=/<domain>/[domain/]<ipaddr>
460Specify an IP address to return for any host in the given domains.
461Queries in the domains are never forwarded and always replied to
462with the specified IP address which may be IPv4 or IPv6. To give
463both IPv4 and IPv6 addresses for a domain, use repeated -A flags.
464Note that /etc/hosts and DHCP leases override this for individual
465names. A common use of this is to redirect the entire doubleclick.net
a222641c
SK
466domain to some friendly local web server to avoid banner ads. The
467domain specification works in the same was as for --server, with the
468additional facility that /#/ matches any domain. Thus
469--address=/#/1.2.3.4 will always return 1.2.3.4 for any query not
470answered from /etc/hosts or DHCP and not sent to an upstream
471nameserver by a more specific --server directive.
9e4abcb5 472.TP
13d86c73
JD
473.B --ipset=/<domain>/[domain/]<ipset>[,<ipset>]
474Places the resolved IP addresses of queries for the specified domains
475in the specified netfilter ip sets. Domains and subdomains are matched
476in the same way as --address. These ip sets must already exist. See
477ipset(8) for more details.
478.TP
f6b7dc47 479.B \-m, --mx-host=<mx name>[[,<hostname>],<preference>]
de37951c
SK
480Return an MX record named <mx name> pointing to the given hostname (if
481given), or
482the host specified in the --mx-target switch
9e4abcb5 483or, if that switch is not given, the host on which dnsmasq
f6b7dc47
SK
484is running. The default is useful for directing mail from systems on a LAN
485to a central server. The preference value is optional, and defaults to
4861 if not given. More than one MX record may be given for a host.
9e4abcb5
SK
487.TP
488.B \-t, --mx-target=<hostname>
f6b7dc47
SK
489Specify the default target for the MX record returned by dnsmasq. See
490--mx-host. If --mx-target is given, but not --mx-host, then dnsmasq
491returns a MX record containing the MX target for MX queries on the
492hostname of the machine on which dnsmasq is running.
9e4abcb5
SK
493.TP
494.B \-e, --selfmx
495Return an MX record pointing to itself for each local
496machine. Local machines are those in /etc/hosts or with DHCP leases.
497.TP
498.B \-L, --localmx
499Return an MX record pointing to the host given by mx-target (or the
500machine on which dnsmasq is running) for each
501local machine. Local machines are those in /etc/hosts or with DHCP
502leases.
503.TP
f6b7dc47
SK
504.B \-W, --srv-host=<_service>.<_prot>.[<domain>],[<target>[,<port>[,<priority>[,<weight>]]]]
505Return a SRV DNS record. See RFC2782 for details. If not supplied, the
506domain defaults to that given by
507.B --domain.
508The default for the target domain is empty, and the default for port
509is one and the defaults for
510weight and priority are zero. Be careful if transposing data from BIND
511zone files: the port, weight and priority numbers are in a different
512order. More than one SRV record for a given service/domain is allowed,
3d8df260 513all that match are returned.
f6b7dc47 514.TP
e46164e0 515.B --host-record=<name>[,<name>....][<IPv4-address>],[<IPv6-address>]
e759d426
SK
516Add A, AAAA and PTR records to the DNS. This adds one or more names to
517the DNS with associated IPv4 (A) and IPv6 (AAAA) records. A name may
518appear in more than one
519.B host-record
520and therefore be assigned more than one address. Only the first
521address creates a PTR record linking the address to the name. This is
522the same rule as is used reading hosts-files.
523.B host-record
524options are considered to be read before host-files, so a name
525appearing there inhibits PTR-record creation if it appears in
e46164e0 526hosts-file also. Unlike hosts-files, names are not expanded, even when
e759d426
SK
527.B expand-hosts
528is in effect. Short and long names may appear in the same
e46164e0
SK
529.B host-record,
530eg.
531.B --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100
e759d426 532.TP
0a852541
SK
533.B \-Y, --txt-record=<name>[[,<text>],<text>]
534Return a TXT DNS record. The value of TXT record is a set of strings,
28866e95
SK
535so any number may be included, delimited by commas; use quotes to put
536commas into a string. Note that the maximum length of a single string
537is 255 characters, longer strings are split into 255 character chunks.
0a852541 538.TP
832af0ba
SK
539.B --ptr-record=<name>[,<target>]
540Return a PTR DNS record.
541.TP
1a6bca81
SK
542.B --naptr-record=<name>,<order>,<preference>,<flags>,<service>,<regexp>[,<replacement>]
543Return an NAPTR DNS record, as specified in RFC3403.
544.TP
9009d746
SK
545.B --cname=<cname>,<target>
546Return a CNAME record which indicates that <cname> is really
547<target>. There are significant limitations on the target; it must be a
548DNS name which is known to dnsmasq from /etc/hosts (or additional
d56a604a 549hosts files), from DHCP, from --interface-name or from another
611ebc5f
SK
550.B --cname.
551If the target does not satisfy this
9009d746
SK
552criteria, the whole cname is ignored. The cname must be unique, but it
553is permissable to have more than one cname pointing to the same target.
554.TP
9f7f3b12
SK
555.B --dns-rr=<name>,<RR-number>,[<hex data>]
556Return an arbitrary DNS Resource Record. The number is the type of the
557record (which is always in the C_IN class). The value of the record is
a2ce6fcc 558given by the hex data, which may be of the form 01:23:45 or 01 23 45 or
9f7f3b12
SK
559012345 or any mixture of these.
560.TP
f7029f5c 561.B --interface-name=<name>,<interface>[/4|/6]
f2621c7f 562Return a DNS record associating the name with the primary address on
f7029f5c 563the given interface. This flag specifies an A or AAAA record for the given
f2621c7f 564name in the same way as an /etc/hosts line, except that the address is
f7029f5c
SK
565not constant, but taken from the given interface. The interface may be
566followed by "/4" or "/6" to specify that only IPv4 or IPv6 addresses
567of the interface should be used. If the interface is
9e038946 568down, not configured or non-existent, an empty record is returned. The
f2621c7f
SK
569matching PTR record is also created, mapping the interface address to
570the name. More than one name may be associated with an interface
571address by repeating the flag; in that case the first instance is used
572for the reverse address-to-name mapping.
573.TP
48fd1c4d 574.B --synth-domain=<domain>,<address range>[,<prefix>]
2bb73af7
SK
575Create artificial A/AAAA and PTR records for an address range. The
576records use the address, with periods (or colons for IPv6) replaced
577with dashes.
578
579An example should make this clearer.
48fd1c4d
SK
580.B --synth-domain=thekelleys.org.uk,192.168.0.0/24,internal-
581will result in a query for internal-192-168-0-56.thekelleys.org.uk returning
582192.168.0.56 and a reverse query vice versa. The same applies to IPv6,
583but IPv6 addresses may start with '::'
584but DNS labels may not start with '-' so in this case if no prefix is
585configured a zero is added in front of the label. ::1 becomes 0--1.
2bb73af7
SK
586
587The address range can be of the form
588<ip address>,<ip address> or <ip address>/<netmask>
589.TP
28866e95
SK
590.B --add-mac
591Add the MAC address of the requestor to DNS queries which are
592forwarded upstream. This may be used to DNS filtering by the upstream
593server. The MAC address can only be added if the requestor is on the same
594subnet as the dnsmasq server. Note that the mechanism used to achieve this (an EDNS0 option)
595is not yet standardised, so this should be considered
596experimental. Also note that exposing MAC addresses in this way may
ed4c0767
SK
597have security and privacy implications. The warning about caching
598given for --add-subnet applies to --add-mac too.
599.TP
600.B --add-subnet[[=<IPv4 prefix length>],<IPv6 prefix length>]
601Add the subnet address of the requestor to the DNS queries which are
602forwarded upstream. The amount of the address forwarded depends on the
603prefix length parameter: 32 (128 for IPv6) forwards the whole address,
604zero forwards none of it but still marks the request so that no
605upstream nameserver will add client address information either. The
606default is zero for both IPv4 and IPv6. Note that upstream nameservers
607may be configured to return different results based on this
608information, but the dnsmasq cache does not take account. If a dnsmasq
609instance is configured such that different results may be encountered,
610caching should be disabled.
28866e95 611.TP
9e4abcb5
SK
612.B \-c, --cache-size=<cachesize>
613Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching.
614.TP
615.B \-N, --no-negcache
616Disable negative caching. Negative caching allows dnsmasq to remember
617"no such domain" answers from upstream nameservers and answer
5aabfc78 618identical queries without forwarding them again.
9e4abcb5 619.TP
1697269c
SK
620.B \-0, --dns-forward-max=<queries>
621Set the maximum number of concurrent DNS queries. The default value is
622150, which should be fine for most setups. The only known situation
623where this needs to be increased is when using web-server log file
624resolvers, which can generate large numbers of concurrent queries.
208b65c5 625.TP
70b4a818
SK
626.B --dnssec
627Validate DNS replies and cache DNSSEC data. When forwarding DNS queries, dnsmasq requests the
628DNSSEC records needed to validate the replies. The replies are validated and the result returned as
629the Authenticated Data bit in the DNS packet. In addition the DNSSEC records are stored in the cache, making
630validation by clients more efficient. Note that validation by clients is the most secure DNSSEC mode, but for
631clients unable to do validation, use of the AD bit set by dnsmasq is useful, provided that the network between
632the dnsmasq server and the client is trusted. Dnsmasq must be compiled with HAVE_DNSSEC enabled, and DNSSEC
633trust anchors provided, see
ee415867 634.B --trust-anchor.
d588ab54
SK
635Because the DNSSEC validation process uses the cache, it is not
636permitted to reduce the cache size below the default when DNSSEC is
637enabled. The nameservers upstream of dnsmasq must be DNSSEC-capable,
638ie capable of returning DNSSEC records with data. If they are not,
639then dnsmasq will not be able to determine the trusted status of
640answers. In the default mode, this menas that all replies will be
641marked as untrusted. If
642.B --dnssec-check-unsigned
643is set and the upstream servers don't support DNSSEC, then DNS service will be entirely broken.
70b4a818 644.TP
ee415867
SK
645.B --trust-anchor=[<class>],<domain>,<key-tag>,<algorithm>,<digest-type>,<digest>
646Provide DS records to act a trust anchors for DNSSEC
647validation. Typically these will be the DS record(s) for Zone Signing
648key(s) of the root zone,
649but trust anchors for limited domains are also possible. The current
650root-zone trust anchors may be donwloaded from https://data.iana.org/root-anchors/root-anchors.xml
70b4a818 651.TP
00a5b5d4
SK
652.B --dnssec-check-unsigned
653As a default, dnsmasq does not check that unsigned DNS replies are
654legitimate: they are assumed to be valid and passed on (without the
655"authentic data" bit set, of course). This does not protect against an
656attacker forging unsigned replies for signed DNS zones, but it is
657fast. If this flag is set, dnsmasq will check the zones of unsigned
658replies, to ensure that unsigned replies are allowed in those
d588ab54
SK
659zones. The cost of this is more upstream queries and slower
660performance. See also the warning about upstream servers in the
661section on
662.B --dnssec
00a5b5d4 663.TP
e98bd52e
SK
664.B --dnssec-no-timecheck
665DNSSEC signatures are only valid for specified time windows, and should be rejected outside those windows. This generates an
666interesting chicken-and-egg problem for machines which don't have a hardware real time clock. For these machines to determine the correct
667time typically requires use of NTP and therefore DNS, but validating DNS requires that the correct time is already known. Setting this flag
668removes the time-window checks (but not other DNSSEC validation.) only until the dnsmasq process receives SIGHUP. The intention is
669that dnsmasq should be started with this flag when the platform determines that reliable time is not currently available. As soon as
670reliable time is established, a SIGHUP should be sent to dnsmasq, which enables time checking, and purges the cache of DNS records
671which have not been throughly checked.
672.TP
28866e95 673.B --proxy-dnssec
70b4a818
SK
674Copy the DNSSEC Authenticated Data bit from upstream servers to downstream clients and cache it. This is an
675alternative to having dnsmasq validate DNSSEC, but it depends on the security of the network between
676dnsmasq and the upstream servers, and the trustworthiness of the upstream servers.
677.TP
678.B --dnssec-debug
679Set debugging mode for the DNSSEC validation, set the Checking Disabled bit on upstream queries,
ee415867
SK
680and don't convert replies which do not validate to responses with
681a return code of SERVFAIL. Note that
682setting this may affect DNS behaviour in bad ways, it is not an
683extra-logging flag and should not be set in production.
28866e95 684.TP
baa80ae5 685.B --auth-zone=<domain>[,<subnet>[/<prefix length>][,<subnet>[/<prefix length>].....]]
34d0a36a 686Define a DNS zone for which dnsmasq acts as authoritative server. Locally defined DNS records which are in the domain
c50f25a3
SK
687will be served. If subnet(s) are given, A and AAAA records must be in one of the
688specified subnets.
689
690As alternative to directly specifying the subnets, it's possible to
376d48c7
SK
691give the name of an interface, in which case the subnets implied by
692that interface's configured addresses and netmask/prefix-length are
693used; this is useful when using constructed DHCP ranges as the actual
694address is dynamic and not known when configuring dnsmasq. The
695interface addresses may be confined to only IPv6 addresses using
696<interface>/6 or to only IPv4 using <interface>/4. This is useful when
697an interface has dynamically determined global IPv6 addresses which should
698appear in the zone, but RFC1918 IPv4 addresses which should not.
699Interface-name and address-literal subnet specifications may be used
700freely in the same --auth-zone declaration.
701
702The subnet(s) are also used to define in-addr.arpa and
1d7e0a36 703ip6.arpa domains which are served for reverse-DNS queries. If not
baa80ae5
SK
704specified, the prefix length defaults to 24 for IPv4 and 64 for IPv6.
705For IPv4 subnets, the prefix length should be have the value 8, 16 or 24
706unless you are familiar with RFC 2317 and have arranged the
c50f25a3
SK
707in-addr.arpa delegation accordingly. Note that if no subnets are
708specified, then no reverse queries are answered.
333b2ceb
SK
709.TP
710.B --auth-soa=<serial>[,<hostmaster>[,<refresh>[,<retry>[,<expiry>]]]]
711Specify fields in the SOA record associated with authoritative
712zones. Note that this is optional, all the values are set to sane defaults.
713.TP
714.B --auth-sec-servers=<domain>[,<domain>[,<domain>...]]
715Specify any secondary servers for a zone for which dnsmasq is
716authoritative. These servers must be configured to get zone data from
717dnsmasq by zone transfer, and answer queries for the same
6f130def 718authoritative zones as dnsmasq.
333b2ceb
SK
719.TP
720.B --auth-peer=<ip-address>[,<ip-address>[,<ip-address>...]]
721Specify the addresses of secondary servers which are allowed to
722initiate zone transfer (AXFR) requests for zones for which dnsmasq is
6f130def 723authoritative. If this option is not given, then AXFR requests will be
333b2ceb
SK
724accepted from any secondary.
725.TP
7de060b0
SK
726.B --conntrack
727Read the Linux connection track mark associated with incoming DNS
728queries and set the same mark value on upstream traffic used to answer
729those queries. This allows traffic generated by dnsmasq to be
730associated with the queries which cause it, useful for bandwidth
731accounting and firewalling. Dnsmasq must have conntrack support
732compiled in and the kernel must have conntrack support
733included and configured. This option cannot be combined with
734--query-port.
735.TP
49dc570a 736.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-addr>[,<end-addr>][,<mode>][,<netmask>[,<broadcast>]][,<lease time>]
1adadf58 737.TP
83f28bef 738.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-IPv6addr>[,<end-IPv6addr>|constructor:<interface>][,<mode>][,<prefix-len>][,<lease time>]
1adadf58 739
9e4abcb5 740Enable the DHCP server. Addresses will be given out from the range
44a2a316
SK
741<start-addr> to <end-addr> and from statically defined addresses given
742in
743.B dhcp-host
744options. If the lease time is given, then leases
b8187c80 745will be given for that length of time. The lease time is in seconds,
7622fc06
SK
746or minutes (eg 45m) or hours (eg 1h) or "infinite". If not given,
747the default lease time is one hour. The
c8257540
SK
748minimum lease time is two minutes. For IPv6 ranges, the lease time
749maybe "deprecated"; this sets the preferred lifetime sent in a DHCP
750lease or router advertisement to zero, which causes clients to use
751other addresses, if available, for new connections as a prelude to renumbering.
752
753This option may be repeated, with different addresses, to enable DHCP
44a2a316
SK
754service to more than one network. For directly connected networks (ie,
755networks on which the machine running dnsmasq has an interface) the
7de060b0
SK
756netmask is optional: dnsmasq will determine it from the interface
757configuration. For networks which receive DHCP service via a relay
758agent, dnsmasq cannot determine the netmask itself, so it should be
759specified, otherwise dnsmasq will have to guess, based on the class (A, B or
760C) of the network address. The broadcast address is
7622fc06 761always optional. It is always
8ef5ada2
SK
762allowed to have more than one dhcp-range in a single subnet.
763
1adadf58 764For IPv6, the parameters are slightly different: instead of netmask
4c82efc5
VG
765and broadcast address, there is an optional prefix length which must
766be equal to or larger then the prefix length on the local interface. If not
1adadf58
SK
767given, this defaults to 64. Unlike the IPv4 case, the prefix length is not
768automatically derived from the interface configuration. The mimimum
769size of the prefix length is 64.
770
34d0a36a
SK
771IPv6 (only) supports another type of range. In this, the start address and optional end address contain only the network part (ie ::1) and they are followed by
772.B constructor:<interface>.
773This forms a template which describes how to create ranges, based on the addresses assigned to the interface. For instance
774
83f28bef 775.B --dhcp-range=::1,::400,constructor:eth0
34d0a36a 776
861c8914 777will look for addresses on
429805db
SK
778eth0 and then create a range from <network>::1 to <network>::400. If
779the interface is assigned more than one network, then the
780corresponding ranges will be automatically created, and then
781deprecated and finally removed again as the address is deprecated and
782then deleted. The interface name may have a final "*" wildcard. Note
861c8914
SK
783that just any address on eth0 will not do: it must not be an
784autoconfigured or privacy address, or be deprecated.
34d0a36a 785
e4cdbbf5
VG
786If a dhcp-range is only being used for stateless DHCP and/or SLAAC,
787then the address can be simply ::
788
789.B --dhcp-range=::,constructor:eth0
790
e4cdbbf5 791
8ef5ada2
SK
792The optional
793.B set:<tag>
794sets an alphanumeric label which marks this network so that
0a852541 795dhcp options may be specified on a per-network basis.
8ef5ada2 796When it is prefixed with 'tag:' instead, then its meaning changes from setting
c5ad4e79
SK
797a tag to matching it. Only one tag may be set, but more than one tag
798may be matched.
799
e8ca69ea 800The optional <mode> keyword may be
33820b7e
SK
801.B static
802which tells dnsmasq to enable DHCP for the network specified, but not
7622fc06 803to dynamically allocate IP addresses: only hosts which have static
33820b7e
SK
804addresses given via
805.B dhcp-host
52002051
SK
806or from /etc/ethers will be served. A static-only subnet with address
807all zeros may be used as a "catch-all" address to enable replies to all
808Information-request packets on a subnet which is provided with
809stateless DHCPv6, ie
e62e9b61 810.B --dhcp-range=::,static
c5ad4e79 811
e46164e0 812For IPv4, the <mode> may be
7622fc06
SK
813.B proxy
814in which case dnsmasq will provide proxy-DHCP on the specified
815subnet. (See
816.B pxe-prompt
817and
818.B pxe-service
e8ca69ea
SK
819for details.)
820
821For IPv6, the mode may be some combination of
7ea3d3fd 822.B ra-only, slaac, ra-names, ra-stateless, ra-advrouter.
8ef5ada2 823
c5ad4e79 824.B ra-only
e8ca69ea
SK
825tells dnsmasq to offer Router Advertisement only on this subnet,
826and not DHCP.
827
828.B slaac
829tells dnsmasq to offer Router Advertisement on this subnet and to set
830the A bit in the router advertisement, so that the client will use
831SLAAC addresses. When used with a DHCP range or static DHCP address
832this results in the client having both a DHCP-assigned and a SLAAC
833address.
834
835.B ra-stateless
836sends router advertisements with the O and A bits set, and provides a
837stateless DHCP service. The client will use a SLAAC address, and use
838DHCP for other configuration information.
839
7023e382 840.B ra-names
e8ca69ea 841enables a mode
7023e382 842which gives DNS names to dual-stack hosts which do SLAAC for
884a6dfe 843IPv6. Dnsmasq uses the host's IPv4 lease to derive the name, network
7023e382 844segment and MAC address and assumes that the host will also have an
e46164e0 845IPv6 address calculated using the SLAAC algorithm, on the same network
884a6dfe
SK
846segment. The address is pinged, and if a reply is received, an AAAA
847record is added to the DNS for this IPv6
7023e382 848address. Note that this is only happens for directly-connected
884a6dfe
SK
849networks, (not one doing DHCP via a relay) and it will not work
850if a host is using privacy extensions.
e8ca69ea
SK
851.B ra-names
852can be combined with
853.B ra-stateless
854and
855.B slaac.
c5ad4e79 856
7ea3d3fd
SK
857.B ra-advrouter
858enables a mode where router address(es) rather than prefix(es) are included in the advertisements.
859This is described in RFC-3775 section 7.2 and is used in mobile IPv6. In this mode the interval option
860is also included, as described in RFC-3775 section 7.3.
861
9e4abcb5 862.TP
8ef5ada2 863.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
9e4abcb5
SK
864Specify per host parameters for the DHCP server. This allows a machine
865with a particular hardware address to be always allocated the same
866hostname, IP address and lease time. A hostname specified like this
867overrides any supplied by the DHCP client on the machine. It is also
c72daea8 868allowable to omit the hardware address and include the hostname, in
9e4abcb5
SK
869which case the IP address and lease times will apply to any machine
870claiming that name. For example
871.B --dhcp-host=00:20:e0:3b:13:af,wap,infinite
872tells dnsmasq to give
cdeda28f 873the machine with hardware address 00:20:e0:3b:13:af the name wap, and
9e4abcb5
SK
874an infinite DHCP lease.
875.B --dhcp-host=lap,192.168.0.199
876tells
877dnsmasq to always allocate the machine lap the IP address
8ef5ada2
SK
878192.168.0.199.
879
880Addresses allocated like this are not constrained to be
881in the range given by the --dhcp-range option, but they must be in
882the same subnet as some valid dhcp-range. For
883subnets which don't need a pool of dynamically allocated addresses,
884use the "static" keyword in the dhcp-range declaration.
885
89500e31
SK
886It is allowed to use client identifiers (called client
887DUID in IPv6-land rather than
9e4abcb5
SK
888hardware addresses to identify hosts by prefixing with 'id:'. Thus:
889.B --dhcp-host=id:01:02:03:04,.....
890refers to the host with client identifier 01:02:03:04. It is also
891allowed to specify the client ID as text, like this:
a84fa1d0 892.B --dhcp-host=id:clientidastext,.....
9009d746 893
1adadf58
SK
894A single
895.B dhcp-host
896may contain an IPv4 address or an IPv6 address, or both. IPv6 addresses must be bracketed by square brackets thus:
897.B --dhcp-host=laptop,[1234::56]
30393100
SK
898IPv6 addresses may contain only the host-identifier part:
899.B --dhcp-host=laptop,[::56]
6f130def 900in which case they act as wildcards in constructed dhcp ranges, with
30393100 901the appropriate network part inserted.
89500e31
SK
902Note that in IPv6 DHCP, the hardware address may not be
903available, though it normally is for direct-connected clients, or
904clients using DHCP relays which support RFC 6939.
1adadf58 905
89500e31
SK
906
907For DHCPv4, the special option id:* means "ignore any client-id
a84fa1d0
SK
908and use MAC addresses only." This is useful when a client presents a client-id sometimes
909but not others.
9009d746 910
1ab84e2f
SK
911If a name appears in /etc/hosts, the associated address can be
912allocated to a DHCP lease, but only if a
913.B --dhcp-host
8ef5ada2
SK
914option specifying the name also exists. Only one hostname can be
915given in a
916.B dhcp-host
917option, but aliases are possible by using CNAMEs. (See
918.B --cname
919).
920
921The special keyword "ignore"
33820b7e
SK
922tells dnsmasq to never offer a DHCP lease to a machine. The machine
923can be specified by hardware address, client ID or hostname, for
924instance
925.B --dhcp-host=00:20:e0:3b:13:af,ignore
926This is
927useful when there is another DHCP server on the network which should
9009d746
SK
928be used by some machines.
929
a66d36ea 930The set:<tag> construct sets the tag
9009d746 931whenever this dhcp-host directive is in use. This can be used to
8ef5ada2
SK
932selectively send DHCP options just for this host. More than one tag
933can be set in a dhcp-host directive (but not in other places where
934"set:<tag>" is allowed). When a host matches any
5aabfc78 935dhcp-host directive (or one implied by /etc/ethers) then the special
8ef5ada2 936tag "known" is set. This allows dnsmasq to be configured to
5aabfc78 937ignore requests from unknown machines using
8ef5ada2 938.B --dhcp-ignore=tag:!known
0a852541
SK
939Ethernet addresses (but not client-ids) may have
940wildcard bytes, so for example
941.B --dhcp-host=00:20:e0:3b:13:*,ignore
cdeda28f 942will cause dnsmasq to ignore a range of hardware addresses. Note that
0a852541 943the "*" will need to be escaped or quoted on a command line, but not
9009d746
SK
944in the configuration file.
945
946Hardware addresses normally match any
cdeda28f
SK
947network (ARP) type, but it is possible to restrict them to a single
948ARP type by preceding them with the ARP-type (in HEX) and "-". so
949.B --dhcp-host=06-00:20:e0:3b:13:af,1.2.3.4
950will only match a
951Token-Ring hardware address, since the ARP-address type for token ring
9009d746
SK
952is 6.
953
1adadf58 954As a special case, in DHCPv4, it is possible to include more than one
73a08a24
SK
955hardware address. eg:
956.B --dhcp-host=11:22:33:44:55:66,12:34:56:78:90:12,192.168.0.2
957This allows an IP address to be associated with
9009d746
SK
958multiple hardware addresses, and gives dnsmasq permission to abandon a
959DHCP lease to one of the hardware addresses when another one asks for
960a lease. Beware that this is a dangerous thing to do, it will only
961work reliably if only one of the hardware addresses is active at any
73a08a24
SK
962time and there is no way for dnsmasq to enforce this. It is, for instance,
963useful to allocate a stable IP address to a laptop which
9009d746 964has both wired and wireless interfaces.
5aabfc78 965.TP
28866e95
SK
966.B --dhcp-hostsfile=<path>
967Read DHCP host information from the specified file. If a directory
968is given, then read all the files contained in that directory. The file contains
5aabfc78
SK
969information about one host per line. The format of a line is the same
970as text to the right of '=' in --dhcp-host. The advantage of storing DHCP host information
971in this file is that it can be changed without re-starting dnsmasq:
972the file will be re-read when dnsmasq receives SIGHUP.
824af85b 973.TP
28866e95
SK
974.B --dhcp-optsfile=<path>
975Read DHCP option information from the specified file. If a directory
976is given, then read all the files contained in that directory. The advantage of
824af85b 977using this option is the same as for --dhcp-hostsfile: the
1f15b81d
SK
978dhcp-optsfile will be re-read when dnsmasq receives SIGHUP. Note that
979it is possible to encode the information in a
980.B --dhcp-boot
981flag as DHCP options, using the options names bootfile-name,
982server-ip-address and tftp-server. This allows these to be included
983in a dhcp-optsfile.
44a2a316
SK
984.TP
985.B \-Z, --read-ethers
986Read /etc/ethers for information about hosts for the DHCP server. The
987format of /etc/ethers is a hardware address, followed by either a
988hostname or dotted-quad IP address. When read by dnsmasq these lines
989have exactly the same effect as
990.B --dhcp-host
5aabfc78 991options containing the same information. /etc/ethers is re-read when
1adadf58 992dnsmasq receives SIGHUP. IPv6 addresses are NOT read from /etc/ethers.
9e4abcb5 993.TP
1adadf58 994.B \-O, --dhcp-option=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>|option6:<opt>|option6:<opt-name>],[<value>[,<value>]]
b8187c80 995Specify different or extra options to DHCP clients. By default,
9e4abcb5
SK
996dnsmasq sends some standard options to DHCP clients, the netmask and
997broadcast address are set to the same as the host running dnsmasq, and
998the DNS server and default route are set to the address of the machine
1adadf58 999running dnsmasq. (Equivalent rules apply for IPv6.) If the domain name option has been set, that is sent.
f2621c7f
SK
1000This configuration allows these defaults to be overridden,
1001or other options specified. The option, to be sent may be given as a
1002decimal number or as "option:<option-name>" The option numbers are
1003specified in RFC2132 and subsequent RFCs. The set of option-names
1004known by dnsmasq can be discovered by running "dnsmasq --help dhcp".
1005For example, to set the default route option to
9e4abcb5 1006192.168.4.4, do
f2621c7f
SK
1007.B --dhcp-option=3,192.168.4.4
1008or
1009.B --dhcp-option = option:router, 192.168.4.4
9e4abcb5 1010and to set the time-server address to 192.168.0.4, do
f2621c7f
SK
1011.B --dhcp-option = 42,192.168.0.4
1012or
1013.B --dhcp-option = option:ntp-server, 192.168.0.4
c3a04081
SK
1014The special address 0.0.0.0 is taken to mean "the address of the
1015machine running dnsmasq".
1016
1017Data types allowed are comma separated
1018dotted-quad IPv4 addresses, []-wrapped IPv6 addresses, a decimal number, colon-separated hex digits
8ef5ada2
SK
1019and a text string. If the optional tags are given then
1020this option is only sent when all the tags are matched.
91dccd09 1021
cdeda28f 1022Special processing is done on a text argument for option 119, to
832af0ba
SK
1023conform with RFC 3397. Text or dotted-quad IP addresses as arguments
1024to option 120 are handled as per RFC 3361. Dotted-quad IP addresses
1025which are followed by a slash and then a netmask size are encoded as
1026described in RFC 3442.
cdeda28f 1027
1adadf58
SK
1028IPv6 options are specified using the
1029.B option6:
1030keyword, followed by the option number or option name. The IPv6 option
1031name space is disjoint from the IPv4 option name space. IPv6 addresses
1032in options must be bracketed with square brackets, eg.
1033.B --dhcp-option=option6:ntp-server,[1234::56]
c3a04081
SK
1034For IPv6, [::] means "the global address of
1035the machine running dnsmasq", whilst [fd00::] is replaced with the
1036ULA, if it exists, and [fe80::] with the link-local address.
1adadf58 1037
9e4abcb5 1038Be careful: no checking is done that the correct type of data for the
26128d27 1039option number is sent, it is quite possible to
9e4abcb5 1040persuade dnsmasq to generate illegal DHCP packets with injudicious use
91dccd09
SK
1041of this flag. When the value is a decimal number, dnsmasq must determine how
1042large the data item is. It does this by examining the option number and/or the
b8187c80 1043value, but can be overridden by appending a single letter flag as follows:
91dccd09 1044b = one byte, s = two bytes, i = four bytes. This is mainly useful with
3d8df260
SK
1045encapsulated vendor class options (see below) where dnsmasq cannot
1046determine data size from the option number. Option data which
1047consists solely of periods and digits will be interpreted by dnsmasq
1048as an IP address, and inserted into an option as such. To force a
1049literal string, use quotes. For instance when using option 66 to send
1050a literal IP address as TFTP server name, it is necessary to do
1051.B --dhcp-option=66,"1.2.3.4"
91dccd09 1052
1adadf58 1053Encapsulated Vendor-class options may also be specified (IPv4 only) using
91dccd09 1054--dhcp-option: for instance
1b7ecd11
SK
1055.B --dhcp-option=vendor:PXEClient,1,0.0.0.0
1056sends the encapsulated vendor
1057class-specific option "mftp-address=0.0.0.0" to any client whose
1058vendor-class matches "PXEClient". The vendor-class matching is
6b01084f
SK
1059substring based (see --dhcp-vendorclass for details). If a
1060vendor-class option (number 60) is sent by dnsmasq, then that is used
1061for selecting encapsulated options in preference to any sent by the
1062client. It is
1b7ecd11
SK
1063possible to omit the vendorclass completely;
1064.B --dhcp-option=vendor:,1,0.0.0.0
1adadf58 1065in which case the encapsulated option is always sent.
73a08a24 1066
1adadf58 1067Options may be encapsulated (IPv4 only) within other options: for instance
73a08a24
SK
1068.B --dhcp-option=encap:175, 190, "iscsi-client0"
1069will send option 175, within which is the option 190. If multiple
1070options are given which are encapsulated with the same option number
1071then they will be correctly combined into one encapsulated option.
1072encap: and vendor: are may not both be set in the same dhcp-option.
1073
316e2730
SK
1074The final variant on encapsulated options is "Vendor-Identifying
1075Vendor Options" as specified by RFC3925. These are denoted like this:
1076.B --dhcp-option=vi-encap:2, 10, "text"
1077The number in the vi-encap: section is the IANA enterprise number
1adadf58
SK
1078used to identify this option. This form of encapsulation is supported
1079in IPv6.
1080
1b7ecd11 1081The address 0.0.0.0 is not treated specially in
73a08a24 1082encapsulated options.
9e4abcb5 1083.TP
8ef5ada2 1084.B --dhcp-option-force=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]]
6b01084f 1085This works in exactly the same way as
f2621c7f
SK
1086.B --dhcp-option
1087except that the option will always be sent, even if the client does
6b01084f
SK
1088not ask for it in the parameter request list. This is sometimes
1089needed, for example when sending options to PXELinux.
1090.TP
824af85b 1091.B --dhcp-no-override
1adadf58 1092(IPv4 only) Disable re-use of the DHCP servername and filename fields as extra
824af85b
SK
1093option space. If it can, dnsmasq moves the boot server and filename
1094information (from dhcp-boot) out of their dedicated fields into
1095DHCP options. This make extra space available in the DHCP packet for
1096options but can, rarely, confuse old or broken clients. This flag
1097forces "simple and safe" behaviour to avoid problems in such a case.
1098.TP
ff7eea27
SK
1099.B --dhcp-relay=<local address>,<server address>[,<interface]
1100Configure dnsmasq to do DHCP relay. The local address is an address
1101allocated to an interface on the host running dnsmasq. All DHCP
1102requests arriving on that interface will we relayed to a remote DHCP
1103server at the server address. It is possible to relay from a single local
1104address to multiple remote servers by using multiple dhcp-relay
1105configs with the same local address and different server
1106addresses. A server address must be an IP literal address, not a
1107domain name. In the case of DHCPv6, the server address may be the
1108ALL_SERVERS multicast address, ff05::1:3. In this case the interface
1109must be given, not be wildcard, and is used to direct the multicast to the
1110correct interface to reach the DHCP server.
1111
1112Access control for DHCP clients has the same rules as for the DHCP
1113server, see --interface, --except-interface, etc. The optional
1114interface name in the dhcp-relay config has a different function: it
1115controls on which interface DHCP replies from the server will be
1116accepted. This is intended for configurations which have three
1117interfaces: one being relayed from, a second connecting the DHCP
1118server, and a third untrusted network, typically the wider
1119internet. It avoids the possibility of spoof replies arriving via this
1120third interface.
1121
1122It is allowed to have dnsmasq act as a DHCP server on one set of
1123interfaces and relay from a disjoint set of interfaces. Note that
1124whilst it is quite possible to write configurations which appear to
1125act as a server and a relay on the same interface, this is not
1126supported: the relay function will take precedence.
1127
1128Both DHCPv4 and DHCPv6 relay is supported. It's not possible to relay
1129DHCPv4 to a DHCPv6 server or vice-versa.
1130.TP
1adadf58 1131.B \-U, --dhcp-vendorclass=set:<tag>,[enterprise:<IANA-enterprise number>,]<vendor-class>
8ef5ada2 1132Map from a vendor-class string to a tag. Most DHCP clients provide a
a222641c 1133"vendor class" which represents, in some sense, the type of host. This option
f2621c7f 1134maps vendor classes to tags, so that DHCP options may be selectively delivered
a84fa1d0 1135to different classes of hosts. For example
8ef5ada2 1136.B dhcp-vendorclass=set:printers,Hewlett-Packard JetDirect
a84fa1d0 1137will allow options to be set only for HP printers like so:
8ef5ada2 1138.B --dhcp-option=tag:printers,3,192.168.4.4
a222641c
SK
1139The vendor-class string is
1140substring matched against the vendor-class supplied by the client, to
1adadf58
SK
1141allow fuzzy matching. The set: prefix is optional but allowed for
1142consistency.
1143
1144Note that in IPv6 only, vendorclasses are namespaced with an
1145IANA-allocated enterprise number. This is given with enterprise:
1146keyword and specifies that only vendorclasses matching the specified
1147number should be searched.
a222641c 1148.TP
8ef5ada2
SK
1149.B \-j, --dhcp-userclass=set:<tag>,<user-class>
1150Map from a user-class string to a tag (with substring
a222641c
SK
1151matching, like vendor classes). Most DHCP clients provide a
1152"user class" which is configurable. This option
f2621c7f 1153maps user classes to tags, so that DHCP options may be selectively delivered
a222641c
SK
1154to different classes of hosts. It is possible, for instance to use
1155this to set a different printer server for hosts in the class
1156"accounts" than for hosts in the class "engineering".
a84fa1d0 1157.TP
8ef5ada2 1158.B \-4, --dhcp-mac=set:<tag>,<MAC address>
89500e31 1159Map from a MAC address to a tag. The MAC address may include
cdeda28f 1160wildcards. For example
8ef5ada2 1161.B --dhcp-mac=set:3com,01:34:23:*:*:*
cdeda28f
SK
1162will set the tag "3com" for any host whose MAC address matches the pattern.
1163.TP
8ef5ada2
SK
1164.B --dhcp-circuitid=set:<tag>,<circuit-id>, --dhcp-remoteid=set:<tag>,<remote-id>
1165Map from RFC3046 relay agent options to tags. This data may
f2621c7f
SK
1166be provided by DHCP relay agents. The circuit-id or remote-id is
1167normally given as colon-separated hex, but is also allowed to be a
1168simple string. If an exact match is achieved between the circuit or
1adadf58
SK
1169agent ID and one provided by a relay agent, the tag is set.
1170
1171.B dhcp-remoteid
1172(but not dhcp-circuitid) is supported in IPv6.
8ef5ada2
SK
1173.TP
1174.B --dhcp-subscrid=set:<tag>,<subscriber-id>
1adadf58 1175(IPv4 and IPv6) Map from RFC3993 subscriber-id relay agent options to tags.
8ef5ada2
SK
1176.TP
1177.B --dhcp-proxy[=<ip addr>]......
0793380b 1178(IPv4 only) A normal DHCP relay agent is only used to forward the initial parts of
8ef5ada2
SK
1179a DHCP interaction to the DHCP server. Once a client is configured, it
1180communicates directly with the server. This is undesirable if the
a66d36ea 1181relay agent is adding extra information to the DHCP packets, such as
8ef5ada2
SK
1182that used by
1183.B dhcp-circuitid
1184and
1185.B dhcp-remoteid.
1186A full relay implementation can use the RFC 5107 serverid-override
1187option to force the DHCP server to use the relay as a full proxy, with all
1188packets passing through it. This flag provides an alternative method
1189of doing the same thing, for relays which don't support RFC
11905107. Given alone, it manipulates the server-id for all interactions
1191via relays. If a list of IP addresses is given, only interactions via
1192relays at those addresses are affected.
1193.TP
1194.B --dhcp-match=set:<tag>,<option number>|option:<option name>|vi-encap:<enterprise>[,<value>]
1195Without a value, set the tag if the client sends a DHCP
73a08a24
SK
1196option of the given number or name. When a value is given, set the tag only if
1197the option is sent and matches the value. The value may be of the form
a66d36ea 1198"01:ff:*:02" in which case the value must match (apart from wildcards)
73a08a24
SK
1199but the option sent may have unmatched data past the end of the
1200value. The value may also be of the same form as in
1201.B dhcp-option
1202in which case the option sent is treated as an array, and one element
1203must match, so
1204
8ef5ada2 1205--dhcp-match=set:efi-ia32,option:client-arch,6
73a08a24
SK
1206
1207will set the tag "efi-ia32" if the the number 6 appears in the list of
1208architectures sent by the client in option 93. (See RFC 4578 for
316e2730
SK
1209details.) If the value is a string, substring matching is used.
1210
a66d36ea 1211The special form with vi-encap:<enterprise number> matches against
316e2730 1212vendor-identifying vendor classes for the specified enterprise. Please
8ef5ada2
SK
1213see RFC 3925 for more details of these rare and interesting beasts.
1214.TP
1215.B --tag-if=set:<tag>[,set:<tag>[,tag:<tag>[,tag:<tag>]]]
1216Perform boolean operations on tags. Any tag appearing as set:<tag> is set if
1217all the tags which appear as tag:<tag> are set, (or unset when tag:!<tag> is used)
1218If no tag:<tag> appears set:<tag> tags are set unconditionally.
1219Any number of set: and tag: forms may appear, in any order.
1220Tag-if lines ares executed in order, so if the tag in tag:<tag> is a
1221tag set by another
1222.B tag-if,
1223the line which sets the tag must precede the one which tests it.
1224.TP
1225.B \-J, --dhcp-ignore=tag:<tag>[,tag:<tag>]
1226When all the given tags appear in the tag set ignore the host and do
26128d27
SK
1227not allocate it a DHCP lease.
1228.TP
8ef5ada2
SK
1229.B --dhcp-ignore-names[=tag:<tag>[,tag:<tag>]]
1230When all the given tags appear in the tag set, ignore any hostname
9e038946 1231provided by the host. Note that, unlike dhcp-ignore, it is permissible
8ef5ada2 1232to supply no tags, in which case DHCP-client supplied hostnames
832af0ba
SK
1233are always ignored, and DHCP hosts are added to the DNS using only
1234dhcp-host configuration in dnsmasq and the contents of /etc/hosts and
1235/etc/ethers.
1236.TP
8ef5ada2 1237.B --dhcp-generate-names=tag:<tag>[,tag:<tag>]
1adadf58 1238(IPv4 only) Generate a name for DHCP clients which do not otherwise have one,
a66d36ea 1239using the MAC address expressed in hex, separated by dashes. Note that
8ef5ada2
SK
1240if a host provides a name, it will be used by preference to this,
1241unless
1242.B --dhcp-ignore-names
1243is set.
1244.TP
1245.B --dhcp-broadcast[=tag:<tag>[,tag:<tag>]]
1adadf58 1246(IPv4 only) When all the given tags appear in the tag set, always use broadcast to
8ef5ada2
SK
1247communicate with the host when it is unconfigured. It is permissible
1248to supply no tags, in which case this is unconditional. Most DHCP clients which
824af85b
SK
1249need broadcast replies set a flag in their requests so that this
1250happens automatically, some old BOOTP clients do not.
1251.TP
7de060b0 1252.B \-M, --dhcp-boot=[tag:<tag>,]<filename>,[<servername>[,<server address>|<tftp_servername>]]
1adadf58 1253(IPv4 only) Set BOOTP options to be returned by the DHCP server. Server name and
832af0ba
SK
1254address are optional: if not provided, the name is left empty, and the
1255address set to the address of the machine running dnsmasq. If dnsmasq
1256is providing a TFTP service (see
1257.B --enable-tftp
1258) then only the filename is required here to enable network booting.
8ef5ada2
SK
1259If the optional tag(s) are given,
1260they must match for this configuration to be sent.
7de060b0
SK
1261Instead of an IP address, the TFTP server address can be given as a domain
1262name which is looked up in /etc/hosts. This name can be associated in
1263/etc/hosts with multiple IP addresses, which are used round-robin.
1264This facility can be used to load balance the tftp load among a set of servers.
1265.TP
1266.B --dhcp-sequential-ip
1267Dnsmasq is designed to choose IP addresses for DHCP clients using a
1268hash of the client's MAC address. This normally allows a client's
1269address to remain stable long-term, even if the client sometimes allows its DHCP
1270lease to expire. In this default mode IP addresses are distributed
1271pseudo-randomly over the entire available address range. There are
1272sometimes circumstances (typically server deployment) where it is more
1273convenient to have IP
1274addresses allocated sequentially, starting from the lowest available
1275address, and setting this flag enables this mode. Note that in the
1276sequential mode, clients which allow a lease to expire are much more
1277likely to move IP address; for this reason it should not be generally used.
7622fc06 1278.TP
751d6f4a 1279.B --pxe-service=[tag:<tag>,]<CSA>,<menu text>[,<basename>|<bootservicetype>][,<server address>|<server_name>]
7622fc06
SK
1280Most uses of PXE boot-ROMS simply allow the PXE
1281system to obtain an IP address and then download the file specified by
1282.B dhcp-boot
1283and execute it. However the PXE system is capable of more complex
1284functions when supported by a suitable DHCP server.
1285
1286This specifies a boot option which may appear in a PXE boot menu. <CSA> is
1287client system type, only services of the correct type will appear in a
1288menu. The known types are x86PC, PC98, IA64_EFI, Alpha, Arc_x86,
1289Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI and X86-64_EFI; an
1290integer may be used for other types. The
1291parameter after the menu text may be a file name, in which case dnsmasq acts as a
1292boot server and directs the PXE client to download the file by TFTP,
1293either from itself (
1294.B enable-tftp
751d6f4a
SK
1295must be set for this to work) or another TFTP server if the final server
1296address/name is given.
7622fc06
SK
1297Note that the "layer"
1298suffix (normally ".0") is supplied by PXE, and should not be added to
1299the basename. If an integer boot service type, rather than a basename
1300is given, then the PXE client will search for a
1301suitable boot service for that type on the network. This search may be done
751d6f4a 1302by broadcast, or direct to a server if its IP address/name is provided.
316e2730
SK
1303If no boot service type or filename is provided (or a boot service type of 0 is specified)
1304then the menu entry will abort the net boot procedure and
751d6f4a
SK
1305continue booting from local media. The server address can be given as a domain
1306name which is looked up in /etc/hosts. This name can be associated in
1307/etc/hosts with multiple IP addresses, which are used round-robin.
7622fc06 1308.TP
8ef5ada2 1309.B --pxe-prompt=[tag:<tag>,]<prompt>[,<timeout>]
7622fc06
SK
1310Setting this provides a prompt to be displayed after PXE boot. If the
1311timeout is given then after the
1312timeout has elapsed with no keyboard input, the first available menu
1313option will be automatically executed. If the timeout is zero then the first available menu
1314item will be executed immediately. If
1315.B pxe-prompt
a66d36ea 1316is omitted the system will wait for user input if there are multiple
7622fc06
SK
1317items in the menu, but boot immediately if
1318there is only one. See
1319.B pxe-service
1320for details of menu items.
1321
1322Dnsmasq supports PXE "proxy-DHCP", in this case another DHCP server on
1323the network is responsible for allocating IP addresses, and dnsmasq
1324simply provides the information given in
1325.B pxe-prompt
1326and
1327.B pxe-service
1328to allow netbooting. This mode is enabled using the
1329.B proxy
1330keyword in
1331.B dhcp-range.
9e4abcb5 1332.TP
44a2a316
SK
1333.B \-X, --dhcp-lease-max=<number>
1334Limits dnsmasq to the specified maximum number of DHCP leases. The
8ef5ada2 1335default is 1000. This limit is to prevent DoS attacks from hosts which
44a2a316
SK
1336create thousands of leases and use lots of memory in the dnsmasq
1337process.
1338.TP
fd9fa481 1339.B \-K, --dhcp-authoritative
095f6255
SK
1340Should be set when dnsmasq is definitely the only DHCP server on a network.
1341For DHCPv4, it changes the behaviour from strict RFC compliance so that DHCP requests on
fd9fa481 1342unknown leases from unknown hosts are not ignored. This allows new hosts
cdeda28f
SK
1343to get a lease without a tedious timeout under all circumstances. It also
1344allows dnsmasq to rebuild its lease database without each client needing to
095f6255
SK
1345reacquire a lease, if the database is lost. For DHCPv6 it sets the
1346priority in replies to 255 (the maximum) instead of 0 (the minimum).
9e038946
SK
1347.TP
1348.B --dhcp-alternate-port[=<server port>[,<client port>]]
1adadf58 1349(IPv4 only) Change the ports used for DHCP from the default. If this option is
9e038946
SK
1350given alone, without arguments, it changes the ports used for DHCP
1351from 67 and 68 to 1067 and 1068. If a single argument is given, that
1352port number is used for the server and the port number plus one used
1353for the client. Finally, two port numbers allows arbitrary
1354specification of both server and client ports for DHCP.
fd9fa481 1355.TP
9009d746 1356.B \-3, --bootp-dynamic[=<network-id>[,<network-id>]]
1adadf58 1357(IPv4 only) Enable dynamic allocation of IP addresses to BOOTP clients. Use this
3d8df260
SK
1358with care, since each address allocated to a BOOTP client is leased
1359forever, and therefore becomes permanently unavailable for re-use by
9009d746
SK
1360other hosts. if this is given without tags, then it unconditionally
1361enables dynamic allocation. With tags, only when the tags are all
1362set. It may be repeated with different tag sets.
3d8df260 1363.TP
5e9e0efb 1364.B \-5, --no-ping
1adadf58 1365(IPv4 only) By default, the DHCP server will attempt to ensure that an address in
5e9e0efb
SK
1366not in use before allocating it to a host. It does this by sending an
1367ICMP echo request (aka "ping") to the address in question. If it gets
1368a reply, then the address must already be in use, and another is
1369tried. This flag disables this check. Use with caution.
1370.TP
f2621c7f
SK
1371.B --log-dhcp
1372Extra logging for DHCP: log all the options sent to DHCP clients and
8ef5ada2 1373the tags used to determine them.
f2621c7f 1374.TP
8c0b73d3
KDB
1375.B --quiet-dhcp, --quiet-dhcp6, --quiet-ra
1376Suppress logging of the routine operation of these protocols. Errors and
1377problems will still be logged. --quiet-dhcp and quiet-dhcp6 are
1378over-ridden by --log-dhcp.
1379.TP
9e4abcb5 1380.B \-l, --dhcp-leasefile=<path>
73a08a24 1381Use the specified file to store DHCP lease information.
208b65c5 1382.TP
8b372704
SK
1383.B --dhcp-duid=<enterprise-id>,<uid>
1384(IPv6 only) Specify the server persistent UID which the DHCPv6 server
1385will use. This option is not normally required as dnsmasq creates a
1386DUID automatically when it is first needed. When given, this option
1387provides dnsmasq the data required to create a DUID-EN type DUID. Note
1388that once set, the DUID is stored in the lease database, so to change between DUID-EN and
1389automatically created DUIDs or vice-versa, the lease database must be
1390re-intialised. The enterprise-id is assigned by IANA, and the uid is a
1391string of hex octets unique to a particular device.
1392.TP
7cebd20f 1393.B \-6 --dhcp-script=<path>
a9530964
SK
1394Whenever a new DHCP lease is created, or an old one destroyed, or a
1395TFTP file transfer completes, the
8ef5ada2
SK
1396executable specified by this option is run. <path>
1397must be an absolute pathname, no PATH search occurs.
1398The arguments to the process
7cebd20f 1399are "add", "old" or "del", the MAC
1adadf58 1400address of the host (or DUID for IPv6) , the IP address, and the hostname,
7cebd20f
SK
1401if known. "add" means a lease has been created, "del" means it has
1402been destroyed, "old" is a notification of an existing lease when
208b65c5
SK
1403dnsmasq starts or a change to MAC address or hostname of an existing
1404lease (also, lease length or expiry and client-id, if leasefile-ro is set).
9009d746
SK
1405If the MAC address is from a network type other than ethernet,
1406it will have the network type prepended, eg "06-01:23:45:67:89:ab" for
1407token ring. The process is run as root (assuming that dnsmasq was originally run as
1697269c 1408root) even if dnsmasq is configured to change UID to an unprivileged user.
8ef5ada2
SK
1409
1410The environment is inherited from the invoker of dnsmasq, with some or
1adadf58 1411all of the following variables added
8ef5ada2 1412
1adadf58 1413For both IPv4 and IPv6:
8ef5ada2
SK
1414
1415DNSMASQ_DOMAIN if the fully-qualified domain name of the host is
28866e95
SK
1416known, this is set to the domain part. (Note that the hostname passed
1417to the script as an argument is never fully-qualified.)
8ef5ada2 1418
1adadf58
SK
1419If the client provides a hostname, DNSMASQ_SUPPLIED_HOSTNAME
1420
1421If the client provides user-classes, DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn
8ef5ada2
SK
1422
1423If dnsmasq was compiled with HAVE_BROKEN_RTC, then
208b65c5 1424the length of the lease (in seconds) is stored in
1697269c 1425DNSMASQ_LEASE_LENGTH, otherwise the time of lease expiry is stored in
5aabfc78
SK
1426DNSMASQ_LEASE_EXPIRES. The number of seconds until lease expiry is
1427always stored in DNSMASQ_TIME_REMAINING.
8ef5ada2 1428
5aabfc78 1429If a lease used to have a hostname, which is
1697269c
SK
1430removed, an "old" event is generated with the new state of the lease,
1431ie no name, and the former name is provided in the environment
8ef5ada2
SK
1432variable DNSMASQ_OLD_HOSTNAME.
1433
1434DNSMASQ_INTERFACE stores the name of
9e038946 1435the interface on which the request arrived; this is not set for "old"
8ef5ada2
SK
1436actions when dnsmasq restarts.
1437
1438DNSMASQ_RELAY_ADDRESS is set if the client
316e2730 1439used a DHCP relay to contact dnsmasq and the IP address of the relay
8ef5ada2
SK
1440is known.
1441
1442DNSMASQ_TAGS contains all the tags set during the
316e2730 1443DHCP transaction, separated by spaces.
8ef5ada2 1444
e46164e0
SK
1445DNSMASQ_LOG_DHCP is set if
1446.B --log-dhcp
1447is in effect.
a9530964 1448
1adadf58
SK
1449For IPv4 only:
1450
1451DNSMASQ_CLIENT_ID if the host provided a client-id.
1452
dd1721c7
SK
1453DNSMASQ_CIRCUIT_ID, DNSMASQ_SUBSCRIBER_ID, DNSMASQ_REMOTE_ID if a
1454DHCP relay-agent added any of these options.
1455
1adadf58
SK
1456If the client provides vendor-class, DNSMASQ_VENDOR_CLASS.
1457
1458For IPv6 only:
1459
1460If the client provides vendor-class, DNSMASQ_VENDOR_CLASS_ID,
1461containing the IANA enterprise id for the class, and
1462DNSMASQ_VENDOR_CLASS0..DNSMASQ_VENDOR_CLASSn for the data.
1463
57f460de 1464DNSMASQ_SERVER_DUID containing the DUID of the server: this is the same for
1adadf58
SK
1465every call to the script.
1466
1467DNSMASQ_IAID containing the IAID for the lease. If the lease is a
1468temporary allocation, this is prefixed to 'T'.
1469
89500e31 1470DNSMASQ_MAC containing the MAC address of the client, if known.
1adadf58
SK
1471
1472Note that the supplied hostname, vendorclass and userclass data is
1473only supplied for
1474"add" actions or "old" actions when a host resumes an existing lease,
1475since these data are not held in dnsmasq's lease
1476database.
1477
a9530964
SK
1478
1479
9e038946 1480All file descriptors are
7cebd20f
SK
1481closed except stdin, stdout and stderr which are open to /dev/null
1482(except in debug mode).
8ef5ada2
SK
1483
1484The script is not invoked concurrently: at most one instance
1485of the script is ever running (dnsmasq waits for an instance of script to exit
1486before running the next). Changes to the lease database are which
1487require the script to be invoked are queued awaiting exit of a running instance.
1488If this queueing allows multiple state changes occur to a single
1489lease before the script can be run then
1490earlier states are discarded and the current state of that lease is
1491reflected when the script finally runs.
1492
1493At dnsmasq startup, the script will be invoked for
7cebd20f 1494all existing leases as they are read from the lease file. Expired
8ef5ada2 1495leases will be called with "del" and others with "old". When dnsmasq
5aabfc78 1496receives a HUP signal, the script will be invoked for existing leases
9e038946 1497with an "old " event.
a9530964
SK
1498
1499
1500There are two further actions which may appear as the first argument
1501to the script, "init" and "tftp". More may be added in the future, so
1502scripts should be written to ignore unknown actions. "init" is
e46164e0 1503described below in
a9530964
SK
1504.B --leasefile-ro
1505The "tftp" action is invoked when a TFTP file transfer completes: the
1506arguments are the file size in bytes, the address to which the file
1507was sent, and the complete pathname of the file.
1508
9e038946 1509.TP
57f460de
SK
1510.B --dhcp-luascript=<path>
1511Specify a script written in Lua, to be run when leases are created,
1512destroyed or changed. To use this option, dnsmasq must be compiled
1513with the correct support. The Lua interpreter is intialised once, when
1514dnsmasq starts, so that global variables persist between lease
1515events. The Lua code must define a
1516.B lease
1517function, and may provide
1518.B init
1519and
1520.B shutdown
1521functions, which are called, without arguments when dnsmasq starts up
a9530964
SK
1522and terminates. It may also provide a
1523.B tftp
1524function.
57f460de
SK
1525
1526The
1527.B lease
a9530964 1528function receives the information detailed in
57f460de
SK
1529.B --dhcp-script.
1530It gets two arguments, firstly the action, which is a string
1531containing, "add", "old" or "del", and secondly a table of tag value
1532pairs. The tags mostly correspond to the environment variables
1533detailed above, for instance the tag "domain" holds the same data as
1534the environment variable DNSMASQ_DOMAIN. There are a few extra tags
1535which hold the data supplied as arguments to
1536.B --dhcp-script.
1537These are
1538.B mac_address, ip_address
1539and
1540.B hostname
1541for IPv4, and
1542.B client_duid, ip_address
1543and
1544.B hostname
a9530964
SK
1545for IPv6.
1546
1547The
1548.B tftp
1549function is called in the same way as the lease function, and the
1550table holds the tags
1551.B destination_address,
1552.B file_name
1553and
1554.B file_size.
57f460de 1555.TP
9e038946 1556.B --dhcp-scriptuser
57f460de 1557Specify the user as which to run the lease-change script or Lua script. This defaults to root, but can be changed to another user using this flag.
208b65c5
SK
1558.TP
1559.B \-9, --leasefile-ro
1560Completely suppress use of the lease database file. The file will not
1561be created, read, or written. Change the way the lease-change
1562script (if one is provided) is called, so that the lease database may
1563be maintained in external storage by the script. In addition to the
f2621c7f 1564invocations given in
208b65c5
SK
1565.B --dhcp-script
1566the lease-change script is called once, at dnsmasq startup, with the
1567single argument "init". When called like this the script should write
1568the saved state of the lease database, in dnsmasq leasefile format, to
1569stdout and exit with zero exit code. Setting this
1570option also forces the leasechange script to be called on changes
1571to the client-id and lease length and expiry time.
9e4abcb5 1572.TP
832af0ba
SK
1573.B --bridge-interface=<interface>,<alias>[,<alias>]
1574Treat DHCP request packets arriving at any of the <alias> interfaces
7622fc06
SK
1575as if they had arrived at <interface>. This option is necessary when
1576using "old style" bridging on BSD platforms, since
832af0ba 1577packets arrive at tap interfaces which don't have an IP address.
70772c90 1578A trailing '*' wildcard can be used in each <alias>.
832af0ba 1579.TP
28866e95 1580.B \-s, --domain=<domain>[,<address range>[,local]]
9009d746
SK
1581Specifies DNS domains for the DHCP server. Domains may be be given
1582unconditionally (without the IP range) or for limited IP ranges. This has two effects;
9e4abcb5
SK
1583firstly it causes the DHCP server to return the domain to any hosts
1584which request it, and secondly it sets the domain which it is legal
1b7ecd11
SK
1585for DHCP-configured hosts to claim. The intention is to constrain
1586hostnames so that an untrusted host on the LAN cannot advertise
1587its name via dhcp as e.g. "microsoft.com" and capture traffic not
1588meant for it. If no domain suffix is specified, then any DHCP
1589hostname with a domain part (ie with a period) will be disallowed
1590and logged. If suffix is specified, then hostnames with a domain
1591part are allowed, provided the domain part matches the suffix. In
1592addition, when a suffix is set then hostnames without a domain
1593part have the suffix added as an optional domain part. Eg on my network I can set
3d8df260 1594.B --domain=thekelleys.org.uk
9e4abcb5
SK
1595and have a machine whose DHCP hostname is "laptop". The IP address for that machine is available from
1596.B dnsmasq
de37951c
SK
1597both as "laptop" and "laptop.thekelleys.org.uk". If the domain is
1598given as "#" then the domain is read from the first "search" directive
28866e95
SK
1599in /etc/resolv.conf (or equivalent).
1600
1601The address range can be of the form
9009d746
SK
1602<ip address>,<ip address> or <ip address>/<netmask> or just a single
1603<ip address>. See
1604.B --dhcp-fqdn
1605which can change the behaviour of dnsmasq with domains.
28866e95
SK
1606
1607If the address range is given as ip-address/network-size, then a
1608additional flag "local" may be supplied which has the effect of adding
1609--local declarations for forward and reverse DNS queries. Eg.
1610.B --domain=thekelleys.org.uk,192.168.0.0/24,local
1611is identical to
1612.B --domain=thekelleys.org.uk,192.168.0.0/24
1613--local=/thekelleys.org.uk/ --local=/0.168.192.in-addr.arpa/
1614The network size must be 8, 16 or 24 for this to be legal.
9009d746
SK
1615.TP
1616.B --dhcp-fqdn
1617In the default mode, dnsmasq inserts the unqualified names of
1618DHCP clients into the DNS. For this reason, the names must be unique,
1619even if two clients which have the same name are in different
1620domains. If a second DHCP client appears which has the same name as an
a66d36ea 1621existing client, the name is transferred to the new client. If
9009d746
SK
1622.B --dhcp-fqdn
1623is set, this behaviour changes: the unqualified name is no longer
1624put in the DNS, only the qualified name. Two DHCP clients with the
1625same name may both keep the name, provided that the domain part is
1626different (ie the fully qualified names differ.) To ensure that all
1627names have a domain part, there must be at least
1628.B --domain
1629without an address specified when
1630.B --dhcp-fqdn
1631is set.
9e4abcb5 1632.TP
c72daea8
SK
1633.B --dhcp-client-update
1634Normally, when giving a DHCP lease, dnsmasq sets flags in the FQDN
1635option to tell the client not to attempt a DDNS update with its name
1636and IP address. This is because the name-IP pair is automatically
1637added into dnsmasq's DNS view. This flag suppresses that behaviour,
1638this is useful, for instance, to allow Windows clients to update
1639Active Directory servers. See RFC 4702 for details.
1640.TP
c5ad4e79
SK
1641.B --enable-ra
1642Enable dnsmasq's IPv6 Router Advertisement feature. DHCPv6 doesn't
1643handle complete network configuration in the same way as DHCPv4. Router
1644discovery and (possibly) prefix discovery for autonomous address
1645creation are handled by a different protocol. When DHCP is in use,
1646only a subset of this is needed, and dnsmasq can handle it, using
1647existing DHCP configuration to provide most data. When RA is enabled,
1648dnsmasq will advertise a prefix for each dhcp-range, with default
1649router and recursive DNS server as the relevant link-local address on
e8ca69ea
SK
1650the machine running dnsmasq. By default, he "managed address" bits are set, and
1651the "use SLAAC" bit is reset. This can be changed for individual
1652subnets with the mode keywords described in
1653.B --dhcp-range.
18f0fb05
SK
1654RFC6106 DNS parameters are included in the advertisements. By default,
1655the relevant link-local address of the machine running dnsmasq is sent
1656as recursive DNS server. If provided, the DHCPv6 options dns-server and
1657domain-search are used for RDNSS and DNSSL.
c5ad4e79 1658.TP
c4cd95df
SK
1659.B --ra-param=<interface>,[high|low],[[<ra-interval>],<router lifetime>]
1660Set non-default values for router advertisements sent via an
1661interface. The priority field for the router may be altered from the
1662default of medium with eg
1663.B --ra-param=eth0,high.
1664The interval between router advertisements may be set (in seconds) with
1665.B --ra-param=eth0,60.
1666The lifetime of the route may be changed or set to zero, which allows
1667a router to advertise prefixes but not a route via itself.
1668.B --ra-parm=eth0,0,0
1669(A value of zero for the interval means the default value.) All three parameters may be set at once.
1670.B --ra-param=low,60,1200
1671The interface field may include a wildcard.
8d030462 1672.TP
2937f8a0 1673.B --enable-tftp[=<interface>[,<interface>]]
832af0ba 1674Enable the TFTP server function. This is deliberately limited to that
9e038946 1675needed to net-boot a client. Only reading is allowed; the tsize and
8ef5ada2 1676blksize extensions are supported (tsize is only supported in octet
2937f8a0
SK
1677mode). Without an argument, the TFTP service is provided to the same set of interfaces as DHCP service.
1678If the list of interfaces is provided, that defines which interfaces recieve TFTP service.
832af0ba 1679.TP
8ef5ada2 1680.B --tftp-root=<directory>[,<interface>]
832af0ba
SK
1681Look for files to transfer using TFTP relative to the given
1682directory. When this is set, TFTP paths which include ".." are
1683rejected, to stop clients getting outside the specified root.
f2621c7f 1684Absolute paths (starting with /) are allowed, but they must be within
8ef5ada2
SK
1685the tftp-root. If the optional interface argument is given, the
1686directory is only used for TFTP requests via that interface.
832af0ba 1687.TP
5aabfc78
SK
1688.B --tftp-unique-root
1689Add the IP address of the TFTP client as a path component on the end
1690of the TFTP-root (in standard dotted-quad format). Only valid if a
1691tftp-root is set and the directory exists. For instance, if tftp-root is "/tftp" and client
16921.2.3.4 requests file "myfile" then the effective path will be
1693"/tftp/1.2.3.4/myfile" if /tftp/1.2.3.4 exists or /tftp/myfile otherwise.
1694.TP
832af0ba 1695.B --tftp-secure
5aabfc78 1696Enable TFTP secure mode: without this, any file which is readable by
832af0ba
SK
1697the dnsmasq process under normal unix access-control rules is
1698available via TFTP. When the --tftp-secure flag is given, only files
1699owned by the user running the dnsmasq process are accessible. If
1700dnsmasq is being run as root, different rules apply: --tftp-secure
1b7ecd11 1701has no effect, but only files which have the world-readable bit set
832af0ba
SK
1702are accessible. It is not recommended to run dnsmasq as root with TFTP
1703enabled, and certainly not without specifying --tftp-root. Doing so
1704can expose any world-readable file on the server to any host on the net.
1705.TP
61ce600b
SK
1706.B --tftp-lowercase
1707Convert filenames in TFTP requests to all lowercase. This is useful
1708for requests from Windows machines, which have case-insensitive
1709filesystems and tend to play fast-and-loose with case in filenames.
1710Note that dnsmasq's tftp server always converts "\\" to "/" in filenames.
1711.TP
832af0ba
SK
1712.B --tftp-max=<connections>
1713Set the maximum number of concurrent TFTP connections allowed. This
1714defaults to 50. When serving a large number of TFTP connections,
1715per-process file descriptor limits may be encountered. Dnsmasq needs
1716one file descriptor for each concurrent TFTP connection and one
1717file descriptor per unique file (plus a few others). So serving the
1718same file simultaneously to n clients will use require about n + 10 file
1719descriptors, serving different files simultaneously to n clients will
824af85b
SK
1720require about (2*n) + 10 descriptors. If
1721.B --tftp-port-range
1722is given, that can affect the number of concurrent connections.
6b01084f
SK
1723.TP
1724.B --tftp-no-blocksize
1725Stop the TFTP server from negotiating the "blocksize" option with a
1726client. Some buggy clients request this option but then behave badly
1727when it is granted.
824af85b
SK
1728.TP
1729.B --tftp-port-range=<start>,<end>
1730A TFTP server listens on a well-known port (69) for connection initiation,
1731but it also uses a dynamically-allocated port for each
1732connection. Normally these are allocated by the OS, but this option
1733specifies a range of ports for use by TFTP transfers. This can be
1734useful when TFTP has to traverse a firewall. The start of the range
1735cannot be lower than 1025 unless dnsmasq is running as root. The number
1736of concurrent TFTP connections is limited by the size of the port range.
832af0ba 1737.TP
b8187c80
SK
1738.B \-C, --conf-file=<file>
1739Specify a different configuration file. The conf-file option is also allowed in
28866e95
SK
1740configuration files, to include multiple configuration files. A
1741filename of "-" causes dnsmasq to read configuration from stdin.
849a8357 1742.TP
3e1551a1 1743.B \-7, --conf-dir=<directory>[,<file-extension>......],
849a8357 1744Read all the files in the given directory as configuration
1f15b81d
SK
1745files. If extension(s) are given, any files which end in those
1746extensions are skipped. Any files whose names end in ~ or start with . or start and end
3e1551a1
SK
1747with # are always skipped. If the extension starts with * then only files
1748which have that extension are loaded. So
1749.B --conf-dir=/path/to/dir,*.conf
1750loads all files with the suffix .conf in /path/to/dir. This flag may be given on the command
1751line or in a configuration file. If giving it on the command line, be sure to
1752escape * characters.
7b1eae4f
SK
1753.TP
1754.B --servers-file=<file>
1755A special case of
1756.B --conf-file
1757which differs in two respects. Firstly, only --server and --rev-server are allowed
1758in the configuration file included. Secondly, the file is re-read and the configuration
1759therein is updated when dnsmasq recieves SIGHUP.
9e4abcb5 1760.SH CONFIG FILE
3be34541
SK
1761At startup, dnsmasq reads
1762.I /etc/dnsmasq.conf,
1763if it exists. (On
1764FreeBSD, the file is
1765.I /usr/local/etc/dnsmasq.conf
b8187c80
SK
1766) (but see the
1767.B \-C
849a8357
SK
1768and
1769.B \-7
1770options.) The format of this
9e4abcb5
SK
1771file consists of one option per line, exactly as the long options detailed
1772in the OPTIONS section but without the leading "--". Lines starting with # are comments and ignored. For
b49644f3 1773options which may only be specified once, the configuration file overrides
b8187c80 1774the command line. Quoting is allowed in a config file:
3d8df260 1775between " quotes the special meanings of ,:. and # are removed and the
824af85b
SK
1776following escapes are allowed: \\\\ \\" \\t \\e \\b \\r and \\n. The later
1777corresponding to tab, escape, backspace, return and newline.
9e4abcb5
SK
1778.SH NOTES
1779When it receives a SIGHUP,
1780.B dnsmasq
3be34541 1781clears its cache and then re-loads
5aabfc78
SK
1782.I /etc/hosts
1783and
1784.I /etc/ethers
824af85b 1785and any file given by --dhcp-hostsfile, --dhcp-optsfile or --addn-hosts.
5aabfc78
SK
1786The dhcp lease change script is called for all
1787existing DHCP leases. If
9e4abcb5
SK
1788.B
1789--no-poll
3be34541
SK
1790is set SIGHUP also re-reads
1791.I /etc/resolv.conf.
1792SIGHUP
b49644f3 1793does NOT re-read the configuration file.
9e4abcb5
SK
1794.PP
1795When it receives a SIGUSR1,
1796.B dnsmasq
824af85b 1797writes statistics to the system log. It writes the cache size,
9e4abcb5
SK
1798the number of names which have had to removed from the cache before
1799they expired in order to make room for new names and the total number
fec216df
SK
1800of names that have been inserted into the cache. The number of cache hits and
1801misses and the number of authoritative queries answered are also given. For each upstream
824af85b
SK
1802server it gives the number of queries sent, and the number which
1803resulted in an error. In
9e4abcb5 1804.B --no-daemon
5aabfc78 1805mode or when full logging is enabled (-q), a complete dump of the
fec216df
SK
1806contents of the cache is made.
1807
1808The cache statistics are also available in the DNS as answers to
1809queries of class CHAOS and type TXT in domain bind. The domain names are cachesize.bind, insertions.bind, evictions.bind,
1810misses.bind, hits.bind, auth.bind and servers.bind. An example command to query this, using the
1811.B dig
1812utility would be
1813
1814dig +short chaos txt cachesize.bind
1815
5aabfc78
SK
1816.PP
1817When it receives SIGUSR2 and it is logging direct to a file (see
1818.B --log-facility
1819)
1820.B dnsmasq
1821will close and reopen the log file. Note that during this operation,
1822dnsmasq will not be running as root. When it first creates the logfile
1823dnsmasq changes the ownership of the file to the non-root user it will run
1824as. Logrotate should be configured to create a new log file with
9e038946 1825the ownership which matches the existing one before sending SIGUSR2.
5aabfc78
SK
1826If TCP DNS queries are in progress, the old logfile will remain open in
1827child processes which are handling TCP queries and may continue to be
1828written. There is a limit of 150 seconds, after which all existing TCP
1829processes will have expired: for this reason, it is not wise to
1830configure logfile compression for logfiles which have just been
1831rotated. Using logrotate, the required options are
1832.B create
1833and
1834.B delaycompress.
1835
1836
9e4abcb5 1837.PP
9e4abcb5
SK
1838Dnsmasq is a DNS query forwarder: it it not capable of recursively
1839answering arbitrary queries starting from the root servers but
1840forwards such queries to a fully recursive upstream DNS server which is
1841typically provided by an ISP. By default, dnsmasq reads
3be34541
SK
1842.I /etc/resolv.conf
1843to discover the IP
9e4abcb5
SK
1844addresses of the upstream nameservers it should use, since the
1845information is typically stored there. Unless
1846.B --no-poll
1847is used,
1848.B dnsmasq
3be34541
SK
1849checks the modification time of
1850.I /etc/resolv.conf
1851(or equivalent if
9e4abcb5
SK
1852.B \--resolv-file
1853is used) and re-reads it if it changes. This allows the DNS servers to
1854be set dynamically by PPP or DHCP since both protocols provide the
1855information.
3be34541
SK
1856Absence of
1857.I /etc/resolv.conf
1858is not an error
9e4abcb5 1859since it may not have been created before a PPP connection exists. Dnsmasq
3be34541
SK
1860simply keeps checking in case
1861.I /etc/resolv.conf
1862is created at any
9e4abcb5
SK
1863time. Dnsmasq can be told to parse more than one resolv.conf
1864file. This is useful on a laptop, where both PPP and DHCP may be used:
3be34541
SK
1865dnsmasq can be set to poll both
1866.I /etc/ppp/resolv.conf
1867and
1868.I /etc/dhcpc/resolv.conf
1869and will use the contents of whichever changed
9e4abcb5
SK
1870last, giving automatic switching between DNS servers.
1871.PP
1872Upstream servers may also be specified on the command line or in
b49644f3 1873the configuration file. These server specifications optionally take a
9e4abcb5
SK
1874domain name which tells dnsmasq to use that server only to find names
1875in that particular domain.
1876.PP
1877In order to configure dnsmasq to act as cache for the host on which it is running, put "nameserver 127.0.0.1" in
1878.I /etc/resolv.conf
1879to force local processes to send queries to
1880dnsmasq. Then either specify the upstream servers directly to dnsmasq
1881using
1882.B \--server
1883options or put their addresses real in another file, say
1884.I /etc/resolv.dnsmasq
1885and run dnsmasq with the
1886.B \-r /etc/resolv.dnsmasq
1887option. This second technique allows for dynamic update of the server
1888addresses by PPP or DHCP.
f6b7dc47
SK
1889.PP
1890Addresses in /etc/hosts will "shadow" different addresses for the same
1891names in the upstream DNS, so "mycompany.com 1.2.3.4" in /etc/hosts will ensure that
1892queries for "mycompany.com" always return 1.2.3.4 even if queries in
1893the upstream DNS would otherwise return a different address. There is
1894one exception to this: if the upstream DNS contains a CNAME which
1895points to a shadowed name, then looking up the CNAME through dnsmasq
1896will result in the unshadowed address associated with the target of
1897the CNAME. To work around this, add the CNAME to /etc/hosts so that
1898the CNAME is shadowed too.
1899
3be34541 1900.PP
8ef5ada2
SK
1901The tag system works as follows: For each DHCP request, dnsmasq
1902collects a set of valid tags from active configuration lines which
1903include set:<tag>, including one from the
26128d27
SK
1904.B dhcp-range
1905used to allocate the address, one from any matching
1906.B dhcp-host
9009d746 1907(and "known" if a dhcp-host matches)
8ef5ada2
SK
1908The tag "bootp" is set for BOOTP requests, and a tag whose name is the
1909name of the interface on which the request arrived is also set.
1910
a66d36ea 1911Any configuration lines which include one or more tag:<tag> constructs
8ef5ada2
SK
1912will only be valid if all that tags are matched in the set derived
1913above. Typically this is dhcp-option.
26128d27 1914.B dhcp-option
8ef5ada2 1915which has tags will be used in preference to an untagged
26128d27
SK
1916.B dhcp-option,
1917provided that _all_ the tags match somewhere in the
8ef5ada2 1918set collected as described above. The prefix '!' on a tag means 'not'
e62e9b61 1919so --dhcp-option=tag:!purple,3,1.2.3.4 sends the option when the
8ef5ada2
SK
1920tag purple is not in the set of valid tags. (If using this in a
1921command line rather than a configuration file, be sure to escape !,
1922which is a shell metacharacter)
7de060b0
SK
1923
1924When selecting dhcp-options, a tag from dhcp-range is second class
1925relative to other tags, to make it easy to override options for
1926individual hosts, so
1927.B dhcp-range=set:interface1,......
1928.B dhcp-host=set:myhost,.....
1929.B dhcp-option=tag:interface1,option:nis-domain,"domain1"
1930.B dhcp-option=tag:myhost,option:nis-domain,"domain2"
1931will set the NIS-domain to domain1 for hosts in the range, but
1932override that to domain2 for a particular host.
1933
26128d27 1934.PP
8ef5ada2 1935Note that for
f6b7dc47 1936.B dhcp-range
8ef5ada2
SK
1937both tag:<tag> and set:<tag> are allowed, to both select the range in
1938use based on (eg) dhcp-host, and to affect the options sent, based on
1939the range selected.
1940
1941This system evolved from an earlier, more limited one and for backward
1942compatibility "net:" may be used instead of "tag:" and "set:" may be
1943omitted. (Except in
1944.B dhcp-host,
1945where "net:" may be used instead of "set:".) For the same reason, '#'
1946may be used instead of '!' to indicate NOT.
f6b7dc47 1947.PP
3be34541
SK
1948The DHCP server in dnsmasq will function as a BOOTP server also,
1949provided that the MAC address and IP address for clients are given,
1950either using
1951.B dhcp-host
1952configurations or in
1953.I /etc/ethers
1954, and a
1955.B dhcp-range
1956configuration option is present to activate the DHCP server
b8187c80
SK
1957on a particular network. (Setting --bootp-dynamic removes the need for
1958static address mappings.) The filename
8ef5ada2
SK
1959parameter in a BOOTP request is used as a tag,
1960as is the tag "bootp", allowing some control over the options returned to
3be34541
SK
1961different classes of hosts.
1962
333b2ceb
SK
1963.SH AUTHORITATIVE CONFIGURATION
1964.PP
1965Configuring dnsmasq to act as an authoritative DNS server is
1966complicated by the fact that it involves configuration of external DNS
1967servers to provide delegation. We will walk through three scenarios of
1968increasing complexity. Prerequisites for all of these scenarios
81925ab7 1969are a globally accessible IP address, an A or AAAA record pointing to that address,
333b2ceb
SK
1970and an external DNS server capable of doing delegation of the zone in
1971question. For the first part of this explanation, we will call the A (or AAAA) record
1972for the globally accessible address server.example.com, and the zone
1973for which dnsmasq is authoritative our.zone.com.
1974
1975The simplest configuration consists of two lines of dnsmasq configuration; something like
1976
1977.nf
1978.B auth-server=server.example.com,eth0
79cb46c0 1979.B auth-zone=our.zone.com,1.2.3.0/24
333b2ceb
SK
1980.fi
1981
1982and two records in the external DNS
1983
1984.nf
1985server.example.com A 192.0.43.10
1986our.zone.com NS server.example.com
1987.fi
1988
1989eth0 is the external network interface on which dnsmasq is listening,
1990and has (globally accessible) address 192.0.43.10.
1991
1992Note that the external IP address may well be dynamic (ie assigned
1993from an ISP by DHCP or PPP) If so, the A record must be linked to this
1994dynamic assignment by one of the usual dynamic-DNS systems.
1995
1996A more complex, but practically useful configuration has the address
1997record for the globally accessible IP address residing in the
1998authoritative zone which dnsmasq is serving, typically at the root. Now
1999we have
2000
2001.nf
2002.B auth-server=our.zone.com,eth0
79cb46c0 2003.B auth-zone=our.zone.com,1.2.3.0/24
333b2ceb
SK
2004.fi
2005
2006.nf
0f128eb5 2007our.zone.com A 1.2.3.4
333b2ceb
SK
2008our.zone.com NS our.zone.com
2009.fi
2010
2011The A record for our.zone.com has now become a glue record, it solves
2012the chicken-and-egg problem of finding the IP address of the
2013nameserver for our.zone.com when the A record is within that
2014zone. Note that this is the only role of this record: as dnsmasq is
2015now authoritative from our.zone.com it too must provide this
2016record. If the external address is static, this can be done with an
2017.B /etc/hosts
2018entry or
2019.B --host-record.
333b2ceb
SK
2020
2021.nf
0f128eb5
SK
2022.B auth-server=our.zone.com,eth0
2023.B host-record=our.zone.com,1.2.3.4
2024.B auth-zone=our.zone.com,1.2.3.0/24
2025.fi
2026
2027If the external address is dynamic, the address
2028associated with our.zone.com must be derived from the address of the
6f130def 2029relevant interface. This is done using
0f128eb5
SK
2030.B interface-name
2031Something like:
2032
2033.nf
2034.B auth-server=our.zone.com,eth0
2035.B interface-name=our.zone.com,eth0
32b4e4cb 2036.B auth-zone=our.zone.com,1.2.3.0/24,eth0
333b2ceb
SK
2037.fi
2038
32b4e4cb
SK
2039(The "eth0" argument in auth-zone adds the subnet containing eth0's
2040dynamic address to the zone, so that the interface-name returns the
2041address in outside queries.)
2042
333b2ceb
SK
2043Our final configuration builds on that above, but also adds a
2044secondary DNS server. This is another DNS server which learns the DNS data
2045for the zone by doing zones transfer, and acts as a backup should
2046the primary server become inaccessible. The configuration of the
2047secondary is beyond the scope of this man-page, but the extra
2048configuration of dnsmasq is simple:
2049
2050.nf
2051.B auth-sec-servers=secondary.myisp.com
2052.fi
2053
2054and
2055
2056.nf
2057our.zone.com NS secondary.myisp.com
2058.fi
2059
2060Adding auth-sec-servers enables zone transfer in dnsmasq, to allow the
2061secondary to collect the DNS data. If you wish to restrict this data
2062to particular hosts then
2063
2064.nf
2065.B auth-peer=<IP address of secondary>
2066.fi
2067
2068will do so.
2069
2070Dnsmasq acts as an authoritative server for in-addr.arpa and
1d7e0a36 2071ip6.arpa domains associated with the subnets given in auth-zone
333b2ceb
SK
2072declarations, so reverse (address to name) lookups can be simply
2073configured with a suitable NS record, for instance in this example,
2074where we allow 1.2.3.0/24 addresses.
2075
2076.nf
2077 3.2.1.in-addr.arpa NS our.zone.com
2078.fi
2079
2080Note that at present, reverse (in-addr.arpa and ip6.arpa) zones are
2081not available in zone transfers, so there is no point arranging
2082secondary servers for reverse lookups.
2083
2084.PP
2085When dnsmasq is configured to act as an authoritative server, the
2086following data is used to populate the authoritative zone.
2087.PP
2088.B --mx-host, --srv-host, --dns-rr, --txt-record, --naptr-record
2089, as long as the record names are in the authoritative domain.
2090.PP
2091.B --cname
2092as long as the record name is in the authoritative domain. If the
2093target of the CNAME is unqualified, then it is qualified with the
2094authoritative zone name.
2095.PP
2096IPv4 and IPv6 addresses from /etc/hosts (and
2097.B --addn-hosts
2098) and
2099.B --host-record
376d48c7
SK
2100and
2101.B --interface-name
333b2ceb
SK
2102provided the address falls into one of the subnets specified in the
2103.B --auth-zone.
333b2ceb
SK
2104.PP
2105Addresses of DHCP leases, provided the address falls into one of the subnets specified in the
376d48c7
SK
2106.B --auth-zone.
2107(If contructed DHCP ranges are is use, which depend on the address dynamically
2108assigned to an interface, then the form of
333b2ceb 2109.B --auth-zone
376d48c7
SK
2110which defines subnets by the dynamic address of an interface should
2111be used to ensure this condition is met.)
2112.PP
2113In the default mode, where a DHCP lease
333b2ceb
SK
2114has an unqualified name, and possibly a qualified name constructed
2115using
2116.B --domain
2117then the name in the authoritative zone is constructed from the
2118unqualified name and the zone's domain. This may or may not equal
2119that specified by
2120.B --domain.
2121If
2122.B --dhcp-fqdn
2123is set, then the fully qualified names associated with DHCP leases are
2124used, and must match the zone's domain.
2125
2126
2127
5aabfc78
SK
2128.SH EXIT CODES
2129.PP
21300 - Dnsmasq successfully forked into the background, or terminated
2131normally if backgrounding is not enabled.
2132.PP
21331 - A problem with configuration was detected.
2134.PP
21352 - A problem with network access occurred (address in use, attempt
2136to use privileged ports without permission).
2137.PP
9e038946 21383 - A problem occurred with a filesystem operation (missing
5aabfc78
SK
2139file/directory, permissions).
2140.PP
21414 - Memory allocation failure.
2142.PP
21435 - Other miscellaneous problem.
2144.PP
214511 or greater - a non zero return code was received from the
2146lease-script process "init" call. The exit code from dnsmasq is the
2147script's exit code with 10 added.
2148
1b7ecd11
SK
2149.SH LIMITS
2150The default values for resource limits in dnsmasq are generally
2151conservative, and appropriate for embedded router type devices with
2152slow processors and limited memory. On more capable hardware, it is
2153possible to increase the limits, and handle many more clients. The
2154following applies to dnsmasq-2.37: earlier versions did not scale as well.
2155
2156.PP
2157Dnsmasq is capable of handling DNS and DHCP for at least a thousand
8ef5ada2 2158clients. The DHCP lease times should not be very short (less than one hour). The
1b7ecd11
SK
2159value of
2160.B --dns-forward-max
2161can be increased: start with it equal to
2162the number of clients and increase if DNS seems slow. Note that DNS
2163performance depends too on the performance of the upstream
2164nameservers. The size of the DNS cache may be increased: the hard
2165limit is 10000 names and the default (150) is very low. Sending
2166SIGUSR1 to dnsmasq makes it log information which is useful for tuning
2167the cache size. See the
2168.B NOTES
2169section for details.
2170
2171.PP
2172The built-in TFTP server is capable of many simultaneous file
2173transfers: the absolute limit is related to the number of file-handles
2174allowed to a process and the ability of the select() system call to
2175cope with large numbers of file handles. If the limit is set too high
2176using
2177.B --tftp-max
2178it will be scaled down and the actual limit logged at
2179start-up. Note that more transfers are possible when the same file is
2180being sent than when each transfer sends a different file.
2181
2182.PP
2183It is possible to use dnsmasq to block Web advertising by using a list
2184of known banner-ad servers, all resolving to 127.0.0.1 or 0.0.0.0, in
2185.B /etc/hosts
2186or an additional hosts file. The list can be very long,
2187dnsmasq has been tested successfully with one million names. That size
2188file needs a 1GHz processor and about 60Mb of RAM.
2189
1f15b81d
SK
2190.SH INTERNATIONALISATION
2191Dnsmasq can be compiled to support internationalisation. To do this,
2192the make targets "all-i18n" and "install-i18n" should be used instead of
2193the standard targets "all" and "install". When internationalisation
2194is compiled in, dnsmasq will produce log messages in the local
2195language and support internationalised domain names (IDN). Domain
2196names in /etc/hosts, /etc/ethers and /etc/dnsmasq.conf which contain
2197non-ASCII characters will be translated to the DNS-internal punycode
2198representation. Note that
2199dnsmasq determines both the language for messages and the assumed
2200charset for configuration
2201files from the LANG environment variable. This should be set to the system
2202default value by the script which is responsible for starting
2203dnsmasq. When editing the configuration files, be careful to do so
2204using only the system-default locale and not user-specific one, since
2205dnsmasq has no direct way of determining the charset in use, and must
2206assume that it is the system default.
2207
9e4abcb5 2208.SH FILES
b49644f3
SK
2209.IR /etc/dnsmasq.conf
2210
2211.IR /usr/local/etc/dnsmasq.conf
9e4abcb5
SK
2212
2213.IR /etc/resolv.conf
28866e95
SK
2214.IR /var/run/dnsmasq/resolv.conf
2215.IR /etc/ppp/resolv.conf
2216.IR /etc/dhcpc/resolv.conf
9e4abcb5
SK
2217
2218.IR /etc/hosts
2219
3be34541
SK
2220.IR /etc/ethers
2221
b49644f3
SK
2222.IR /var/lib/misc/dnsmasq.leases
2223
2224.IR /var/db/dnsmasq.leases
9e4abcb5
SK
2225
2226.IR /var/run/dnsmasq.pid
2227.SH SEE ALSO
9e4abcb5
SK
2228.BR hosts (5),
2229.BR resolver (5)
2230.SH AUTHOR
2231This manual page was written by Simon Kelley <simon@thekelleys.org.uk>.
2232
2233