blob: 5520e0303ec8880dc22d6b376391c67d3fa29012 [file] [log] [blame]
Simon Kelley9e4abcb2004-01-22 19:47:41 +00001.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
Simon Kelley5aabfc72007-08-29 11:24:47 +01009is a lightweight DNS, TFTP and DHCP server. It is intended to provide
10coupled DNS and DHCP service to a LAN.
Simon Kelley9e4abcb2004-01-22 19:47:41 +000011.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
Simon Kelley3be34542004-09-11 19:12:13 +010018The 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
Simon Kelleyf2621c72007-04-29 19:47:21 +010021send any desired set of DHCP options, including vendor-encapsulated
Simon Kelley1b7ecd12007-02-05 14:57:57 +000022options. It includes a secure, read-only,
23TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP.
Simon Kelley9e4abcb2004-01-22 19:47:41 +000024.PP
Simon Kelley3be34542004-09-11 19:12:13 +010025Dnsmasq
Simon Kelley1b7ecd12007-02-05 14:57:57 +000026supports IPv6 for DNS, but not DHCP.
Simon Kelley9e4abcb2004-01-22 19:47:41 +000027.SH OPTIONS
28Note that in general missing parameters are allowed and switch off
Simon Kelley832af0b2007-01-21 20:01:28 +000029functions, for instance "--pid-file" disables writing a PID file. On
Simon Kelley33820b72004-04-03 21:10:00 +010030BSD, 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.
Simon Kelley9e4abcb2004-01-22 19:47:41 +000033.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
Simon Kelleyfd9fa482004-10-21 20:24:00 +010039only the specified file. This option may be repeated for more than one
40additional hosts file.
Simon Kelley9e4abcb2004-01-22 19:47:41 +000041.TP
Simon Kelley832af0b2007-01-21 20:01:28 +000042.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
Simon Kelley9e4abcb2004-01-22 19:47:41 +000046.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
Simon Kelley824af852008-02-12 20:43:05 +000055.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
Simon Kelley3be34542004-09-11 19:12:13 +010063.B \-k, --keep-in-foreground
64Do not go into the background at startup but otherwise run as
Simon Kelley3d8df262005-08-29 12:19:27 +010065normal. This is intended for use when dnsmasq is run under daemontools
66or launchd.
Simon Kelley3be34542004-09-11 19:12:13 +010067.TP
Simon Kelley9e4abcb2004-01-22 19:47:41 +000068.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
Simon Kelley3be34542004-09-11 19:12:13 +010071SIGUSR1, log to stderr as well as syslog, don't fork new processes
72to handle TCP queries.
Simon Kelley9e4abcb2004-01-22 19:47:41 +000073.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
Simon Kelley849a8352006-06-09 21:02:31 +010077.B \-8, --log-facility=<facility>
78Set the facility to which dnsmasq will send syslog entries, this
Simon Kelleyf2621c72007-04-29 19:47:21 +010079defaults to DAEMON, and to LOCAL0 when debug mode is in operation. If
Simon Kelley9e038942008-05-30 20:06:34 +010080the facility given contains at least one '/' character, it is taken to
Simon Kelleyf2621c72007-04-29 19:47:21 +010081be 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
Simon Kelley5aabfc72007-08-29 11:24:47 +010084running, 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.
Simon Kelleyf2621c72007-04-29 19:47:21 +010087.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.
Simon Kelley849a8352006-06-09 21:02:31 +010098.TP
Simon Kelley9e4abcb2004-01-22 19:47:41 +000099.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
Simon Kelleyb8187c82005-11-26 21:46:27 +0000104privileges after startup by changing id to another user. Normally this user is "nobody" but that
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000105can 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>
Simon Kelley824af852008-02-12 20:43:05 +0000116Listen on <port> instead of the standard DNS port (53). Setting this
117to zero completely disables DNS function, leaving only DHCP and/or TFTP.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000118.TP
Simon Kelleyfeba5c12004-07-27 20:28:58 +0100119.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
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000124.B \-Q, --query-port=<query_port>
Simon Kelley1a6bca82008-07-11 11:11:42 +0100125Send 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.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000137.TP
138.B \-i, --interface=<interface name>
Simon Kelleyfeba5c12004-07-27 20:28:58 +0100139Listen 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
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000145or
Simon Kelleyfeba5c12004-07-27 20:28:58 +0100146.B \--listen-address
147options are given dnsmasq listens on all available interfaces except any
148given in
149.B \--except-interface
Simon Kelley309331f2006-04-22 15:05:01 +0100150options. IP alias interfaces (eg "eth1:0") cannot be used with
Simon Kelley8a911cc2004-03-16 18:35:52 +0000151.B --interface
152or
153.B --except-interface
Simon Kelley309331f2006-04-22 15:05:01 +0100154options, use --listen-address instead.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000155.TP
156.B \-I, --except-interface=<interface name>
Simon Kelleyfeba5c12004-07-27 20:28:58 +0100157Do 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.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000165.TP
Simon Kelley3d8df262005-08-29 12:19:27 +0100166.B \-2, --no-dhcp-interface=<interface name>
Simon Kelley832af0b2007-01-21 20:01:28 +0000167Do not provide DHCP or TFTP on the specified interface, but do provide DNS service.
Simon Kelley3d8df262005-08-29 12:19:27 +0100168.TP
Simon Kelley44a2a312004-03-10 20:04:35 +0000169.B \-a, --listen-address=<ipaddr>
Simon Kelleyfeba5c12004-07-27 20:28:58 +0100170Listen 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.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000184.TP
Simon Kelley44a2a312004-03-10 20:04:35 +0000185.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
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000192running another nameserver (or another instance of dnsmasq) on the
Simon Kelley309331f2006-04-22 15:05:01 +0100193same machine. Setting this option also enables multiple instances of
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000194dnsmasq 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
Simon Kelleyb8187c82005-11-26 21:46:27 +0000198received. If a name in /etc/hosts has more than one address associated with
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000199it, 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.
Simon Kelley44a2a312004-03-10 20:04:35 +0000205.TP
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000206.B \-b, --bogus-priv
207Bogus private reverse lookups. All reverse lookups for private IP ranges (ie 192.168.x.x, etc)
Simon Kelleyfeba5c12004-07-27 20:28:58 +0100208which are not found in /etc/hosts or the DHCP leases file are answered
209with "no such domain" rather than being forwarded upstream.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000210.TP
Simon Kelley1cff1662004-03-12 08:12:58 +0000211.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
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000219.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
Simon Kelleyb8187c82005-11-26 21:46:27 +0000222Verisign in September 2003 when they started returning the address of
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000223an 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
Simon Kelleyb8187c82005-11-26 21:46:27 +0000226the IP address being returned by Verisign is 64.94.110.11
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000227.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
Simon Kelleyb49644f2004-01-30 21:36:24 +0000246line or the dnsmasq configuration file.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000247.TP
Simon Kelley3d8df262005-08-29 12:19:27 +0100248.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
Simon Kelleyb8187c82005-11-26 21:46:27 +0000251corresponding domains) and cache clear. Requires that dnsmasq has
Simon Kelley3d8df262005-08-29 12:19:27 +0100252been built with DBus support.
253.TP
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000254.B \-o, --strict-order
255By default, dnsmasq will send queries to any of the upstream servers
Simon Kelley824af852008-02-12 20:43:05 +0000256it knows about and tries to favour servers that are known to
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000257be 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
Simon Kelley824af852008-02-12 20:43:05 +0000260.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
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000271.B \-n, --no-poll
272Don't poll /etc/resolv.conf for changes.
273.TP
Simon Kelley16972692006-10-16 20:04:18 +0100274.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
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000279.B \-D, --domain-needed
280Tells dnsmasq to never forward queries for plain names, without dots
Simon Kelley3d8df262005-08-29 12:19:27 +0100281or domain parts, to upstream nameservers. If the name is not known
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000282from /etc/hosts or DHCP then a "not found" answer is returned.
283.TP
Simon Kelley824af852008-02-12 20:43:05 +0000284.B \-S, --local, --server=[/[<domain>]/[domain/]][<ipaddr>[#<port>][@<source-ip>|<interface>[#<port>]]
Simon Kelley5aabfc72007-08-29 11:24:47 +0100285Specify IP address of upstream servers directly. Setting this flag does
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000286not 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
Simon Kelleyb8187c82005-11-26 21:46:27 +0000293.B -S /internal.thekelleys.org.uk/192.168.1.1
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000294will 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
Simon Kelley824af852008-02-12 20:43:05 +0000315The 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
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000318dnsmasq is running otherwise this server line will be logged and then
Simon Kelley824af852008-02-12 20:43:05 +0000319ignored, 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
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000324source address specified but the port may be specified directly as
Simon Kelley824af852008-02-12 20:43:05 +0000325part of the source address. Forcing queries to an interface is not
326implemented on all platforms supported by dnsmasq.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000327.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
Simon Kelleya2226412004-05-13 20:27:08 +0100335domain 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.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000341.TP
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000342.B \-m, --mx-host=<mx name>[[,<hostname>],<preference>]
Simon Kelleyde379512004-06-22 20:23:33 +0100343Return an MX record named <mx name> pointing to the given hostname (if
344given), or
345the host specified in the --mx-target switch
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000346or, if that switch is not given, the host on which dnsmasq
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000347is 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.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000350.TP
351.B \-t, --mx-target=<hostname>
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000352Specify 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.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000356.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
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000367.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,
Simon Kelley3d8df262005-08-29 12:19:27 +0100376all that match are returned.
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000377.TP
Simon Kelley0a852542005-03-23 20:28:59 +0000378.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
Simon Kelley832af0b2007-01-21 20:01:28 +0000382.B --ptr-record=<name>[,<target>]
383Return a PTR DNS record.
384.TP
Simon Kelley1a6bca82008-07-11 11:11:42 +0100385.B --naptr-record=<name>,<order>,<preference>,<flags>,<service>,<regexp>[,<replacement>]
386Return an NAPTR DNS record, as specified in RFC3403.
387.TP
Simon Kelleyf2621c72007-04-29 19:47:21 +0100388.B --interface-name=<name>,<interface>
389Return a DNS record associating the name with the primary address on
390the given interface. This flag specifies an A record for the given
391name in the same way as an /etc/hosts line, except that the address is
392not constant, but taken from the given interface. If the interface is
Simon Kelley9e038942008-05-30 20:06:34 +0100393down, not configured or non-existent, an empty record is returned. The
Simon Kelleyf2621c72007-04-29 19:47:21 +0100394matching PTR record is also created, mapping the interface address to
395the name. More than one name may be associated with an interface
396address by repeating the flag; in that case the first instance is used
397for the reverse address-to-name mapping.
398.TP
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000399.B \-c, --cache-size=<cachesize>
400Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching.
401.TP
402.B \-N, --no-negcache
403Disable negative caching. Negative caching allows dnsmasq to remember
404"no such domain" answers from upstream nameservers and answer
Simon Kelley5aabfc72007-08-29 11:24:47 +0100405identical queries without forwarding them again.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000406.TP
Simon Kelley16972692006-10-16 20:04:18 +0100407.B \-0, --dns-forward-max=<queries>
408Set the maximum number of concurrent DNS queries. The default value is
409150, which should be fine for most setups. The only known situation
410where this needs to be increased is when using web-server log file
411resolvers, which can generate large numbers of concurrent queries.
Simon Kelley208b65c2006-08-05 21:41:37 +0100412.TP
Simon Kelley0a852542005-03-23 20:28:59 +0000413.B \-F, --dhcp-range=[[net:]network-id,]<start-addr>,<end-addr>[[,<netmask>],<broadcast>][,<default lease time>]
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000414Enable the DHCP server. Addresses will be given out from the range
Simon Kelley44a2a312004-03-10 20:04:35 +0000415<start-addr> to <end-addr> and from statically defined addresses given
416in
417.B dhcp-host
418options. If the lease time is given, then leases
Simon Kelleyb8187c82005-11-26 21:46:27 +0000419will be given for that length of time. The lease time is in seconds,
Simon Kelley824af852008-02-12 20:43:05 +0000420or minutes (eg 45m) or hours (eg 1h) or the literal "infinite". The
Simon Kelley9e038942008-05-30 20:06:34 +0100421minimum lease time is two minutes. This
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000422option may be repeated, with different addresses, to enable DHCP
Simon Kelley44a2a312004-03-10 20:04:35 +0000423service to more than one network. For directly connected networks (ie,
424networks on which the machine running dnsmasq has an interface) the
425netmask is optional. It is, however, required for networks which
Simon Kelleyb8187c82005-11-26 21:46:27 +0000426receive DHCP service via a relay agent. The broadcast address is
Simon Kelley44a2a312004-03-10 20:04:35 +0000427always optional. On some broken systems, dnsmasq can listen on only
428one interface when using DHCP, and the name of that interface must be
429given using the
430.B interface
Simon Kelley4011c4e2006-10-28 16:26:19 +0100431option. This limitation currently affects OpenBSD before version 4.0. It is always
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000432allowed to have more than one dhcp-range in a single subnet. The optional
Simon Kelley44a2a312004-03-10 20:04:35 +0000433network-id is a alphanumeric label which marks this network so that
Simon Kelley0a852542005-03-23 20:28:59 +0000434dhcp options may be specified on a per-network basis.
435When it is prefixed with 'net:' then its meaning changes from setting
Simon Kelleycdeda282006-03-16 20:16:06 +0000436a tag to matching it. Only one tag may be set, but more than one tag may be matched.
Simon Kelley0a852542005-03-23 20:28:59 +0000437The end address may be replaced by the keyword
Simon Kelley33820b72004-04-03 21:10:00 +0100438.B static
439which tells dnsmasq to enable DHCP for the network specified, but not
440to dynamically allocate IP addresses. Only hosts which have static
441addresses given via
442.B dhcp-host
443or from /etc/ethers will be served.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000444.TP
Simon Kelley832af0b2007-01-21 20:01:28 +0000445.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,net:<netid>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000446Specify per host parameters for the DHCP server. This allows a machine
447with a particular hardware address to be always allocated the same
448hostname, IP address and lease time. A hostname specified like this
449overrides any supplied by the DHCP client on the machine. It is also
450allowable to ommit the hardware address and include the hostname, in
451which case the IP address and lease times will apply to any machine
452claiming that name. For example
453.B --dhcp-host=00:20:e0:3b:13:af,wap,infinite
454tells dnsmasq to give
Simon Kelleycdeda282006-03-16 20:16:06 +0000455the machine with hardware address 00:20:e0:3b:13:af the name wap, and
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000456an infinite DHCP lease.
457.B --dhcp-host=lap,192.168.0.199
458tells
459dnsmasq to always allocate the machine lap the IP address
Simon Kelley1ab84e22004-01-29 16:48:35 +0000460192.168.0.199. Addresses allocated like this are not constrained to be
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000461in the range given by the --dhcp-range option, but they must be on the
462network being served by the DHCP server. It is allowed to use client identifiers rather than
463hardware addresses to identify hosts by prefixing with 'id:'. Thus:
464.B --dhcp-host=id:01:02:03:04,.....
465refers to the host with client identifier 01:02:03:04. It is also
466allowed to specify the client ID as text, like this:
Simon Kelleya84fa1d2004-04-23 22:21:21 +0100467.B --dhcp-host=id:clientidastext,.....
468The special option id:* means "ignore any client-id
469and use MAC addresses only." This is useful when a client presents a client-id sometimes
470but not others.
Simon Kelley1ab84e22004-01-29 16:48:35 +0000471If a name appears in /etc/hosts, the associated address can be
472allocated to a DHCP lease, but only if a
473.B --dhcp-host
Simon Kelley33820b72004-04-03 21:10:00 +0100474option specifying the name also exists. The special keyword "ignore"
475tells dnsmasq to never offer a DHCP lease to a machine. The machine
476can be specified by hardware address, client ID or hostname, for
477instance
478.B --dhcp-host=00:20:e0:3b:13:af,ignore
479This is
480useful when there is another DHCP server on the network which should
Simon Kelley3d8df262005-08-29 12:19:27 +0100481be used by some machines. The net:<network-id> sets the network-id tag
Simon Kelley5aabfc72007-08-29 11:24:47 +0100482whenever this dhcp-host directive is in use.This can be used to
483selectively send DHCP options just for this host. When a host matches any
484dhcp-host directive (or one implied by /etc/ethers) then the special
485network-id tag "known" is set. This allows dnsmasq to be configured to
486ignore requests from unknown machines using
487.B --dhcp-ignore=#known
Simon Kelley0a852542005-03-23 20:28:59 +0000488Ethernet addresses (but not client-ids) may have
489wildcard bytes, so for example
490.B --dhcp-host=00:20:e0:3b:13:*,ignore
Simon Kelleycdeda282006-03-16 20:16:06 +0000491will cause dnsmasq to ignore a range of hardware addresses. Note that
Simon Kelley0a852542005-03-23 20:28:59 +0000492the "*" will need to be escaped or quoted on a command line, but not
Simon Kelleycdeda282006-03-16 20:16:06 +0000493in the configuration file. Hardware addresses normally match any
494network (ARP) type, but it is possible to restrict them to a single
495ARP type by preceding them with the ARP-type (in HEX) and "-". so
496.B --dhcp-host=06-00:20:e0:3b:13:af,1.2.3.4
497will only match a
498Token-Ring hardware address, since the ARP-address type for token ring
499is 6.
Simon Kelley5aabfc72007-08-29 11:24:47 +0100500.TP
501.B --dhcp-hostsfile=<file>
502Read DHCP host information from the specified file. The file contains
503information about one host per line. The format of a line is the same
504as text to the right of '=' in --dhcp-host. The advantage of storing DHCP host information
505in this file is that it can be changed without re-starting dnsmasq:
506the file will be re-read when dnsmasq receives SIGHUP.
Simon Kelley824af852008-02-12 20:43:05 +0000507.TP
508.B --dhcp-optsfile=<file>
509Read DHCP option information from the specified file. The advantage of
510using this option is the same as for --dhcp-hostsfile: the
511dhcp-optsfile will be re-read when dnsmasq receives SIGHUP.
Simon Kelley44a2a312004-03-10 20:04:35 +0000512.TP
513.B \-Z, --read-ethers
514Read /etc/ethers for information about hosts for the DHCP server. The
515format of /etc/ethers is a hardware address, followed by either a
516hostname or dotted-quad IP address. When read by dnsmasq these lines
517have exactly the same effect as
518.B --dhcp-host
Simon Kelley5aabfc72007-08-29 11:24:47 +0100519options containing the same information. /etc/ethers is re-read when
520dnsmasq receives SIGHUP.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000521.TP
Simon Kelleyf2621c72007-04-29 19:47:21 +0100522.B \-O, --dhcp-option=[<network-id>,[<network-id>,]][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]]
Simon Kelleyb8187c82005-11-26 21:46:27 +0000523Specify different or extra options to DHCP clients. By default,
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000524dnsmasq sends some standard options to DHCP clients, the netmask and
525broadcast address are set to the same as the host running dnsmasq, and
526the DNS server and default route are set to the address of the machine
527running dnsmasq. If the domain name option has been set, that is sent.
Simon Kelleyf2621c72007-04-29 19:47:21 +0100528This configuration allows these defaults to be overridden,
529or other options specified. The option, to be sent may be given as a
530decimal number or as "option:<option-name>" The option numbers are
531specified in RFC2132 and subsequent RFCs. The set of option-names
532known by dnsmasq can be discovered by running "dnsmasq --help dhcp".
533For example, to set the default route option to
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000534192.168.4.4, do
Simon Kelleyf2621c72007-04-29 19:47:21 +0100535.B --dhcp-option=3,192.168.4.4
536or
537.B --dhcp-option = option:router, 192.168.4.4
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000538and to set the time-server address to 192.168.0.4, do
Simon Kelleyf2621c72007-04-29 19:47:21 +0100539.B --dhcp-option = 42,192.168.0.4
540or
541.B --dhcp-option = option:ntp-server, 192.168.0.4
Simon Kelley1ab84e22004-01-29 16:48:35 +0000542The special address 0.0.0.0 is taken to mean "the address of the
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000543machine running dnsmasq". Data types allowed are comma separated
544dotted-quad IP addresses, a decimal number, colon-separated hex digits
Simon Kelley26128d22004-11-14 16:43:54 +0000545and a text string. If the optional network-ids are given then
546this option is only sent when all the network-ids are matched.
Simon Kelley91dccd02005-03-31 17:48:32 +0100547
Simon Kelleycdeda282006-03-16 20:16:06 +0000548Special processing is done on a text argument for option 119, to
Simon Kelley832af0b2007-01-21 20:01:28 +0000549conform with RFC 3397. Text or dotted-quad IP addresses as arguments
550to option 120 are handled as per RFC 3361. Dotted-quad IP addresses
551which are followed by a slash and then a netmask size are encoded as
552described in RFC 3442.
Simon Kelleycdeda282006-03-16 20:16:06 +0000553
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000554Be careful: no checking is done that the correct type of data for the
Simon Kelley26128d22004-11-14 16:43:54 +0000555option number is sent, it is quite possible to
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000556persuade dnsmasq to generate illegal DHCP packets with injudicious use
Simon Kelley91dccd02005-03-31 17:48:32 +0100557of this flag. When the value is a decimal number, dnsmasq must determine how
558large the data item is. It does this by examining the option number and/or the
Simon Kelleyb8187c82005-11-26 21:46:27 +0000559value, but can be overridden by appending a single letter flag as follows:
Simon Kelley91dccd02005-03-31 17:48:32 +0100560b = one byte, s = two bytes, i = four bytes. This is mainly useful with
Simon Kelley3d8df262005-08-29 12:19:27 +0100561encapsulated vendor class options (see below) where dnsmasq cannot
562determine data size from the option number. Option data which
563consists solely of periods and digits will be interpreted by dnsmasq
564as an IP address, and inserted into an option as such. To force a
565literal string, use quotes. For instance when using option 66 to send
566a literal IP address as TFTP server name, it is necessary to do
567.B --dhcp-option=66,"1.2.3.4"
Simon Kelley91dccd02005-03-31 17:48:32 +0100568
569Encapsulated Vendor-class options may also be specified using
570--dhcp-option: for instance
Simon Kelley1b7ecd12007-02-05 14:57:57 +0000571.B --dhcp-option=vendor:PXEClient,1,0.0.0.0
572sends the encapsulated vendor
573class-specific option "mftp-address=0.0.0.0" to any client whose
574vendor-class matches "PXEClient". The vendor-class matching is
Simon Kelley6b010842007-02-12 20:32:07 +0000575substring based (see --dhcp-vendorclass for details). If a
576vendor-class option (number 60) is sent by dnsmasq, then that is used
577for selecting encapsulated options in preference to any sent by the
578client. It is
Simon Kelley1b7ecd12007-02-05 14:57:57 +0000579possible to omit the vendorclass completely;
580.B --dhcp-option=vendor:,1,0.0.0.0
581in which case the encapsulated option is always sent.
582The address 0.0.0.0 is not treated specially in
Simon Kelley91dccd02005-03-31 17:48:32 +0100583encapsulated vendor class options.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000584.TP
Simon Kelley6b010842007-02-12 20:32:07 +0000585.B --dhcp-option-force=[<network-id>,[<network-id>,]][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]]
586This works in exactly the same way as
Simon Kelleyf2621c72007-04-29 19:47:21 +0100587.B --dhcp-option
588except that the option will always be sent, even if the client does
Simon Kelley6b010842007-02-12 20:32:07 +0000589not ask for it in the parameter request list. This is sometimes
590needed, for example when sending options to PXELinux.
591.TP
Simon Kelley824af852008-02-12 20:43:05 +0000592.B --dhcp-no-override
593Disable re-use of the DHCP servername and filename fields as extra
594option space. If it can, dnsmasq moves the boot server and filename
595information (from dhcp-boot) out of their dedicated fields into
596DHCP options. This make extra space available in the DHCP packet for
597options but can, rarely, confuse old or broken clients. This flag
598forces "simple and safe" behaviour to avoid problems in such a case.
599.TP
Simon Kelleya84fa1d2004-04-23 22:21:21 +0100600.B \-U, --dhcp-vendorclass=<network-id>,<vendor-class>
Simon Kelleyf2621c72007-04-29 19:47:21 +0100601Map from a vendor-class string to a network id tag. Most DHCP clients provide a
Simon Kelleya2226412004-05-13 20:27:08 +0100602"vendor class" which represents, in some sense, the type of host. This option
Simon Kelleyf2621c72007-04-29 19:47:21 +0100603maps vendor classes to tags, so that DHCP options may be selectively delivered
Simon Kelleya84fa1d2004-04-23 22:21:21 +0100604to different classes of hosts. For example
605.B dhcp-vendorclass=printers,Hewlett-Packard JetDirect
606will allow options to be set only for HP printers like so:
Simon Kelleya2226412004-05-13 20:27:08 +0100607.B --dhcp-option=printers,3,192.168.4.4
608The vendor-class string is
609substring matched against the vendor-class supplied by the client, to
610allow fuzzy matching.
611.TP
612.B \-j, --dhcp-userclass=<network-id>,<user-class>
Simon Kelleyf2621c72007-04-29 19:47:21 +0100613Map from a user-class string to a network id tag (with substring
Simon Kelleya2226412004-05-13 20:27:08 +0100614matching, like vendor classes). Most DHCP clients provide a
615"user class" which is configurable. This option
Simon Kelleyf2621c72007-04-29 19:47:21 +0100616maps user classes to tags, so that DHCP options may be selectively delivered
Simon Kelleya2226412004-05-13 20:27:08 +0100617to different classes of hosts. It is possible, for instance to use
618this to set a different printer server for hosts in the class
619"accounts" than for hosts in the class "engineering".
Simon Kelleya84fa1d2004-04-23 22:21:21 +0100620.TP
Simon Kelleycdeda282006-03-16 20:16:06 +0000621.B \-4, --dhcp-mac=<network-id>,<MAC address>
Simon Kelleyf2621c72007-04-29 19:47:21 +0100622Map from a MAC address to a network-id tag. The MAC address may include
Simon Kelleycdeda282006-03-16 20:16:06 +0000623wildcards. For example
624.B --dhcp-mac=3com,01:34:23:*:*:*
625will set the tag "3com" for any host whose MAC address matches the pattern.
626.TP
Simon Kelleyf2621c72007-04-29 19:47:21 +0100627.B --dhcp-circuitid=<network-id>,<circuit-id>, --dhcp-remoteid=<network-id>,<remote-id>
628Map from RFC3046 relay agent options to network-id tags. This data may
629be provided by DHCP relay agents. The circuit-id or remote-id is
630normally given as colon-separated hex, but is also allowed to be a
631simple string. If an exact match is achieved between the circuit or
632agent ID and one provided by a relay agent, the network-id tag is set.
633.TP
634.B --dhcp-subscrid=<network-id>,<subscriber-id>
Simon Kelley824af852008-02-12 20:43:05 +0000635Map from RFC3993 subscriber-id relay agent options to network-id tags.
636.TP
637.B --dhcp-match=<network-id>,<option number>
638Set the network-id tag if the client sends a DHCP option of the given
639number. This can be used to identify particular clients which send
640information using private option numbers.
Simon Kelleyf2621c72007-04-29 19:47:21 +0100641.TP
Simon Kelleycdeda282006-03-16 20:16:06 +0000642.B \-J, --dhcp-ignore=<network-id>[,<network-id>]
Simon Kelley26128d22004-11-14 16:43:54 +0000643When all the given network-ids match the set of network-ids derived
644from the net, host, vendor and user classes, ignore the host and do
645not allocate it a DHCP lease.
646.TP
Simon Kelley5aabfc72007-08-29 11:24:47 +0100647.B --dhcp-ignore-names[=<network-id>[,<network-id>]]
Simon Kelley832af0b2007-01-21 20:01:28 +0000648When all the given network-ids match the set of network-ids derived
649from the net, host, vendor and user classes, ignore any hostname
Simon Kelley9e038942008-05-30 20:06:34 +0100650provided by the host. Note that, unlike dhcp-ignore, it is permissible
Simon Kelley832af0b2007-01-21 20:01:28 +0000651to supply no netid tags, in which case DHCP-client supplied hostnames
652are always ignored, and DHCP hosts are added to the DNS using only
653dhcp-host configuration in dnsmasq and the contents of /etc/hosts and
654/etc/ethers.
655.TP
Simon Kelley824af852008-02-12 20:43:05 +0000656.B --dhcp-broadcast=<network-id>[,<network-id>]
657When all the given network-ids match the set of network-ids derived
658from the net, host, vendor and user classes, always use broadcast to
659communicate with the host when it is unconfigured. Most DHCP clients which
660need broadcast replies set a flag in their requests so that this
661happens automatically, some old BOOTP clients do not.
662.TP
Simon Kelley26128d22004-11-14 16:43:54 +0000663.B \-M, --dhcp-boot=[net:<network-id>,]<filename>,[<servername>[,<server address>]]
Simon Kelley832af0b2007-01-21 20:01:28 +0000664Set BOOTP options to be returned by the DHCP server. Server name and
665address are optional: if not provided, the name is left empty, and the
666address set to the address of the machine running dnsmasq. If dnsmasq
667is providing a TFTP service (see
668.B --enable-tftp
669) then only the filename is required here to enable network booting.
670If the optional network-id(s) are given,
Simon Kelley26128d22004-11-14 16:43:54 +0000671they must match for this configuration to be sent. Note that
672network-ids are prefixed by "net:" to distinguish them.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000673.TP
Simon Kelley44a2a312004-03-10 20:04:35 +0000674.B \-X, --dhcp-lease-max=<number>
675Limits dnsmasq to the specified maximum number of DHCP leases. The
676default is 150. This limit is to prevent DoS attacks from hosts which
677create thousands of leases and use lots of memory in the dnsmasq
678process.
679.TP
Simon Kelleyfd9fa482004-10-21 20:24:00 +0100680.B \-K, --dhcp-authoritative
Simon Kelleyf2621c72007-04-29 19:47:21 +0100681Should be set when dnsmasq is definitely the only DHCP server on a network.
Simon Kelleyfd9fa482004-10-21 20:24:00 +0100682It changes the behaviour from strict RFC compliance so that DHCP requests on
683unknown leases from unknown hosts are not ignored. This allows new hosts
Simon Kelleycdeda282006-03-16 20:16:06 +0000684to get a lease without a tedious timeout under all circumstances. It also
685allows dnsmasq to rebuild its lease database without each client needing to
Simon Kelley9e038942008-05-30 20:06:34 +0100686reacquire a lease, if the database is lost.
687.TP
688.B --dhcp-alternate-port[=<server port>[,<client port>]]
689Change the ports used for DHCP from the default. If this option is
690given alone, without arguments, it changes the ports used for DHCP
691from 67 and 68 to 1067 and 1068. If a single argument is given, that
692port number is used for the server and the port number plus one used
693for the client. Finally, two port numbers allows arbitrary
694specification of both server and client ports for DHCP.
Simon Kelleyfd9fa482004-10-21 20:24:00 +0100695.TP
Simon Kelley3d8df262005-08-29 12:19:27 +0100696.B \-3, --bootp-dynamic
697Enable dynamic allocation of IP addresses to BOOTP clients. Use this
698with care, since each address allocated to a BOOTP client is leased
699forever, and therefore becomes permanently unavailable for re-use by
700other hosts.
701.TP
Simon Kelley5e9e0ef2006-04-17 14:24:29 +0100702.B \-5, --no-ping
703By default, the DHCP server will attempt to ensure that an address in
704not in use before allocating it to a host. It does this by sending an
705ICMP echo request (aka "ping") to the address in question. If it gets
706a reply, then the address must already be in use, and another is
707tried. This flag disables this check. Use with caution.
708.TP
Simon Kelleyf2621c72007-04-29 19:47:21 +0100709.B --log-dhcp
710Extra logging for DHCP: log all the options sent to DHCP clients and
711the netid tags used to determine them.
712.TP
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000713.B \-l, --dhcp-leasefile=<path>
Simon Kelley33820b72004-04-03 21:10:00 +0100714Use the specified file to store DHCP lease information. If this option
715is given but no dhcp-range option is given then dnsmasq version 1
716behaviour is activated. The file given is assumed to be an ISC dhcpd
717lease file and parsed for leases which are then added to the DNS
718system if they have a hostname. This functionality may have been
Simon Kelley7cebd202006-05-06 14:13:33 +0100719excluded from dnsmasq at compile time, in which case an error will
720occur. In any case note that ISC leasefile integration is a deprecated
721feature. It should not be used in new installations, and will be
722removed in a future release.
Simon Kelley208b65c2006-08-05 21:41:37 +0100723.TP
Simon Kelley7cebd202006-05-06 14:13:33 +0100724.B \-6 --dhcp-script=<path>
725Whenever a new DHCP lease is created, or an old one destroyed, the
Simon Kelley208b65c2006-08-05 21:41:37 +0100726binary specified by this option is run. The arguments to the process
Simon Kelley7cebd202006-05-06 14:13:33 +0100727are "add", "old" or "del", the MAC
728address of the host (or "<null>"), the IP address, and the hostname,
729if known. "add" means a lease has been created, "del" means it has
730been destroyed, "old" is a notification of an existing lease when
Simon Kelley208b65c2006-08-05 21:41:37 +0100731dnsmasq starts or a change to MAC address or hostname of an existing
732lease (also, lease length or expiry and client-id, if leasefile-ro is set).
Simon Kelley16972692006-10-16 20:04:18 +0100733The process is run as root (assuming that dnsmasq was originally run as
734root) even if dnsmasq is configured to change UID to an unprivileged user.
Simon Kelley208b65c2006-08-05 21:41:37 +0100735The environment is inherited from the invoker of dnsmasq, and if the
Simon Kelley16972692006-10-16 20:04:18 +0100736host provided a client-id, this is stored in the environment variable
737DNSMASQ_CLIENT_ID. If the client provides vendor-class or user-class
738information, these are provided in DNSMASQ_VENDOR_CLASS and
Simon Kelley1b7ecd12007-02-05 14:57:57 +0000739DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn variables, but only for
Simon Kelley4011c4e2006-10-28 16:26:19 +0100740"add" actions or "old" actions when a host resumes an existing lease,
741since these data are not held in dnsmasq's lease
Simon Kelley16972692006-10-16 20:04:18 +0100742database. If dnsmasq was compiled with HAVE_BROKEN_RTC, then
Simon Kelley208b65c2006-08-05 21:41:37 +0100743the length of the lease (in seconds) is stored in
Simon Kelley16972692006-10-16 20:04:18 +0100744DNSMASQ_LEASE_LENGTH, otherwise the time of lease expiry is stored in
Simon Kelley5aabfc72007-08-29 11:24:47 +0100745DNSMASQ_LEASE_EXPIRES. The number of seconds until lease expiry is
746always stored in DNSMASQ_TIME_REMAINING.
747If a lease used to have a hostname, which is
Simon Kelley16972692006-10-16 20:04:18 +0100748removed, an "old" event is generated with the new state of the lease,
749ie no name, and the former name is provided in the environment
Simon Kelley824af852008-02-12 20:43:05 +0000750variable DNSMASQ_OLD_HOSTNAME. DNSMASQ_INTERFACE stores the name of
Simon Kelley9e038942008-05-30 20:06:34 +0100751the interface on which the request arrived; this is not set for "old"
Simon Kelley824af852008-02-12 20:43:05 +0000752actions when dnsmasq restarts.
Simon Kelley9e038942008-05-30 20:06:34 +0100753All file descriptors are
Simon Kelley7cebd202006-05-06 14:13:33 +0100754closed except stdin, stdout and stderr which are open to /dev/null
755(except in debug mode).
756The script is not invoked concurrently: if subsequent lease
757changes occur, the script is not invoked again until any existing
Simon Kelleyf2621c72007-04-29 19:47:21 +0100758invocation exits. At dnsmasq startup, the script will be invoked for
Simon Kelley7cebd202006-05-06 14:13:33 +0100759all existing leases as they are read from the lease file. Expired
760leases will be called with "del" and others with "old". <path>
Simon Kelley5aabfc72007-08-29 11:24:47 +0100761must be an absolute pathname, no PATH search occurs. When dnsmasq
762receives a HUP signal, the script will be invoked for existing leases
Simon Kelley9e038942008-05-30 20:06:34 +0100763with an "old " event.
764.TP
765.B --dhcp-scriptuser
766Specify the user as which to run the lease-change script. This defaults to root, but can be changed to another user using this flag.
Simon Kelley208b65c2006-08-05 21:41:37 +0100767.TP
768.B \-9, --leasefile-ro
769Completely suppress use of the lease database file. The file will not
770be created, read, or written. Change the way the lease-change
771script (if one is provided) is called, so that the lease database may
772be maintained in external storage by the script. In addition to the
Simon Kelleyf2621c72007-04-29 19:47:21 +0100773invocations given in
Simon Kelley208b65c2006-08-05 21:41:37 +0100774.B --dhcp-script
775the lease-change script is called once, at dnsmasq startup, with the
776single argument "init". When called like this the script should write
777the saved state of the lease database, in dnsmasq leasefile format, to
778stdout and exit with zero exit code. Setting this
779option also forces the leasechange script to be called on changes
780to the client-id and lease length and expiry time.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000781.TP
Simon Kelley832af0b2007-01-21 20:01:28 +0000782.B --bridge-interface=<interface>,<alias>[,<alias>]
783Treat DHCP request packets arriving at any of the <alias> interfaces
784as if they had arrived at <interface>. This option is only available
Simon Kelley9e038942008-05-30 20:06:34 +0100785on BSD platforms, and is necessary when using "old style" bridging, since
Simon Kelley832af0b2007-01-21 20:01:28 +0000786packets arrive at tap interfaces which don't have an IP address.
787.TP
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000788.B \-s, --domain=<domain>
789Specifies the domain for the DHCP server. This has two effects;
790firstly it causes the DHCP server to return the domain to any hosts
791which request it, and secondly it sets the domain which it is legal
Simon Kelley1b7ecd12007-02-05 14:57:57 +0000792for DHCP-configured hosts to claim. The intention is to constrain
793hostnames so that an untrusted host on the LAN cannot advertise
794its name via dhcp as e.g. "microsoft.com" and capture traffic not
795meant for it. If no domain suffix is specified, then any DHCP
796hostname with a domain part (ie with a period) will be disallowed
797and logged. If suffix is specified, then hostnames with a domain
798part are allowed, provided the domain part matches the suffix. In
799addition, when a suffix is set then hostnames without a domain
800part have the suffix added as an optional domain part. Eg on my network I can set
Simon Kelley3d8df262005-08-29 12:19:27 +0100801.B --domain=thekelleys.org.uk
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000802and have a machine whose DHCP hostname is "laptop". The IP address for that machine is available from
803.B dnsmasq
Simon Kelleyde379512004-06-22 20:23:33 +0100804both as "laptop" and "laptop.thekelleys.org.uk". If the domain is
805given as "#" then the domain is read from the first "search" directive
806in /etc/resolv.conf (or equivalent).
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000807.TP
Simon Kelley832af0b2007-01-21 20:01:28 +0000808.B --enable-tftp
809Enable the TFTP server function. This is deliberately limited to that
Simon Kelley9e038942008-05-30 20:06:34 +0100810needed to net-boot a client. Only reading is allowed; the tsize and
811blksize extensions are supported (tsize is only supported in octet mode).
Simon Kelleyb8187c82005-11-26 21:46:27 +0000812.TP
Simon Kelley832af0b2007-01-21 20:01:28 +0000813.B --tftp-root=<directory>
814Look for files to transfer using TFTP relative to the given
815directory. When this is set, TFTP paths which include ".." are
816rejected, to stop clients getting outside the specified root.
Simon Kelleyf2621c72007-04-29 19:47:21 +0100817Absolute paths (starting with /) are allowed, but they must be within
818the tftp-root.
Simon Kelley832af0b2007-01-21 20:01:28 +0000819.TP
Simon Kelley5aabfc72007-08-29 11:24:47 +0100820.B --tftp-unique-root
821Add the IP address of the TFTP client as a path component on the end
822of the TFTP-root (in standard dotted-quad format). Only valid if a
823tftp-root is set and the directory exists. For instance, if tftp-root is "/tftp" and client
8241.2.3.4 requests file "myfile" then the effective path will be
825"/tftp/1.2.3.4/myfile" if /tftp/1.2.3.4 exists or /tftp/myfile otherwise.
826.TP
Simon Kelley832af0b2007-01-21 20:01:28 +0000827.B --tftp-secure
Simon Kelley5aabfc72007-08-29 11:24:47 +0100828Enable TFTP secure mode: without this, any file which is readable by
Simon Kelley832af0b2007-01-21 20:01:28 +0000829the dnsmasq process under normal unix access-control rules is
830available via TFTP. When the --tftp-secure flag is given, only files
831owned by the user running the dnsmasq process are accessible. If
832dnsmasq is being run as root, different rules apply: --tftp-secure
Simon Kelley1b7ecd12007-02-05 14:57:57 +0000833has no effect, but only files which have the world-readable bit set
Simon Kelley832af0b2007-01-21 20:01:28 +0000834are accessible. It is not recommended to run dnsmasq as root with TFTP
835enabled, and certainly not without specifying --tftp-root. Doing so
836can expose any world-readable file on the server to any host on the net.
837.TP
838.B --tftp-max=<connections>
839Set the maximum number of concurrent TFTP connections allowed. This
840defaults to 50. When serving a large number of TFTP connections,
841per-process file descriptor limits may be encountered. Dnsmasq needs
842one file descriptor for each concurrent TFTP connection and one
843file descriptor per unique file (plus a few others). So serving the
844same file simultaneously to n clients will use require about n + 10 file
845descriptors, serving different files simultaneously to n clients will
Simon Kelley824af852008-02-12 20:43:05 +0000846require about (2*n) + 10 descriptors. If
847.B --tftp-port-range
848is given, that can affect the number of concurrent connections.
Simon Kelley6b010842007-02-12 20:32:07 +0000849.TP
850.B --tftp-no-blocksize
851Stop the TFTP server from negotiating the "blocksize" option with a
852client. Some buggy clients request this option but then behave badly
853when it is granted.
Simon Kelley824af852008-02-12 20:43:05 +0000854.TP
855.B --tftp-port-range=<start>,<end>
856A TFTP server listens on a well-known port (69) for connection initiation,
857but it also uses a dynamically-allocated port for each
858connection. Normally these are allocated by the OS, but this option
859specifies a range of ports for use by TFTP transfers. This can be
860useful when TFTP has to traverse a firewall. The start of the range
861cannot be lower than 1025 unless dnsmasq is running as root. The number
862of concurrent TFTP connections is limited by the size of the port range.
Simon Kelley832af0b2007-01-21 20:01:28 +0000863.TP
Simon Kelleyb8187c82005-11-26 21:46:27 +0000864.B \-C, --conf-file=<file>
865Specify a different configuration file. The conf-file option is also allowed in
Simon Kelley849a8352006-06-09 21:02:31 +0100866configuration files, to include multiple configuration files.
867.TP
868.B \-7, --conf-dir=<directory>
869Read all the files in the given directory as configuration
870files. Files whose names end in ~ or start with . or start and end
871with # are skipped. This flag may be given on the command
872line or in a configuration file.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000873.SH CONFIG FILE
Simon Kelley3be34542004-09-11 19:12:13 +0100874At startup, dnsmasq reads
875.I /etc/dnsmasq.conf,
876if it exists. (On
877FreeBSD, the file is
878.I /usr/local/etc/dnsmasq.conf
Simon Kelleyb8187c82005-11-26 21:46:27 +0000879) (but see the
880.B \-C
Simon Kelley849a8352006-06-09 21:02:31 +0100881and
882.B \-7
883options.) The format of this
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000884file consists of one option per line, exactly as the long options detailed
885in the OPTIONS section but without the leading "--". Lines starting with # are comments and ignored. For
Simon Kelleyb49644f2004-01-30 21:36:24 +0000886options which may only be specified once, the configuration file overrides
Simon Kelleyb8187c82005-11-26 21:46:27 +0000887the command line. Quoting is allowed in a config file:
Simon Kelley3d8df262005-08-29 12:19:27 +0100888between " quotes the special meanings of ,:. and # are removed and the
Simon Kelley824af852008-02-12 20:43:05 +0000889following escapes are allowed: \\\\ \\" \\t \\e \\b \\r and \\n. The later
890corresponding to tab, escape, backspace, return and newline.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000891.SH NOTES
892When it receives a SIGHUP,
893.B dnsmasq
Simon Kelley3be34542004-09-11 19:12:13 +0100894clears its cache and then re-loads
Simon Kelley5aabfc72007-08-29 11:24:47 +0100895.I /etc/hosts
896and
897.I /etc/ethers
Simon Kelley824af852008-02-12 20:43:05 +0000898and any file given by --dhcp-hostsfile, --dhcp-optsfile or --addn-hosts.
Simon Kelley5aabfc72007-08-29 11:24:47 +0100899The dhcp lease change script is called for all
900existing DHCP leases. If
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000901.B
902--no-poll
Simon Kelley3be34542004-09-11 19:12:13 +0100903is set SIGHUP also re-reads
904.I /etc/resolv.conf.
905SIGHUP
Simon Kelleyb49644f2004-01-30 21:36:24 +0000906does NOT re-read the configuration file.
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000907.PP
908When it receives a SIGUSR1,
909.B dnsmasq
Simon Kelley824af852008-02-12 20:43:05 +0000910writes statistics to the system log. It writes the cache size,
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000911the number of names which have had to removed from the cache before
912they expired in order to make room for new names and the total number
Simon Kelley824af852008-02-12 20:43:05 +0000913of names that have been inserted into the cache. For each upstream
914server it gives the number of queries sent, and the number which
915resulted in an error. In
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000916.B --no-daemon
Simon Kelley5aabfc72007-08-29 11:24:47 +0100917mode or when full logging is enabled (-q), a complete dump of the
918contents of the cache is made.
919.PP
920When it receives SIGUSR2 and it is logging direct to a file (see
921.B --log-facility
922)
923.B dnsmasq
924will close and reopen the log file. Note that during this operation,
925dnsmasq will not be running as root. When it first creates the logfile
926dnsmasq changes the ownership of the file to the non-root user it will run
927as. Logrotate should be configured to create a new log file with
Simon Kelley9e038942008-05-30 20:06:34 +0100928the ownership which matches the existing one before sending SIGUSR2.
Simon Kelley5aabfc72007-08-29 11:24:47 +0100929If TCP DNS queries are in progress, the old logfile will remain open in
930child processes which are handling TCP queries and may continue to be
931written. There is a limit of 150 seconds, after which all existing TCP
932processes will have expired: for this reason, it is not wise to
933configure logfile compression for logfiles which have just been
934rotated. Using logrotate, the required options are
935.B create
936and
937.B delaycompress.
938
939
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000940.PP
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000941Dnsmasq is a DNS query forwarder: it it not capable of recursively
942answering arbitrary queries starting from the root servers but
943forwards such queries to a fully recursive upstream DNS server which is
944typically provided by an ISP. By default, dnsmasq reads
Simon Kelley3be34542004-09-11 19:12:13 +0100945.I /etc/resolv.conf
946to discover the IP
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000947addresses of the upstream nameservers it should use, since the
948information is typically stored there. Unless
949.B --no-poll
950is used,
951.B dnsmasq
Simon Kelley3be34542004-09-11 19:12:13 +0100952checks the modification time of
953.I /etc/resolv.conf
954(or equivalent if
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000955.B \--resolv-file
956is used) and re-reads it if it changes. This allows the DNS servers to
957be set dynamically by PPP or DHCP since both protocols provide the
958information.
Simon Kelley3be34542004-09-11 19:12:13 +0100959Absence of
960.I /etc/resolv.conf
961is not an error
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000962since it may not have been created before a PPP connection exists. Dnsmasq
Simon Kelley3be34542004-09-11 19:12:13 +0100963simply keeps checking in case
964.I /etc/resolv.conf
965is created at any
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000966time. Dnsmasq can be told to parse more than one resolv.conf
967file. This is useful on a laptop, where both PPP and DHCP may be used:
Simon Kelley3be34542004-09-11 19:12:13 +0100968dnsmasq can be set to poll both
969.I /etc/ppp/resolv.conf
970and
971.I /etc/dhcpc/resolv.conf
972and will use the contents of whichever changed
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000973last, giving automatic switching between DNS servers.
974.PP
975Upstream servers may also be specified on the command line or in
Simon Kelleyb49644f2004-01-30 21:36:24 +0000976the configuration file. These server specifications optionally take a
Simon Kelley9e4abcb2004-01-22 19:47:41 +0000977domain name which tells dnsmasq to use that server only to find names
978in that particular domain.
979.PP
980In order to configure dnsmasq to act as cache for the host on which it is running, put "nameserver 127.0.0.1" in
981.I /etc/resolv.conf
982to force local processes to send queries to
983dnsmasq. Then either specify the upstream servers directly to dnsmasq
984using
985.B \--server
986options or put their addresses real in another file, say
987.I /etc/resolv.dnsmasq
988and run dnsmasq with the
989.B \-r /etc/resolv.dnsmasq
990option. This second technique allows for dynamic update of the server
991addresses by PPP or DHCP.
Simon Kelley3be34542004-09-11 19:12:13 +0100992.PP
Simon Kelleyf6b7dc42005-01-23 12:06:08 +0000993Addresses in /etc/hosts will "shadow" different addresses for the same
994names in the upstream DNS, so "mycompany.com 1.2.3.4" in /etc/hosts will ensure that
995queries for "mycompany.com" always return 1.2.3.4 even if queries in
996the upstream DNS would otherwise return a different address. There is
997one exception to this: if the upstream DNS contains a CNAME which
998points to a shadowed name, then looking up the CNAME through dnsmasq
999will result in the unshadowed address associated with the target of
1000the CNAME. To work around this, add the CNAME to /etc/hosts so that
1001the CNAME is shadowed too.
1002
1003.PP
Simon Kelley26128d22004-11-14 16:43:54 +00001004The network-id system works as follows: For each DHCP request, dnsmasq
1005collects a set of valid network-id tags, one from the
1006.B dhcp-range
1007used to allocate the address, one from any matching
1008.B dhcp-host
1009and possibly many from matching vendor classes and user
1010classes sent by the DHCP client. Any
1011.B dhcp-option
1012which has network-id tags will be used in preference to an untagged
1013.B dhcp-option,
1014provided that _all_ the tags match somewhere in the
1015set collected as described above. The prefix '#' on a tag means 'not'
1016so --dhcp=option=#purple,3,1.2.3.4 sends the option when the
1017network-id tag purple is not in the set of valid tags.
1018.PP
Simon Kelleyf6b7dc42005-01-23 12:06:08 +00001019If the network-id in a
1020.B dhcp-range
1021is prefixed with 'net:' then its meaning changes from setting a
1022tag to matching it. Thus if there is more than dhcp-range on a subnet,
1023and one is tagged with a network-id which is set (for instance
1024from a vendorclass option) then hosts which set the netid tag will be
1025allocated addresses in the tagged range.
1026.PP
Simon Kelley3be34542004-09-11 19:12:13 +01001027The DHCP server in dnsmasq will function as a BOOTP server also,
1028provided that the MAC address and IP address for clients are given,
1029either using
1030.B dhcp-host
1031configurations or in
1032.I /etc/ethers
1033, and a
1034.B dhcp-range
1035configuration option is present to activate the DHCP server
Simon Kelleyb8187c82005-11-26 21:46:27 +00001036on a particular network. (Setting --bootp-dynamic removes the need for
1037static address mappings.) The filename
Simon Kelley3be34542004-09-11 19:12:13 +01001038parameter in a BOOTP request is matched against netids in
1039.B dhcp-option
Simon Kelley6b010842007-02-12 20:32:07 +00001040configurations, as is the tag "bootp", allowing some control over the options returned to
Simon Kelley3be34542004-09-11 19:12:13 +01001041different classes of hosts.
1042
Simon Kelley5aabfc72007-08-29 11:24:47 +01001043.SH EXIT CODES
1044.PP
10450 - Dnsmasq successfully forked into the background, or terminated
1046normally if backgrounding is not enabled.
1047.PP
10481 - A problem with configuration was detected.
1049.PP
10502 - A problem with network access occurred (address in use, attempt
1051to use privileged ports without permission).
1052.PP
Simon Kelley9e038942008-05-30 20:06:34 +010010533 - A problem occurred with a filesystem operation (missing
Simon Kelley5aabfc72007-08-29 11:24:47 +01001054file/directory, permissions).
1055.PP
10564 - Memory allocation failure.
1057.PP
10585 - Other miscellaneous problem.
1059.PP
106011 or greater - a non zero return code was received from the
1061lease-script process "init" call. The exit code from dnsmasq is the
1062script's exit code with 10 added.
1063
Simon Kelley1b7ecd12007-02-05 14:57:57 +00001064.SH LIMITS
1065The default values for resource limits in dnsmasq are generally
1066conservative, and appropriate for embedded router type devices with
1067slow processors and limited memory. On more capable hardware, it is
1068possible to increase the limits, and handle many more clients. The
1069following applies to dnsmasq-2.37: earlier versions did not scale as well.
1070
1071.PP
1072Dnsmasq is capable of handling DNS and DHCP for at least a thousand
1073clients. Clearly to do this the value of
Simon Kelleyf2621c72007-04-29 19:47:21 +01001074.B --dhcp-lease-max
Simon Kelley1b7ecd12007-02-05 14:57:57 +00001075must be increased,
1076and lease times should not be very short (less than one hour). The
1077value of
1078.B --dns-forward-max
1079can be increased: start with it equal to
1080the number of clients and increase if DNS seems slow. Note that DNS
1081performance depends too on the performance of the upstream
1082nameservers. The size of the DNS cache may be increased: the hard
1083limit is 10000 names and the default (150) is very low. Sending
1084SIGUSR1 to dnsmasq makes it log information which is useful for tuning
1085the cache size. See the
1086.B NOTES
1087section for details.
1088
1089.PP
1090The built-in TFTP server is capable of many simultaneous file
1091transfers: the absolute limit is related to the number of file-handles
1092allowed to a process and the ability of the select() system call to
1093cope with large numbers of file handles. If the limit is set too high
1094using
1095.B --tftp-max
1096it will be scaled down and the actual limit logged at
1097start-up. Note that more transfers are possible when the same file is
1098being sent than when each transfer sends a different file.
1099
1100.PP
1101It is possible to use dnsmasq to block Web advertising by using a list
1102of known banner-ad servers, all resolving to 127.0.0.1 or 0.0.0.0, in
1103.B /etc/hosts
1104or an additional hosts file. The list can be very long,
1105dnsmasq has been tested successfully with one million names. That size
1106file needs a 1GHz processor and about 60Mb of RAM.
1107
Simon Kelley9e4abcb2004-01-22 19:47:41 +00001108.SH FILES
Simon Kelleyb49644f2004-01-30 21:36:24 +00001109.IR /etc/dnsmasq.conf
1110
1111.IR /usr/local/etc/dnsmasq.conf
Simon Kelley9e4abcb2004-01-22 19:47:41 +00001112
1113.IR /etc/resolv.conf
1114
1115.IR /etc/hosts
1116
Simon Kelley3be34542004-09-11 19:12:13 +01001117.IR /etc/ethers
1118
Simon Kelleyb49644f2004-01-30 21:36:24 +00001119.IR /var/lib/misc/dnsmasq.leases
1120
1121.IR /var/db/dnsmasq.leases
Simon Kelley9e4abcb2004-01-22 19:47:41 +00001122
1123.IR /var/run/dnsmasq.pid
1124.SH SEE ALSO
Simon Kelley9e4abcb2004-01-22 19:47:41 +00001125.BR hosts (5),
1126.BR resolver (5)
1127.SH AUTHOR
1128This manual page was written by Simon Kelley <simon@thekelleys.org.uk>.
1129
1130