]> git.ipfire.org Git - people/ms/dnsmasq.git/blame - man/dnsmasq.8
import of dnsmasq-2.46.tar.gz
[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
5aabfc78
SK
9is a lightweight DNS, TFTP and DHCP server. It is intended to provide
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
16DNS queries for DHCP configured hosts.
17.PP
3be34541
SK
18The dnsmasq DHCP server supports static address assignments, multiple
19networks, DHCP-relay and RFC3011 subnet specifiers. It automatically
20sends a sensible default set of DHCP options, and can be configured to
f2621c7f 21send any desired set of DHCP options, including vendor-encapsulated
1b7ecd11
SK
22options. It includes a secure, read-only,
23TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP.
9e4abcb5 24.PP
3be34541 25Dnsmasq
1b7ecd11 26supports IPv6 for DNS, but not DHCP.
9e4abcb5
SK
27.SH OPTIONS
28Note that in general missing parameters are allowed and switch off
832af0ba 29functions, for instance "--pid-file" disables writing a PID file. On
33820b7e
SK
30BSD, unless the GNU getopt library is linked, the long form of the
31options does not work on the command line; it is still recognised in
32the configuration file.
9e4abcb5
SK
33.TP
34.B \-h, --no-hosts
35Don't read the hostnames in /etc/hosts.
36.TP
37.B \-H, --addn-hosts=<file>
38Additional hosts file. Read the specified file as well as /etc/hosts. If -h is given, read
fd9fa481
SK
39only the specified file. This option may be repeated for more than one
40additional hosts file.
9e4abcb5 41.TP
832af0ba
SK
42.B \-E, --expand-hosts
43Add the domain to simple names (without a period) in /etc/hosts
44in the same way as for DHCP-derived names.
45.TP
9e4abcb5
SK
46.B \-T, --local-ttl=<time>
47When replying with information from /etc/hosts or the DHCP leases
48file dnsmasq by default sets the time-to-live field to zero, meaning
49that the requestor should not itself cache the information. This is
50the correct thing to do in almost all situations. This option allows a
51time-to-live (in seconds) to be given for these replies. This will
52reduce the load on the server at the expense of clients using stale
53data under some circumstances.
54.TP
824af85b
SK
55.B --neg-ttl=<time>
56Negative replies from upstream servers normally contain time-to-live
57information in SOA records which dnsmasq uses for caching. If the
58replies from upstream servers omit this information, dnsmasq does not
59cache the reply. This option gives a default value for time-to-live
60(in seconds) which dnsmasq uses to cache negative replies even in
61the absence of an SOA record.
62.TP
3be34541
SK
63.B \-k, --keep-in-foreground
64Do not go into the background at startup but otherwise run as
3d8df260
SK
65normal. This is intended for use when dnsmasq is run under daemontools
66or launchd.
3be34541 67.TP
9e4abcb5
SK
68.B \-d, --no-daemon
69Debug mode: don't fork to the background, don't write a pid file,
70don't change user id, generate a complete cache dump on receipt on
3be34541
SK
71SIGUSR1, log to stderr as well as syslog, don't fork new processes
72to handle TCP queries.
9e4abcb5
SK
73.TP
74.B \-q, --log-queries
75Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1.
76.TP
849a8357
SK
77.B \-8, --log-facility=<facility>
78Set the facility to which dnsmasq will send syslog entries, this
f2621c7f 79defaults to DAEMON, and to LOCAL0 when debug mode is in operation. If
9e038946 80the facility given contains at least one '/' character, it is taken to
f2621c7f
SK
81be a filename, and dnsmasq logs to the given file, instead of
82syslog. (Errors whilst reading configuration will still go to syslog,
83but all output from a successful startup, and all output whilst
5aabfc78
SK
84running, will go exclusively to the file.) When logging to a file,
85dnsmasq will close and reopen the file when it receives SIGUSR2. This
86allows the log file to be rotated without stopping dnsmasq.
f2621c7f
SK
87.TP
88.B --log-async[=<lines>]
89Enable asynchronous logging and optionally set the limit on the
90number of lines
91which will be queued by dnsmasq when writing to the syslog is slow.
92Dnsmasq can log asynchronously: this
93allows it to continue functioning without being blocked by syslog, and
94allows syslog to use dnsmasq for DNS queries without risking deadlock.
95If the queue of log-lines becomes full, dnsmasq will log the
96overflow, and the number of messages lost. The default queue length is
975, a sane value would be 5-25, and a maximum limit of 100 is imposed.
849a8357 98.TP
9e4abcb5
SK
99.B \-x, --pid-file=<path>
100Specify an alternate path for dnsmasq to record its process-id in. Normally /var/run/dnsmasq.pid.
101.TP
102.B \-u, --user=<username>
103Specify the userid to which dnsmasq will change after startup. Dnsmasq must normally be started as root, but it will drop root
b8187c80 104privileges after startup by changing id to another user. Normally this user is "nobody" but that
9e4abcb5
SK
105can be over-ridden with this switch.
106.TP
107.B \-g, --group=<groupname>
108Specify the group which dnsmasq will run
109as. The defaults to "dip", if available, to facilitate access to
110/etc/ppp/resolv.conf which is not normally world readable.
111.TP
112.B \-v, --version
113Print the version number.
114.TP
115.B \-p, --port=<port>
824af85b
SK
116Listen on <port> instead of the standard DNS port (53). Setting this
117to zero completely disables DNS function, leaving only DHCP and/or TFTP.
9e4abcb5 118.TP
feba5c1d
SK
119.B \-P, --edns-packet-max=<size>
120Specify the largest EDNS.0 UDP packet which is supported by the DNS
121forwarder. Defaults to 1280, which is the RFC2671-recommended maximum
122for ethernet.
123.TP
9e4abcb5 124.B \-Q, --query-port=<query_port>
1a6bca81
SK
125Send outbound DNS queries from, and listen for their replies on, the
126specific UDP port <query_port> instead of using random ports. NOTE
127that using this option will make dnsmasq less secure against DNS
128spoofing attacks but it may be faster and use less resources. Setting this option
129to zero makes dnsmasq use a single port allocated to it by the
130OS: this was the default behaviour in versions prior to 2.43.
131.TP
132.B --min-port=<port>
133Do not use ports less than that given as source for outbound DNS
134queries. Dnsmasq picks random ports as source for outbound queries:
135when this option is given, the ports used will always to larger
136than that specified. Useful for systems behind firewalls.
9e4abcb5
SK
137.TP
138.B \-i, --interface=<interface name>
feba5c1d
SK
139Listen only on the specified interface(s). Dnsmasq automatically adds
140the loopback (local) interface to the list of interfaces to use when
141the
142.B \--interface
143option is used. If no
144.B \--interface
9e4abcb5 145or
feba5c1d
SK
146.B \--listen-address
147options are given dnsmasq listens on all available interfaces except any
148given in
149.B \--except-interface
309331f5 150options. IP alias interfaces (eg "eth1:0") cannot be used with
8a911ccc
SK
151.B --interface
152or
153.B --except-interface
309331f5 154options, use --listen-address instead.
9e4abcb5
SK
155.TP
156.B \-I, --except-interface=<interface name>
feba5c1d
SK
157Do not listen on the specified interface. Note that the order of
158.B \--listen-address
159.B --interface
160and
161.B --except-interface
162options does not matter and that
163.B --except-interface
164options always override the others.
9e4abcb5 165.TP
3d8df260 166.B \-2, --no-dhcp-interface=<interface name>
832af0ba 167Do not provide DHCP or TFTP on the specified interface, but do provide DNS service.
3d8df260 168.TP
44a2a316 169.B \-a, --listen-address=<ipaddr>
feba5c1d
SK
170Listen on the given IP address(es). Both
171.B \--interface
172and
173.B \--listen-address
174options may be given, in which case the set of both interfaces and
175addresses is used. Note that if no
176.B \--interface
177option is given, but
178.B \--listen-address
179is, dnsmasq will not automatically listen on the loopback
180interface. To achieve this, its IP address, 127.0.0.1, must be
181explicitly given as a
182.B \--listen-address
183option.
9e4abcb5 184.TP
44a2a316
SK
185.B \-z, --bind-interfaces
186On systems which support it, dnsmasq binds the wildcard address,
187even when it is listening on only some interfaces. It then discards
188requests that it shouldn't reply to. This has the advantage of
189working even when interfaces come and go and change address. This
190option forces dnsmasq to really bind only the interfaces it is
191listening on. About the only time when this is useful is when
f6b7dc47 192running another nameserver (or another instance of dnsmasq) on the
309331f5 193same machine. Setting this option also enables multiple instances of
f6b7dc47
SK
194dnsmasq which provide DHCP service to run in the same machine.
195.TP
196.B \-y, --localise-queries
197Return answers to DNS queries from /etc/hosts which depend on the interface over which the query was
b8187c80 198received. If a name in /etc/hosts has more than one address associated with
f6b7dc47
SK
199it, and at least one of those addresses is on the same subnet as the
200interface to which the query was sent, then return only the
201address(es) on that subnet. This allows for a server to have multiple
202addresses in /etc/hosts corresponding to each of its interfaces, and
203hosts will get the correct address based on which network they are
204attached to. Currently this facility is limited to IPv4.
44a2a316 205.TP
9e4abcb5
SK
206.B \-b, --bogus-priv
207Bogus private reverse lookups. All reverse lookups for private IP ranges (ie 192.168.x.x, etc)
feba5c1d
SK
208which are not found in /etc/hosts or the DHCP leases file are answered
209with "no such domain" rather than being forwarded upstream.
9e4abcb5 210.TP
1cff166d
SK
211.B \-V, --alias=<old-ip>,<new-ip>[,<mask>]
212Modify IPv4 addresses returned from upstream nameservers; old-ip is
213replaced by new-ip. If the optional mask is given then any address
214which matches the masked old-ip will be re-written. So, for instance
215.B --alias=1.2.3.0,6.7.8.0,255.255.255.0
216will map 1.2.3.56 to 6.7.8.56 and 1.2.3.67 to 6.7.8.67. This is what
217Cisco PIX routers call "DNS doctoring".
218.TP
9e4abcb5
SK
219.B \-B, --bogus-nxdomain=<ipaddr>
220Transform replies which contain the IP address given into "No such
221domain" replies. This is intended to counteract a devious move made by
b8187c80 222Verisign in September 2003 when they started returning the address of
9e4abcb5
SK
223an advertising web page in response to queries for unregistered names,
224instead of the correct NXDOMAIN response. This option tells dnsmasq to
225fake the correct response when it sees this behaviour. As at Sept 2003
b8187c80 226the IP address being returned by Verisign is 64.94.110.11
9e4abcb5
SK
227.TP
228.B \-f, --filterwin2k
229Later versions of windows make periodic DNS requests which don't get sensible answers from
230the public DNS and can cause problems by triggering dial-on-demand links. This flag turns on an option
231to filter such requests. The requests blocked are for records of types SOA and SRV, and type ANY where the
232requested name has underscores, to catch LDAP requests.
233.TP
234.B \-r, --resolv-file=<file>
235Read the IP addresses of the upstream nameservers from <file>, instead of
236/etc/resolv.conf. For the format of this file see
237.BR resolv.conf (5)
238the only lines relevant to dnsmasq are nameserver ones. Dnsmasq can
239be told to poll more than one resolv.conf file, the first file name specified
240overrides the default, subsequent ones add to the list. This is only
241allowed when polling; the file with the currently latest modification
242time is the one used.
243.TP
244.B \-R, --no-resolv
245Don't read /etc/resolv.conf. Get upstream servers only from the command
b49644f3 246line or the dnsmasq configuration file.
9e4abcb5 247.TP
3d8df260
SK
248.B \-1, --enable-dbus
249Allow dnsmasq configuration to be updated via DBus method calls. The
250configuration which can be changed is upstream DNS servers (and
b8187c80 251corresponding domains) and cache clear. Requires that dnsmasq has
3d8df260
SK
252been built with DBus support.
253.TP
9e4abcb5
SK
254.B \-o, --strict-order
255By default, dnsmasq will send queries to any of the upstream servers
824af85b 256it knows about and tries to favour servers that are known to
9e4abcb5
SK
257be up. Setting this flag forces dnsmasq to try each query with each
258server strictly in the order they appear in /etc/resolv.conf
259.TP
824af85b
SK
260.B --all-servers
261By default, when dnsmasq has more than one upstream server available,
262it will send queries to just one server. Setting this flag forces
263dnsmasq to send all queries to all available servers. The reply from
264the server which answers first will be returned to the original requestor.
265.TP
266.B --stop-dns-rebind
267Reject (and log) addresses from upstream nameservers which are in the
268private IP ranges. This blocks an attack where a browser behind a
269firewall is used to probe machines on the local network.
270.TP
9e4abcb5
SK
271.B \-n, --no-poll
272Don't poll /etc/resolv.conf for changes.
273.TP
1697269c
SK
274.B --clear-on-reload
275Whenever /etc/resolv.conf is re-read, clear the DNS cache.
276This is useful when new nameservers may have different
277data than that held in cache.
278.TP
9e4abcb5
SK
279.B \-D, --domain-needed
280Tells dnsmasq to never forward queries for plain names, without dots
3d8df260 281or domain parts, to upstream nameservers. If the name is not known
9e4abcb5
SK
282from /etc/hosts or DHCP then a "not found" answer is returned.
283.TP
824af85b 284.B \-S, --local, --server=[/[<domain>]/[domain/]][<ipaddr>[#<port>][@<source-ip>|<interface>[#<port>]]
5aabfc78 285Specify IP address of upstream servers directly. Setting this flag does
9e4abcb5
SK
286not suppress reading of /etc/resolv.conf, use -R to do that. If one or
287more
288optional domains are given, that server is used only for those domains
289and they are queried only using the specified server. This is
290intended for private nameservers: if you have a nameserver on your
291network which deals with names of the form
292xxx.internal.thekelleys.org.uk at 192.168.1.1 then giving the flag
b8187c80 293.B -S /internal.thekelleys.org.uk/192.168.1.1
9e4abcb5
SK
294will send all queries for
295internal machines to that nameserver, everything else will go to the
296servers in /etc/resolv.conf. An empty domain specification,
297.B //
298has the special meaning of "unqualified names only" ie names without any
299dots in them. A non-standard port may be specified as
300part of the IP
301address using a # character.
302More than one -S flag is allowed, with
303repeated domain or ipaddr parts as required.
304
305Also permitted is a -S
306flag which gives a domain but no IP address; this tells dnsmasq that
307a domain is local and it may answer queries from /etc/hosts or DHCP
308but should never forward queries on that domain to any upstream
309servers.
310.B local
311is a synonym for
312.B server
313to make configuration files clearer in this case.
314
824af85b
SK
315The optional string after the @ character tells
316dnsmasq how to set the source of the queries to this
317nameserver. It should be an ip-address, which should belong to the machine on which
9e4abcb5 318dnsmasq is running otherwise this server line will be logged and then
824af85b
SK
319ignored, or an interface name. If an interface name is given, then
320queries to the server will be forced via that interface; if an
321ip-address is given then the source address of the queries will be set
322to that address.
323The query-port flag is ignored for any servers which have a
9e4abcb5 324source address specified but the port may be specified directly as
824af85b
SK
325part of the source address. Forcing queries to an interface is not
326implemented on all platforms supported by dnsmasq.
9e4abcb5
SK
327.TP
328.B \-A, --address=/<domain>/[domain/]<ipaddr>
329Specify an IP address to return for any host in the given domains.
330Queries in the domains are never forwarded and always replied to
331with the specified IP address which may be IPv4 or IPv6. To give
332both IPv4 and IPv6 addresses for a domain, use repeated -A flags.
333Note that /etc/hosts and DHCP leases override this for individual
334names. A common use of this is to redirect the entire doubleclick.net
a222641c
SK
335domain to some friendly local web server to avoid banner ads. The
336domain specification works in the same was as for --server, with the
337additional facility that /#/ matches any domain. Thus
338--address=/#/1.2.3.4 will always return 1.2.3.4 for any query not
339answered from /etc/hosts or DHCP and not sent to an upstream
340nameserver by a more specific --server directive.
9e4abcb5 341.TP
f6b7dc47 342.B \-m, --mx-host=<mx name>[[,<hostname>],<preference>]
de37951c
SK
343Return an MX record named <mx name> pointing to the given hostname (if
344given), or
345the host specified in the --mx-target switch
9e4abcb5 346or, if that switch is not given, the host on which dnsmasq
f6b7dc47
SK
347is running. The default is useful for directing mail from systems on a LAN
348to a central server. The preference value is optional, and defaults to
3491 if not given. More than one MX record may be given for a host.
9e4abcb5
SK
350.TP
351.B \-t, --mx-target=<hostname>
f6b7dc47
SK
352Specify the default target for the MX record returned by dnsmasq. See
353--mx-host. If --mx-target is given, but not --mx-host, then dnsmasq
354returns a MX record containing the MX target for MX queries on the
355hostname of the machine on which dnsmasq is running.
9e4abcb5
SK
356.TP
357.B \-e, --selfmx
358Return an MX record pointing to itself for each local
359machine. Local machines are those in /etc/hosts or with DHCP leases.
360.TP
361.B \-L, --localmx
362Return an MX record pointing to the host given by mx-target (or the
363machine on which dnsmasq is running) for each
364local machine. Local machines are those in /etc/hosts or with DHCP
365leases.
366.TP
f6b7dc47
SK
367.B \-W, --srv-host=<_service>.<_prot>.[<domain>],[<target>[,<port>[,<priority>[,<weight>]]]]
368Return a SRV DNS record. See RFC2782 for details. If not supplied, the
369domain defaults to that given by
370.B --domain.
371The default for the target domain is empty, and the default for port
372is one and the defaults for
373weight and priority are zero. Be careful if transposing data from BIND
374zone files: the port, weight and priority numbers are in a different
375order. More than one SRV record for a given service/domain is allowed,
3d8df260 376all that match are returned.
f6b7dc47 377.TP
0a852541
SK
378.B \-Y, --txt-record=<name>[[,<text>],<text>]
379Return a TXT DNS record. The value of TXT record is a set of strings,
380so any number may be included, split by commas.
381.TP
832af0ba
SK
382.B --ptr-record=<name>[,<target>]
383Return a PTR DNS record.
384.TP
1a6bca81
SK
385.B --naptr-record=<name>,<order>,<preference>,<flags>,<service>,<regexp>[,<replacement>]
386Return an NAPTR DNS record, as specified in RFC3403.
387.TP
9009d746
SK
388.B --cname=<cname>,<target>
389Return a CNAME record which indicates that <cname> is really
390<target>. There are significant limitations on the target; it must be a
391DNS name which is known to dnsmasq from /etc/hosts (or additional
392hosts files) or from DHCP. If the target does not satisfy this
393criteria, the whole cname is ignored. The cname must be unique, but it
394is permissable to have more than one cname pointing to the same target.
395.TP
f2621c7f
SK
396.B --interface-name=<name>,<interface>
397Return a DNS record associating the name with the primary address on
398the given interface. This flag specifies an A record for the given
399name in the same way as an /etc/hosts line, except that the address is
400not constant, but taken from the given interface. If the interface is
9e038946 401down, not configured or non-existent, an empty record is returned. The
f2621c7f
SK
402matching PTR record is also created, mapping the interface address to
403the name. More than one name may be associated with an interface
404address by repeating the flag; in that case the first instance is used
405for the reverse address-to-name mapping.
406.TP
9e4abcb5
SK
407.B \-c, --cache-size=<cachesize>
408Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching.
409.TP
410.B \-N, --no-negcache
411Disable negative caching. Negative caching allows dnsmasq to remember
412"no such domain" answers from upstream nameservers and answer
5aabfc78 413identical queries without forwarding them again.
9e4abcb5 414.TP
1697269c
SK
415.B \-0, --dns-forward-max=<queries>
416Set the maximum number of concurrent DNS queries. The default value is
417150, which should be fine for most setups. The only known situation
418where this needs to be increased is when using web-server log file
419resolvers, which can generate large numbers of concurrent queries.
208b65c5 420.TP
0a852541 421.B \-F, --dhcp-range=[[net:]network-id,]<start-addr>,<end-addr>[[,<netmask>],<broadcast>][,<default lease time>]
9e4abcb5 422Enable the DHCP server. Addresses will be given out from the range
44a2a316
SK
423<start-addr> to <end-addr> and from statically defined addresses given
424in
425.B dhcp-host
426options. If the lease time is given, then leases
b8187c80 427will be given for that length of time. The lease time is in seconds,
824af85b 428or minutes (eg 45m) or hours (eg 1h) or the literal "infinite". The
9e038946 429minimum lease time is two minutes. This
9e4abcb5 430option may be repeated, with different addresses, to enable DHCP
44a2a316
SK
431service to more than one network. For directly connected networks (ie,
432networks on which the machine running dnsmasq has an interface) the
433netmask is optional. It is, however, required for networks which
b8187c80 434receive DHCP service via a relay agent. The broadcast address is
44a2a316
SK
435always optional. On some broken systems, dnsmasq can listen on only
436one interface when using DHCP, and the name of that interface must be
437given using the
438.B interface
4011c4e0 439option. This limitation currently affects OpenBSD before version 4.0. It is always
f6b7dc47 440allowed to have more than one dhcp-range in a single subnet. The optional
44a2a316 441network-id is a alphanumeric label which marks this network so that
0a852541
SK
442dhcp options may be specified on a per-network basis.
443When it is prefixed with 'net:' then its meaning changes from setting
cdeda28f 444a tag to matching it. Only one tag may be set, but more than one tag may be matched.
0a852541 445The end address may be replaced by the keyword
33820b7e
SK
446.B static
447which tells dnsmasq to enable DHCP for the network specified, but not
448to dynamically allocate IP addresses. Only hosts which have static
449addresses given via
450.B dhcp-host
451or from /etc/ethers will be served.
9e4abcb5 452.TP
832af0ba 453.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,net:<netid>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
9e4abcb5
SK
454Specify per host parameters for the DHCP server. This allows a machine
455with a particular hardware address to be always allocated the same
456hostname, IP address and lease time. A hostname specified like this
457overrides any supplied by the DHCP client on the machine. It is also
458allowable to ommit the hardware address and include the hostname, in
459which case the IP address and lease times will apply to any machine
460claiming that name. For example
461.B --dhcp-host=00:20:e0:3b:13:af,wap,infinite
462tells dnsmasq to give
cdeda28f 463the machine with hardware address 00:20:e0:3b:13:af the name wap, and
9e4abcb5
SK
464an infinite DHCP lease.
465.B --dhcp-host=lap,192.168.0.199
466tells
467dnsmasq to always allocate the machine lap the IP address
1ab84e2f 468192.168.0.199. Addresses allocated like this are not constrained to be
9e4abcb5
SK
469in the range given by the --dhcp-range option, but they must be on the
470network being served by the DHCP server. It is allowed to use client identifiers rather than
471hardware addresses to identify hosts by prefixing with 'id:'. Thus:
472.B --dhcp-host=id:01:02:03:04,.....
473refers to the host with client identifier 01:02:03:04. It is also
474allowed to specify the client ID as text, like this:
a84fa1d0 475.B --dhcp-host=id:clientidastext,.....
9009d746 476
a84fa1d0
SK
477The special option id:* means "ignore any client-id
478and use MAC addresses only." This is useful when a client presents a client-id sometimes
479but not others.
9009d746 480
1ab84e2f
SK
481If a name appears in /etc/hosts, the associated address can be
482allocated to a DHCP lease, but only if a
483.B --dhcp-host
33820b7e
SK
484option specifying the name also exists. The special keyword "ignore"
485tells dnsmasq to never offer a DHCP lease to a machine. The machine
486can be specified by hardware address, client ID or hostname, for
487instance
488.B --dhcp-host=00:20:e0:3b:13:af,ignore
489This is
490useful when there is another DHCP server on the network which should
9009d746
SK
491be used by some machines.
492
493The net:<network-id> sets the network-id tag
494whenever this dhcp-host directive is in use. This can be used to
5aabfc78
SK
495selectively send DHCP options just for this host. When a host matches any
496dhcp-host directive (or one implied by /etc/ethers) then the special
497network-id tag "known" is set. This allows dnsmasq to be configured to
498ignore requests from unknown machines using
499.B --dhcp-ignore=#known
0a852541
SK
500Ethernet addresses (but not client-ids) may have
501wildcard bytes, so for example
502.B --dhcp-host=00:20:e0:3b:13:*,ignore
cdeda28f 503will cause dnsmasq to ignore a range of hardware addresses. Note that
0a852541 504the "*" will need to be escaped or quoted on a command line, but not
9009d746
SK
505in the configuration file.
506
507Hardware addresses normally match any
cdeda28f
SK
508network (ARP) type, but it is possible to restrict them to a single
509ARP type by preceding them with the ARP-type (in HEX) and "-". so
510.B --dhcp-host=06-00:20:e0:3b:13:af,1.2.3.4
511will only match a
512Token-Ring hardware address, since the ARP-address type for token ring
9009d746
SK
513is 6.
514
515As a special case, it is possible to include more than one
516hardware address. This allows an IP address to be associated with
517multiple hardware addresses, and gives dnsmasq permission to abandon a
518DHCP lease to one of the hardware addresses when another one asks for
519a lease. Beware that this is a dangerous thing to do, it will only
520work reliably if only one of the hardware addresses is active at any
521time and there is no way for dnsmasq to enforce this. It is, however
522useful, for instance to allocate a stable IP address to a laptop which
523has both wired and wireless interfaces.
5aabfc78
SK
524.TP
525.B --dhcp-hostsfile=<file>
526Read DHCP host information from the specified file. The file contains
527information about one host per line. The format of a line is the same
528as text to the right of '=' in --dhcp-host. The advantage of storing DHCP host information
529in this file is that it can be changed without re-starting dnsmasq:
530the file will be re-read when dnsmasq receives SIGHUP.
824af85b
SK
531.TP
532.B --dhcp-optsfile=<file>
533Read DHCP option information from the specified file. The advantage of
534using this option is the same as for --dhcp-hostsfile: the
535dhcp-optsfile will be re-read when dnsmasq receives SIGHUP.
44a2a316
SK
536.TP
537.B \-Z, --read-ethers
538Read /etc/ethers for information about hosts for the DHCP server. The
539format of /etc/ethers is a hardware address, followed by either a
540hostname or dotted-quad IP address. When read by dnsmasq these lines
541have exactly the same effect as
542.B --dhcp-host
5aabfc78
SK
543options containing the same information. /etc/ethers is re-read when
544dnsmasq receives SIGHUP.
9e4abcb5 545.TP
f2621c7f 546.B \-O, --dhcp-option=[<network-id>,[<network-id>,]][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]]
b8187c80 547Specify different or extra options to DHCP clients. By default,
9e4abcb5
SK
548dnsmasq sends some standard options to DHCP clients, the netmask and
549broadcast address are set to the same as the host running dnsmasq, and
550the DNS server and default route are set to the address of the machine
551running dnsmasq. If the domain name option has been set, that is sent.
f2621c7f
SK
552This configuration allows these defaults to be overridden,
553or other options specified. The option, to be sent may be given as a
554decimal number or as "option:<option-name>" The option numbers are
555specified in RFC2132 and subsequent RFCs. The set of option-names
556known by dnsmasq can be discovered by running "dnsmasq --help dhcp".
557For example, to set the default route option to
9e4abcb5 558192.168.4.4, do
f2621c7f
SK
559.B --dhcp-option=3,192.168.4.4
560or
561.B --dhcp-option = option:router, 192.168.4.4
9e4abcb5 562and to set the time-server address to 192.168.0.4, do
f2621c7f
SK
563.B --dhcp-option = 42,192.168.0.4
564or
565.B --dhcp-option = option:ntp-server, 192.168.0.4
1ab84e2f 566The special address 0.0.0.0 is taken to mean "the address of the
f6b7dc47
SK
567machine running dnsmasq". Data types allowed are comma separated
568dotted-quad IP addresses, a decimal number, colon-separated hex digits
26128d27
SK
569and a text string. If the optional network-ids are given then
570this option is only sent when all the network-ids are matched.
91dccd09 571
cdeda28f 572Special processing is done on a text argument for option 119, to
832af0ba
SK
573conform with RFC 3397. Text or dotted-quad IP addresses as arguments
574to option 120 are handled as per RFC 3361. Dotted-quad IP addresses
575which are followed by a slash and then a netmask size are encoded as
576described in RFC 3442.
cdeda28f 577
9e4abcb5 578Be careful: no checking is done that the correct type of data for the
26128d27 579option number is sent, it is quite possible to
9e4abcb5 580persuade dnsmasq to generate illegal DHCP packets with injudicious use
91dccd09
SK
581of this flag. When the value is a decimal number, dnsmasq must determine how
582large the data item is. It does this by examining the option number and/or the
b8187c80 583value, but can be overridden by appending a single letter flag as follows:
91dccd09 584b = one byte, s = two bytes, i = four bytes. This is mainly useful with
3d8df260
SK
585encapsulated vendor class options (see below) where dnsmasq cannot
586determine data size from the option number. Option data which
587consists solely of periods and digits will be interpreted by dnsmasq
588as an IP address, and inserted into an option as such. To force a
589literal string, use quotes. For instance when using option 66 to send
590a literal IP address as TFTP server name, it is necessary to do
591.B --dhcp-option=66,"1.2.3.4"
91dccd09
SK
592
593Encapsulated Vendor-class options may also be specified using
594--dhcp-option: for instance
1b7ecd11
SK
595.B --dhcp-option=vendor:PXEClient,1,0.0.0.0
596sends the encapsulated vendor
597class-specific option "mftp-address=0.0.0.0" to any client whose
598vendor-class matches "PXEClient". The vendor-class matching is
6b01084f
SK
599substring based (see --dhcp-vendorclass for details). If a
600vendor-class option (number 60) is sent by dnsmasq, then that is used
601for selecting encapsulated options in preference to any sent by the
602client. It is
1b7ecd11
SK
603possible to omit the vendorclass completely;
604.B --dhcp-option=vendor:,1,0.0.0.0
605in which case the encapsulated option is always sent.
606The address 0.0.0.0 is not treated specially in
91dccd09 607encapsulated vendor class options.
9e4abcb5 608.TP
6b01084f
SK
609.B --dhcp-option-force=[<network-id>,[<network-id>,]][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]]
610This works in exactly the same way as
f2621c7f
SK
611.B --dhcp-option
612except that the option will always be sent, even if the client does
6b01084f
SK
613not ask for it in the parameter request list. This is sometimes
614needed, for example when sending options to PXELinux.
615.TP
824af85b
SK
616.B --dhcp-no-override
617Disable re-use of the DHCP servername and filename fields as extra
618option space. If it can, dnsmasq moves the boot server and filename
619information (from dhcp-boot) out of their dedicated fields into
620DHCP options. This make extra space available in the DHCP packet for
621options but can, rarely, confuse old or broken clients. This flag
622forces "simple and safe" behaviour to avoid problems in such a case.
623.TP
a84fa1d0 624.B \-U, --dhcp-vendorclass=<network-id>,<vendor-class>
f2621c7f 625Map from a vendor-class string to a network id tag. Most DHCP clients provide a
a222641c 626"vendor class" which represents, in some sense, the type of host. This option
f2621c7f 627maps vendor classes to tags, so that DHCP options may be selectively delivered
a84fa1d0
SK
628to different classes of hosts. For example
629.B dhcp-vendorclass=printers,Hewlett-Packard JetDirect
630will allow options to be set only for HP printers like so:
a222641c
SK
631.B --dhcp-option=printers,3,192.168.4.4
632The vendor-class string is
633substring matched against the vendor-class supplied by the client, to
634allow fuzzy matching.
635.TP
636.B \-j, --dhcp-userclass=<network-id>,<user-class>
f2621c7f 637Map from a user-class string to a network id tag (with substring
a222641c
SK
638matching, like vendor classes). Most DHCP clients provide a
639"user class" which is configurable. This option
f2621c7f 640maps user classes to tags, so that DHCP options may be selectively delivered
a222641c
SK
641to different classes of hosts. It is possible, for instance to use
642this to set a different printer server for hosts in the class
643"accounts" than for hosts in the class "engineering".
a84fa1d0 644.TP
cdeda28f 645.B \-4, --dhcp-mac=<network-id>,<MAC address>
f2621c7f 646Map from a MAC address to a network-id tag. The MAC address may include
cdeda28f
SK
647wildcards. For example
648.B --dhcp-mac=3com,01:34:23:*:*:*
649will set the tag "3com" for any host whose MAC address matches the pattern.
650.TP
f2621c7f
SK
651.B --dhcp-circuitid=<network-id>,<circuit-id>, --dhcp-remoteid=<network-id>,<remote-id>
652Map from RFC3046 relay agent options to network-id tags. This data may
653be provided by DHCP relay agents. The circuit-id or remote-id is
654normally given as colon-separated hex, but is also allowed to be a
655simple string. If an exact match is achieved between the circuit or
656agent ID and one provided by a relay agent, the network-id tag is set.
657.TP
658.B --dhcp-subscrid=<network-id>,<subscriber-id>
824af85b
SK
659Map from RFC3993 subscriber-id relay agent options to network-id tags.
660.TP
661.B --dhcp-match=<network-id>,<option number>
662Set the network-id tag if the client sends a DHCP option of the given
663number. This can be used to identify particular clients which send
664information using private option numbers.
f2621c7f 665.TP
cdeda28f 666.B \-J, --dhcp-ignore=<network-id>[,<network-id>]
26128d27
SK
667When all the given network-ids match the set of network-ids derived
668from the net, host, vendor and user classes, ignore the host and do
669not allocate it a DHCP lease.
670.TP
5aabfc78 671.B --dhcp-ignore-names[=<network-id>[,<network-id>]]
832af0ba
SK
672When all the given network-ids match the set of network-ids derived
673from the net, host, vendor and user classes, ignore any hostname
9e038946 674provided by the host. Note that, unlike dhcp-ignore, it is permissible
832af0ba
SK
675to supply no netid tags, in which case DHCP-client supplied hostnames
676are always ignored, and DHCP hosts are added to the DNS using only
677dhcp-host configuration in dnsmasq and the contents of /etc/hosts and
678/etc/ethers.
679.TP
824af85b
SK
680.B --dhcp-broadcast=<network-id>[,<network-id>]
681When all the given network-ids match the set of network-ids derived
682from the net, host, vendor and user classes, always use broadcast to
683communicate with the host when it is unconfigured. Most DHCP clients which
684need broadcast replies set a flag in their requests so that this
685happens automatically, some old BOOTP clients do not.
686.TP
26128d27 687.B \-M, --dhcp-boot=[net:<network-id>,]<filename>,[<servername>[,<server address>]]
832af0ba
SK
688Set BOOTP options to be returned by the DHCP server. Server name and
689address are optional: if not provided, the name is left empty, and the
690address set to the address of the machine running dnsmasq. If dnsmasq
691is providing a TFTP service (see
692.B --enable-tftp
693) then only the filename is required here to enable network booting.
694If the optional network-id(s) are given,
26128d27
SK
695they must match for this configuration to be sent. Note that
696network-ids are prefixed by "net:" to distinguish them.
9e4abcb5 697.TP
44a2a316
SK
698.B \-X, --dhcp-lease-max=<number>
699Limits dnsmasq to the specified maximum number of DHCP leases. The
700default is 150. This limit is to prevent DoS attacks from hosts which
701create thousands of leases and use lots of memory in the dnsmasq
702process.
703.TP
fd9fa481 704.B \-K, --dhcp-authoritative
f2621c7f 705Should be set when dnsmasq is definitely the only DHCP server on a network.
fd9fa481
SK
706It changes the behaviour from strict RFC compliance so that DHCP requests on
707unknown leases from unknown hosts are not ignored. This allows new hosts
cdeda28f
SK
708to get a lease without a tedious timeout under all circumstances. It also
709allows dnsmasq to rebuild its lease database without each client needing to
9e038946
SK
710reacquire a lease, if the database is lost.
711.TP
712.B --dhcp-alternate-port[=<server port>[,<client port>]]
713Change the ports used for DHCP from the default. If this option is
714given alone, without arguments, it changes the ports used for DHCP
715from 67 and 68 to 1067 and 1068. If a single argument is given, that
716port number is used for the server and the port number plus one used
717for the client. Finally, two port numbers allows arbitrary
718specification of both server and client ports for DHCP.
fd9fa481 719.TP
9009d746 720.B \-3, --bootp-dynamic[=<network-id>[,<network-id>]]
3d8df260
SK
721Enable dynamic allocation of IP addresses to BOOTP clients. Use this
722with care, since each address allocated to a BOOTP client is leased
723forever, and therefore becomes permanently unavailable for re-use by
9009d746
SK
724other hosts. if this is given without tags, then it unconditionally
725enables dynamic allocation. With tags, only when the tags are all
726set. It may be repeated with different tag sets.
3d8df260 727.TP
5e9e0efb
SK
728.B \-5, --no-ping
729By default, the DHCP server will attempt to ensure that an address in
730not in use before allocating it to a host. It does this by sending an
731ICMP echo request (aka "ping") to the address in question. If it gets
732a reply, then the address must already be in use, and another is
733tried. This flag disables this check. Use with caution.
734.TP
f2621c7f
SK
735.B --log-dhcp
736Extra logging for DHCP: log all the options sent to DHCP clients and
737the netid tags used to determine them.
738.TP
9e4abcb5 739.B \-l, --dhcp-leasefile=<path>
33820b7e
SK
740Use the specified file to store DHCP lease information. If this option
741is given but no dhcp-range option is given then dnsmasq version 1
742behaviour is activated. The file given is assumed to be an ISC dhcpd
743lease file and parsed for leases which are then added to the DNS
744system if they have a hostname. This functionality may have been
7cebd20f
SK
745excluded from dnsmasq at compile time, in which case an error will
746occur. In any case note that ISC leasefile integration is a deprecated
747feature. It should not be used in new installations, and will be
748removed in a future release.
208b65c5 749.TP
7cebd20f
SK
750.B \-6 --dhcp-script=<path>
751Whenever a new DHCP lease is created, or an old one destroyed, the
9009d746 752executable specified by this option is run. The arguments to the process
7cebd20f 753are "add", "old" or "del", the MAC
9009d746 754address of the host, the IP address, and the hostname,
7cebd20f
SK
755if known. "add" means a lease has been created, "del" means it has
756been destroyed, "old" is a notification of an existing lease when
208b65c5
SK
757dnsmasq starts or a change to MAC address or hostname of an existing
758lease (also, lease length or expiry and client-id, if leasefile-ro is set).
9009d746
SK
759If the MAC address is from a network type other than ethernet,
760it will have the network type prepended, eg "06-01:23:45:67:89:ab" for
761token ring. The process is run as root (assuming that dnsmasq was originally run as
1697269c 762root) even if dnsmasq is configured to change UID to an unprivileged user.
208b65c5 763The environment is inherited from the invoker of dnsmasq, and if the
1697269c 764host provided a client-id, this is stored in the environment variable
9009d746
SK
765DNSMASQ_CLIENT_ID. If the fully-qualified domain name of the host is
766known, the domain part is stored in DNSMASQ_DOMAIN.
767If the client provides vendor-class or user-class
1697269c 768information, these are provided in DNSMASQ_VENDOR_CLASS and
1b7ecd11 769DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn variables, but only for
4011c4e0
SK
770"add" actions or "old" actions when a host resumes an existing lease,
771since these data are not held in dnsmasq's lease
1697269c 772database. If dnsmasq was compiled with HAVE_BROKEN_RTC, then
208b65c5 773the length of the lease (in seconds) is stored in
1697269c 774DNSMASQ_LEASE_LENGTH, otherwise the time of lease expiry is stored in
5aabfc78
SK
775DNSMASQ_LEASE_EXPIRES. The number of seconds until lease expiry is
776always stored in DNSMASQ_TIME_REMAINING.
777If a lease used to have a hostname, which is
1697269c
SK
778removed, an "old" event is generated with the new state of the lease,
779ie no name, and the former name is provided in the environment
824af85b 780variable DNSMASQ_OLD_HOSTNAME. DNSMASQ_INTERFACE stores the name of
9e038946 781the interface on which the request arrived; this is not set for "old"
824af85b 782actions when dnsmasq restarts.
9e038946 783All file descriptors are
7cebd20f
SK
784closed except stdin, stdout and stderr which are open to /dev/null
785(except in debug mode).
786The script is not invoked concurrently: if subsequent lease
787changes occur, the script is not invoked again until any existing
f2621c7f 788invocation exits. At dnsmasq startup, the script will be invoked for
7cebd20f
SK
789all existing leases as they are read from the lease file. Expired
790leases will be called with "del" and others with "old". <path>
5aabfc78
SK
791must be an absolute pathname, no PATH search occurs. When dnsmasq
792receives a HUP signal, the script will be invoked for existing leases
9e038946
SK
793with an "old " event.
794.TP
795.B --dhcp-scriptuser
796Specify the user as which to run the lease-change script. This defaults to root, but can be changed to another user using this flag.
208b65c5
SK
797.TP
798.B \-9, --leasefile-ro
799Completely suppress use of the lease database file. The file will not
800be created, read, or written. Change the way the lease-change
801script (if one is provided) is called, so that the lease database may
802be maintained in external storage by the script. In addition to the
f2621c7f 803invocations given in
208b65c5
SK
804.B --dhcp-script
805the lease-change script is called once, at dnsmasq startup, with the
806single argument "init". When called like this the script should write
807the saved state of the lease database, in dnsmasq leasefile format, to
808stdout and exit with zero exit code. Setting this
809option also forces the leasechange script to be called on changes
810to the client-id and lease length and expiry time.
9e4abcb5 811.TP
832af0ba
SK
812.B --bridge-interface=<interface>,<alias>[,<alias>]
813Treat DHCP request packets arriving at any of the <alias> interfaces
814as if they had arrived at <interface>. This option is only available
9e038946 815on BSD platforms, and is necessary when using "old style" bridging, since
832af0ba
SK
816packets arrive at tap interfaces which don't have an IP address.
817.TP
9009d746
SK
818.B \-s, --domain=<domain>[,<address range>]
819Specifies DNS domains for the DHCP server. Domains may be be given
820unconditionally (without the IP range) or for limited IP ranges. This has two effects;
9e4abcb5
SK
821firstly it causes the DHCP server to return the domain to any hosts
822which request it, and secondly it sets the domain which it is legal
1b7ecd11
SK
823for DHCP-configured hosts to claim. The intention is to constrain
824hostnames so that an untrusted host on the LAN cannot advertise
825its name via dhcp as e.g. "microsoft.com" and capture traffic not
826meant for it. If no domain suffix is specified, then any DHCP
827hostname with a domain part (ie with a period) will be disallowed
828and logged. If suffix is specified, then hostnames with a domain
829part are allowed, provided the domain part matches the suffix. In
830addition, when a suffix is set then hostnames without a domain
831part have the suffix added as an optional domain part. Eg on my network I can set
3d8df260 832.B --domain=thekelleys.org.uk
9e4abcb5
SK
833and have a machine whose DHCP hostname is "laptop". The IP address for that machine is available from
834.B dnsmasq
de37951c
SK
835both as "laptop" and "laptop.thekelleys.org.uk". If the domain is
836given as "#" then the domain is read from the first "search" directive
9009d746
SK
837in /etc/resolv.conf (or equivalent). The address range can be of the form
838<ip address>,<ip address> or <ip address>/<netmask> or just a single
839<ip address>. See
840.B --dhcp-fqdn
841which can change the behaviour of dnsmasq with domains.
842.TP
843.B --dhcp-fqdn
844In the default mode, dnsmasq inserts the unqualified names of
845DHCP clients into the DNS. For this reason, the names must be unique,
846even if two clients which have the same name are in different
847domains. If a second DHCP client appears which has the same name as an
848existing client, the name is transfered to the new client. If
849.B --dhcp-fqdn
850is set, this behaviour changes: the unqualified name is no longer
851put in the DNS, only the qualified name. Two DHCP clients with the
852same name may both keep the name, provided that the domain part is
853different (ie the fully qualified names differ.) To ensure that all
854names have a domain part, there must be at least
855.B --domain
856without an address specified when
857.B --dhcp-fqdn
858is set.
9e4abcb5 859.TP
832af0ba
SK
860.B --enable-tftp
861Enable the TFTP server function. This is deliberately limited to that
9e038946
SK
862needed to net-boot a client. Only reading is allowed; the tsize and
863blksize extensions are supported (tsize is only supported in octet mode).
832af0ba
SK
864.TP
865.B --tftp-root=<directory>
866Look for files to transfer using TFTP relative to the given
867directory. When this is set, TFTP paths which include ".." are
868rejected, to stop clients getting outside the specified root.
f2621c7f
SK
869Absolute paths (starting with /) are allowed, but they must be within
870the tftp-root.
832af0ba 871.TP
5aabfc78
SK
872.B --tftp-unique-root
873Add the IP address of the TFTP client as a path component on the end
874of the TFTP-root (in standard dotted-quad format). Only valid if a
875tftp-root is set and the directory exists. For instance, if tftp-root is "/tftp" and client
8761.2.3.4 requests file "myfile" then the effective path will be
877"/tftp/1.2.3.4/myfile" if /tftp/1.2.3.4 exists or /tftp/myfile otherwise.
878.TP
832af0ba 879.B --tftp-secure
5aabfc78 880Enable TFTP secure mode: without this, any file which is readable by
832af0ba
SK
881the dnsmasq process under normal unix access-control rules is
882available via TFTP. When the --tftp-secure flag is given, only files
883owned by the user running the dnsmasq process are accessible. If
884dnsmasq is being run as root, different rules apply: --tftp-secure
1b7ecd11 885has no effect, but only files which have the world-readable bit set
832af0ba
SK
886are accessible. It is not recommended to run dnsmasq as root with TFTP
887enabled, and certainly not without specifying --tftp-root. Doing so
888can expose any world-readable file on the server to any host on the net.
889.TP
890.B --tftp-max=<connections>
891Set the maximum number of concurrent TFTP connections allowed. This
892defaults to 50. When serving a large number of TFTP connections,
893per-process file descriptor limits may be encountered. Dnsmasq needs
894one file descriptor for each concurrent TFTP connection and one
895file descriptor per unique file (plus a few others). So serving the
896same file simultaneously to n clients will use require about n + 10 file
897descriptors, serving different files simultaneously to n clients will
824af85b
SK
898require about (2*n) + 10 descriptors. If
899.B --tftp-port-range
900is given, that can affect the number of concurrent connections.
6b01084f
SK
901.TP
902.B --tftp-no-blocksize
903Stop the TFTP server from negotiating the "blocksize" option with a
904client. Some buggy clients request this option but then behave badly
905when it is granted.
824af85b
SK
906.TP
907.B --tftp-port-range=<start>,<end>
908A TFTP server listens on a well-known port (69) for connection initiation,
909but it also uses a dynamically-allocated port for each
910connection. Normally these are allocated by the OS, but this option
911specifies a range of ports for use by TFTP transfers. This can be
912useful when TFTP has to traverse a firewall. The start of the range
913cannot be lower than 1025 unless dnsmasq is running as root. The number
914of concurrent TFTP connections is limited by the size of the port range.
832af0ba 915.TP
b8187c80
SK
916.B \-C, --conf-file=<file>
917Specify a different configuration file. The conf-file option is also allowed in
849a8357
SK
918configuration files, to include multiple configuration files.
919.TP
920.B \-7, --conf-dir=<directory>
921Read all the files in the given directory as configuration
922files. Files whose names end in ~ or start with . or start and end
923with # are skipped. This flag may be given on the command
924line or in a configuration file.
9e4abcb5 925.SH CONFIG FILE
3be34541
SK
926At startup, dnsmasq reads
927.I /etc/dnsmasq.conf,
928if it exists. (On
929FreeBSD, the file is
930.I /usr/local/etc/dnsmasq.conf
b8187c80
SK
931) (but see the
932.B \-C
849a8357
SK
933and
934.B \-7
935options.) The format of this
9e4abcb5
SK
936file consists of one option per line, exactly as the long options detailed
937in the OPTIONS section but without the leading "--". Lines starting with # are comments and ignored. For
b49644f3 938options which may only be specified once, the configuration file overrides
b8187c80 939the command line. Quoting is allowed in a config file:
3d8df260 940between " quotes the special meanings of ,:. and # are removed and the
824af85b
SK
941following escapes are allowed: \\\\ \\" \\t \\e \\b \\r and \\n. The later
942corresponding to tab, escape, backspace, return and newline.
9e4abcb5
SK
943.SH NOTES
944When it receives a SIGHUP,
945.B dnsmasq
3be34541 946clears its cache and then re-loads
5aabfc78
SK
947.I /etc/hosts
948and
949.I /etc/ethers
824af85b 950and any file given by --dhcp-hostsfile, --dhcp-optsfile or --addn-hosts.
5aabfc78
SK
951The dhcp lease change script is called for all
952existing DHCP leases. If
9e4abcb5
SK
953.B
954--no-poll
3be34541
SK
955is set SIGHUP also re-reads
956.I /etc/resolv.conf.
957SIGHUP
b49644f3 958does NOT re-read the configuration file.
9e4abcb5
SK
959.PP
960When it receives a SIGUSR1,
961.B dnsmasq
824af85b 962writes statistics to the system log. It writes the cache size,
9e4abcb5
SK
963the number of names which have had to removed from the cache before
964they expired in order to make room for new names and the total number
824af85b
SK
965of names that have been inserted into the cache. For each upstream
966server it gives the number of queries sent, and the number which
967resulted in an error. In
9e4abcb5 968.B --no-daemon
5aabfc78
SK
969mode or when full logging is enabled (-q), a complete dump of the
970contents of the cache is made.
971.PP
972When it receives SIGUSR2 and it is logging direct to a file (see
973.B --log-facility
974)
975.B dnsmasq
976will close and reopen the log file. Note that during this operation,
977dnsmasq will not be running as root. When it first creates the logfile
978dnsmasq changes the ownership of the file to the non-root user it will run
979as. Logrotate should be configured to create a new log file with
9e038946 980the ownership which matches the existing one before sending SIGUSR2.
5aabfc78
SK
981If TCP DNS queries are in progress, the old logfile will remain open in
982child processes which are handling TCP queries and may continue to be
983written. There is a limit of 150 seconds, after which all existing TCP
984processes will have expired: for this reason, it is not wise to
985configure logfile compression for logfiles which have just been
986rotated. Using logrotate, the required options are
987.B create
988and
989.B delaycompress.
990
991
9e4abcb5 992.PP
9e4abcb5
SK
993Dnsmasq is a DNS query forwarder: it it not capable of recursively
994answering arbitrary queries starting from the root servers but
995forwards such queries to a fully recursive upstream DNS server which is
996typically provided by an ISP. By default, dnsmasq reads
3be34541
SK
997.I /etc/resolv.conf
998to discover the IP
9e4abcb5
SK
999addresses of the upstream nameservers it should use, since the
1000information is typically stored there. Unless
1001.B --no-poll
1002is used,
1003.B dnsmasq
3be34541
SK
1004checks the modification time of
1005.I /etc/resolv.conf
1006(or equivalent if
9e4abcb5
SK
1007.B \--resolv-file
1008is used) and re-reads it if it changes. This allows the DNS servers to
1009be set dynamically by PPP or DHCP since both protocols provide the
1010information.
3be34541
SK
1011Absence of
1012.I /etc/resolv.conf
1013is not an error
9e4abcb5 1014since it may not have been created before a PPP connection exists. Dnsmasq
3be34541
SK
1015simply keeps checking in case
1016.I /etc/resolv.conf
1017is created at any
9e4abcb5
SK
1018time. Dnsmasq can be told to parse more than one resolv.conf
1019file. This is useful on a laptop, where both PPP and DHCP may be used:
3be34541
SK
1020dnsmasq can be set to poll both
1021.I /etc/ppp/resolv.conf
1022and
1023.I /etc/dhcpc/resolv.conf
1024and will use the contents of whichever changed
9e4abcb5
SK
1025last, giving automatic switching between DNS servers.
1026.PP
1027Upstream servers may also be specified on the command line or in
b49644f3 1028the configuration file. These server specifications optionally take a
9e4abcb5
SK
1029domain name which tells dnsmasq to use that server only to find names
1030in that particular domain.
1031.PP
1032In order to configure dnsmasq to act as cache for the host on which it is running, put "nameserver 127.0.0.1" in
1033.I /etc/resolv.conf
1034to force local processes to send queries to
1035dnsmasq. Then either specify the upstream servers directly to dnsmasq
1036using
1037.B \--server
1038options or put their addresses real in another file, say
1039.I /etc/resolv.dnsmasq
1040and run dnsmasq with the
1041.B \-r /etc/resolv.dnsmasq
1042option. This second technique allows for dynamic update of the server
1043addresses by PPP or DHCP.
f6b7dc47
SK
1044.PP
1045Addresses in /etc/hosts will "shadow" different addresses for the same
1046names in the upstream DNS, so "mycompany.com 1.2.3.4" in /etc/hosts will ensure that
1047queries for "mycompany.com" always return 1.2.3.4 even if queries in
1048the upstream DNS would otherwise return a different address. There is
1049one exception to this: if the upstream DNS contains a CNAME which
1050points to a shadowed name, then looking up the CNAME through dnsmasq
1051will result in the unshadowed address associated with the target of
1052the CNAME. To work around this, add the CNAME to /etc/hosts so that
1053the CNAME is shadowed too.
1054
3be34541 1055.PP
26128d27
SK
1056The network-id system works as follows: For each DHCP request, dnsmasq
1057collects a set of valid network-id tags, one from the
1058.B dhcp-range
1059used to allocate the address, one from any matching
1060.B dhcp-host
9009d746
SK
1061(and "known" if a dhcp-host matches)
1062the tag "bootp" for BOOTP requests, a tag whose name is the
1063name if the interface on which the request arrived,
26128d27
SK
1064and possibly many from matching vendor classes and user
1065classes sent by the DHCP client. Any
1066.B dhcp-option
1067which has network-id tags will be used in preference to an untagged
1068.B dhcp-option,
1069provided that _all_ the tags match somewhere in the
1070set collected as described above. The prefix '#' on a tag means 'not'
1071so --dhcp=option=#purple,3,1.2.3.4 sends the option when the
1072network-id tag purple is not in the set of valid tags.
1073.PP
f6b7dc47
SK
1074If the network-id in a
1075.B dhcp-range
1076is prefixed with 'net:' then its meaning changes from setting a
1077tag to matching it. Thus if there is more than dhcp-range on a subnet,
1078and one is tagged with a network-id which is set (for instance
1079from a vendorclass option) then hosts which set the netid tag will be
1080allocated addresses in the tagged range.
1081.PP
3be34541
SK
1082The DHCP server in dnsmasq will function as a BOOTP server also,
1083provided that the MAC address and IP address for clients are given,
1084either using
1085.B dhcp-host
1086configurations or in
1087.I /etc/ethers
1088, and a
1089.B dhcp-range
1090configuration option is present to activate the DHCP server
b8187c80
SK
1091on a particular network. (Setting --bootp-dynamic removes the need for
1092static address mappings.) The filename
3be34541
SK
1093parameter in a BOOTP request is matched against netids in
1094.B dhcp-option
6b01084f 1095configurations, as is the tag "bootp", allowing some control over the options returned to
3be34541
SK
1096different classes of hosts.
1097
5aabfc78
SK
1098.SH EXIT CODES
1099.PP
11000 - Dnsmasq successfully forked into the background, or terminated
1101normally if backgrounding is not enabled.
1102.PP
11031 - A problem with configuration was detected.
1104.PP
11052 - A problem with network access occurred (address in use, attempt
1106to use privileged ports without permission).
1107.PP
9e038946 11083 - A problem occurred with a filesystem operation (missing
5aabfc78
SK
1109file/directory, permissions).
1110.PP
11114 - Memory allocation failure.
1112.PP
11135 - Other miscellaneous problem.
1114.PP
111511 or greater - a non zero return code was received from the
1116lease-script process "init" call. The exit code from dnsmasq is the
1117script's exit code with 10 added.
1118
1b7ecd11
SK
1119.SH LIMITS
1120The default values for resource limits in dnsmasq are generally
1121conservative, and appropriate for embedded router type devices with
1122slow processors and limited memory. On more capable hardware, it is
1123possible to increase the limits, and handle many more clients. The
1124following applies to dnsmasq-2.37: earlier versions did not scale as well.
1125
1126.PP
1127Dnsmasq is capable of handling DNS and DHCP for at least a thousand
1128clients. Clearly to do this the value of
f2621c7f 1129.B --dhcp-lease-max
1b7ecd11
SK
1130must be increased,
1131and lease times should not be very short (less than one hour). The
1132value of
1133.B --dns-forward-max
1134can be increased: start with it equal to
1135the number of clients and increase if DNS seems slow. Note that DNS
1136performance depends too on the performance of the upstream
1137nameservers. The size of the DNS cache may be increased: the hard
1138limit is 10000 names and the default (150) is very low. Sending
1139SIGUSR1 to dnsmasq makes it log information which is useful for tuning
1140the cache size. See the
1141.B NOTES
1142section for details.
1143
1144.PP
1145The built-in TFTP server is capable of many simultaneous file
1146transfers: the absolute limit is related to the number of file-handles
1147allowed to a process and the ability of the select() system call to
1148cope with large numbers of file handles. If the limit is set too high
1149using
1150.B --tftp-max
1151it will be scaled down and the actual limit logged at
1152start-up. Note that more transfers are possible when the same file is
1153being sent than when each transfer sends a different file.
1154
1155.PP
1156It is possible to use dnsmasq to block Web advertising by using a list
1157of known banner-ad servers, all resolving to 127.0.0.1 or 0.0.0.0, in
1158.B /etc/hosts
1159or an additional hosts file. The list can be very long,
1160dnsmasq has been tested successfully with one million names. That size
1161file needs a 1GHz processor and about 60Mb of RAM.
1162
9e4abcb5 1163.SH FILES
b49644f3
SK
1164.IR /etc/dnsmasq.conf
1165
1166.IR /usr/local/etc/dnsmasq.conf
9e4abcb5
SK
1167
1168.IR /etc/resolv.conf
1169
1170.IR /etc/hosts
1171
3be34541
SK
1172.IR /etc/ethers
1173
b49644f3
SK
1174.IR /var/lib/misc/dnsmasq.leases
1175
1176.IR /var/db/dnsmasq.leases
9e4abcb5
SK
1177
1178.IR /var/run/dnsmasq.pid
1179.SH SEE ALSO
9e4abcb5
SK
1180.BR hosts (5),
1181.BR resolver (5)
1182.SH AUTHOR
1183This manual page was written by Simon Kelley <simon@thekelleys.org.uk>.
1184
1185