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