]> git.ipfire.org Git - people/ms/dnsmasq.git/blame - man/dnsmasq.8
import of dnsmasq-2.30.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
9is a lightweight DNS and DHCP server. It is intended to provide coupled DNS and DHCP service to a
10LAN.
11.PP
12Dnsmasq accepts DNS queries and either answers them from a small, local,
13cache or forwards them to a real, recursive, DNS server. It loads the
14contents of /etc/hosts so that local hostnames
15which do not appear in the global DNS can be resolved and also answers
16DNS queries for DHCP configured hosts.
17.PP
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
21send any desired set of DHCP options. It also supports BOOTP.
9e4abcb5 22.PP
3be34541
SK
23Dnsmasq
24supports IPv6.
9e4abcb5
SK
25.SH OPTIONS
26Note that in general missing parameters are allowed and switch off
33820b7e
SK
27functions, for instance "--pid-file=" disables writing a PID file. On
28BSD, unless the GNU getopt library is linked, the long form of the
29options does not work on the command line; it is still recognised in
30the configuration file.
9e4abcb5
SK
31.TP
32.B \-h, --no-hosts
33Don't read the hostnames in /etc/hosts.
34.TP
35.B \-H, --addn-hosts=<file>
36Additional hosts file. Read the specified file as well as /etc/hosts. If -h is given, read
fd9fa481
SK
37only the specified file. This option may be repeated for more than one
38additional hosts file.
9e4abcb5
SK
39.TP
40.B \-T, --local-ttl=<time>
41When replying with information from /etc/hosts or the DHCP leases
42file dnsmasq by default sets the time-to-live field to zero, meaning
43that the requestor should not itself cache the information. This is
44the correct thing to do in almost all situations. This option allows a
45time-to-live (in seconds) to be given for these replies. This will
46reduce the load on the server at the expense of clients using stale
47data under some circumstances.
48.TP
3be34541
SK
49.B \-k, --keep-in-foreground
50Do not go into the background at startup but otherwise run as
3d8df260
SK
51normal. This is intended for use when dnsmasq is run under daemontools
52or launchd.
3be34541 53.TP
9e4abcb5
SK
54.B \-d, --no-daemon
55Debug mode: don't fork to the background, don't write a pid file,
56don't change user id, generate a complete cache dump on receipt on
3be34541
SK
57SIGUSR1, log to stderr as well as syslog, don't fork new processes
58to handle TCP queries.
9e4abcb5
SK
59.TP
60.B \-q, --log-queries
61Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1.
62.TP
63.B \-x, --pid-file=<path>
64Specify an alternate path for dnsmasq to record its process-id in. Normally /var/run/dnsmasq.pid.
65.TP
66.B \-u, --user=<username>
67Specify the userid to which dnsmasq will change after startup. Dnsmasq must normally be started as root, but it will drop root
b8187c80 68privileges after startup by changing id to another user. Normally this user is "nobody" but that
9e4abcb5
SK
69can be over-ridden with this switch.
70.TP
71.B \-g, --group=<groupname>
72Specify the group which dnsmasq will run
73as. The defaults to "dip", if available, to facilitate access to
74/etc/ppp/resolv.conf which is not normally world readable.
75.TP
76.B \-v, --version
77Print the version number.
78.TP
79.B \-p, --port=<port>
80Listen on <port> instead of the standard DNS port (53). Useful mainly for
81debugging.
82.TP
feba5c1d
SK
83.B \-P, --edns-packet-max=<size>
84Specify the largest EDNS.0 UDP packet which is supported by the DNS
85forwarder. Defaults to 1280, which is the RFC2671-recommended maximum
86for ethernet.
87.TP
9e4abcb5
SK
88.B \-Q, --query-port=<query_port>
89Send 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
90firewall 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
91port being used by the current dnsmasq instance.
92.TP
93.B \-i, --interface=<interface name>
feba5c1d
SK
94Listen only on the specified interface(s). Dnsmasq automatically adds
95the loopback (local) interface to the list of interfaces to use when
96the
97.B \--interface
98option is used. If no
99.B \--interface
9e4abcb5 100or
feba5c1d
SK
101.B \--listen-address
102options are given dnsmasq listens on all available interfaces except any
103given in
104.B \--except-interface
309331f5 105options. IP alias interfaces (eg "eth1:0") cannot be used with
8a911ccc
SK
106.B --interface
107or
108.B --except-interface
309331f5 109options, use --listen-address instead.
9e4abcb5
SK
110.TP
111.B \-I, --except-interface=<interface name>
feba5c1d
SK
112Do not listen on the specified interface. Note that the order of
113.B \--listen-address
114.B --interface
115and
116.B --except-interface
117options does not matter and that
118.B --except-interface
119options always override the others.
9e4abcb5 120.TP
3d8df260
SK
121.B \-2, --no-dhcp-interface=<interface name>
122Do not provide DHCP on the specified interface, but do provide DNS service.
123.TP
44a2a316 124.B \-a, --listen-address=<ipaddr>
feba5c1d
SK
125Listen on the given IP address(es). Both
126.B \--interface
127and
128.B \--listen-address
129options may be given, in which case the set of both interfaces and
130addresses is used. Note that if no
131.B \--interface
132option is given, but
133.B \--listen-address
134is, dnsmasq will not automatically listen on the loopback
135interface. To achieve this, its IP address, 127.0.0.1, must be
136explicitly given as a
137.B \--listen-address
138option.
9e4abcb5 139.TP
44a2a316
SK
140.B \-z, --bind-interfaces
141On systems which support it, dnsmasq binds the wildcard address,
142even when it is listening on only some interfaces. It then discards
143requests that it shouldn't reply to. This has the advantage of
144working even when interfaces come and go and change address. This
145option forces dnsmasq to really bind only the interfaces it is
146listening on. About the only time when this is useful is when
f6b7dc47 147running another nameserver (or another instance of dnsmasq) on the
309331f5 148same machine. Setting this option also enables multiple instances of
f6b7dc47
SK
149dnsmasq which provide DHCP service to run in the same machine.
150.TP
151.B \-y, --localise-queries
152Return answers to DNS queries from /etc/hosts which depend on the interface over which the query was
b8187c80 153received. If a name in /etc/hosts has more than one address associated with
f6b7dc47
SK
154it, and at least one of those addresses is on the same subnet as the
155interface to which the query was sent, then return only the
156address(es) on that subnet. This allows for a server to have multiple
157addresses in /etc/hosts corresponding to each of its interfaces, and
158hosts will get the correct address based on which network they are
159attached to. Currently this facility is limited to IPv4.
44a2a316 160.TP
9e4abcb5
SK
161.B \-b, --bogus-priv
162Bogus private reverse lookups. All reverse lookups for private IP ranges (ie 192.168.x.x, etc)
feba5c1d
SK
163which are not found in /etc/hosts or the DHCP leases file are answered
164with "no such domain" rather than being forwarded upstream.
9e4abcb5 165.TP
1cff166d
SK
166.B \-V, --alias=<old-ip>,<new-ip>[,<mask>]
167Modify IPv4 addresses returned from upstream nameservers; old-ip is
168replaced by new-ip. If the optional mask is given then any address
169which matches the masked old-ip will be re-written. So, for instance
170.B --alias=1.2.3.0,6.7.8.0,255.255.255.0
171will map 1.2.3.56 to 6.7.8.56 and 1.2.3.67 to 6.7.8.67. This is what
172Cisco PIX routers call "DNS doctoring".
173.TP
9e4abcb5
SK
174.B \-B, --bogus-nxdomain=<ipaddr>
175Transform replies which contain the IP address given into "No such
176domain" replies. This is intended to counteract a devious move made by
b8187c80 177Verisign in September 2003 when they started returning the address of
9e4abcb5
SK
178an advertising web page in response to queries for unregistered names,
179instead of the correct NXDOMAIN response. This option tells dnsmasq to
180fake the correct response when it sees this behaviour. As at Sept 2003
b8187c80 181the IP address being returned by Verisign is 64.94.110.11
9e4abcb5
SK
182.TP
183.B \-f, --filterwin2k
184Later versions of windows make periodic DNS requests which don't get sensible answers from
185the public DNS and can cause problems by triggering dial-on-demand links. This flag turns on an option
186to filter such requests. The requests blocked are for records of types SOA and SRV, and type ANY where the
187requested name has underscores, to catch LDAP requests.
188.TP
189.B \-r, --resolv-file=<file>
190Read the IP addresses of the upstream nameservers from <file>, instead of
191/etc/resolv.conf. For the format of this file see
192.BR resolv.conf (5)
193the only lines relevant to dnsmasq are nameserver ones. Dnsmasq can
194be told to poll more than one resolv.conf file, the first file name specified
195overrides the default, subsequent ones add to the list. This is only
196allowed when polling; the file with the currently latest modification
197time is the one used.
198.TP
199.B \-R, --no-resolv
200Don't read /etc/resolv.conf. Get upstream servers only from the command
b49644f3 201line or the dnsmasq configuration file.
9e4abcb5 202.TP
3d8df260
SK
203.B \-1, --enable-dbus
204Allow dnsmasq configuration to be updated via DBus method calls. The
205configuration which can be changed is upstream DNS servers (and
b8187c80 206corresponding domains) and cache clear. Requires that dnsmasq has
3d8df260
SK
207been built with DBus support.
208.TP
9e4abcb5
SK
209.B \-o, --strict-order
210By default, dnsmasq will send queries to any of the upstream servers
211it knows about and tries to favour servers to are known to
212be up. Setting this flag forces dnsmasq to try each query with each
213server strictly in the order they appear in /etc/resolv.conf
214.TP
215.B \-n, --no-poll
216Don't poll /etc/resolv.conf for changes.
217.TP
218.B \-D, --domain-needed
219Tells dnsmasq to never forward queries for plain names, without dots
3d8df260 220or domain parts, to upstream nameservers. If the name is not known
9e4abcb5
SK
221from /etc/hosts or DHCP then a "not found" answer is returned.
222.TP
223.B \-S, --server=[/[<domain>]/[domain/]][<ipaddr>[#<port>][@<source>[#<port>]]]
3d8df260 224Specify IP address of upstream severs directly. Setting this flag does
9e4abcb5
SK
225not suppress reading of /etc/resolv.conf, use -R to do that. If one or
226more
227optional domains are given, that server is used only for those domains
228and they are queried only using the specified server. This is
229intended for private nameservers: if you have a nameserver on your
230network which deals with names of the form
231xxx.internal.thekelleys.org.uk at 192.168.1.1 then giving the flag
b8187c80 232.B -S /internal.thekelleys.org.uk/192.168.1.1
9e4abcb5
SK
233will send all queries for
234internal machines to that nameserver, everything else will go to the
235servers in /etc/resolv.conf. An empty domain specification,
236.B //
237has the special meaning of "unqualified names only" ie names without any
238dots in them. A non-standard port may be specified as
239part of the IP
240address using a # character.
241More than one -S flag is allowed, with
242repeated domain or ipaddr parts as required.
243
244Also permitted is a -S
245flag which gives a domain but no IP address; this tells dnsmasq that
246a domain is local and it may answer queries from /etc/hosts or DHCP
247but should never forward queries on that domain to any upstream
248servers.
249.B local
250is a synonym for
251.B server
252to make configuration files clearer in this case.
253
254The optional second IP address after the @ character tells
255dnsmasq how to set the source address of the queries to this
256nameserver. It should be an address belonging to the machine on which
257dnsmasq is running otherwise this server line will be logged and then
258ignored. The query-port flag is ignored for any servers which have a
259source address specified but the port may be specified directly as
260part of the source address.
261.TP
262.B \-A, --address=/<domain>/[domain/]<ipaddr>
263Specify an IP address to return for any host in the given domains.
264Queries in the domains are never forwarded and always replied to
265with the specified IP address which may be IPv4 or IPv6. To give
266both IPv4 and IPv6 addresses for a domain, use repeated -A flags.
267Note that /etc/hosts and DHCP leases override this for individual
268names. A common use of this is to redirect the entire doubleclick.net
a222641c
SK
269domain to some friendly local web server to avoid banner ads. The
270domain specification works in the same was as for --server, with the
271additional facility that /#/ matches any domain. Thus
272--address=/#/1.2.3.4 will always return 1.2.3.4 for any query not
273answered from /etc/hosts or DHCP and not sent to an upstream
274nameserver by a more specific --server directive.
9e4abcb5 275.TP
f6b7dc47 276.B \-m, --mx-host=<mx name>[[,<hostname>],<preference>]
de37951c
SK
277Return an MX record named <mx name> pointing to the given hostname (if
278given), or
279the host specified in the --mx-target switch
9e4abcb5 280or, if that switch is not given, the host on which dnsmasq
f6b7dc47
SK
281is running. The default is useful for directing mail from systems on a LAN
282to a central server. The preference value is optional, and defaults to
2831 if not given. More than one MX record may be given for a host.
9e4abcb5
SK
284.TP
285.B \-t, --mx-target=<hostname>
f6b7dc47
SK
286Specify the default target for the MX record returned by dnsmasq. See
287--mx-host. If --mx-target is given, but not --mx-host, then dnsmasq
288returns a MX record containing the MX target for MX queries on the
289hostname of the machine on which dnsmasq is running.
9e4abcb5
SK
290.TP
291.B \-e, --selfmx
292Return an MX record pointing to itself for each local
293machine. Local machines are those in /etc/hosts or with DHCP leases.
294.TP
295.B \-L, --localmx
296Return an MX record pointing to the host given by mx-target (or the
297machine on which dnsmasq is running) for each
298local machine. Local machines are those in /etc/hosts or with DHCP
299leases.
300.TP
f6b7dc47
SK
301.B \-W, --srv-host=<_service>.<_prot>.[<domain>],[<target>[,<port>[,<priority>[,<weight>]]]]
302Return a SRV DNS record. See RFC2782 for details. If not supplied, the
303domain defaults to that given by
304.B --domain.
305The default for the target domain is empty, and the default for port
306is one and the defaults for
307weight and priority are zero. Be careful if transposing data from BIND
308zone files: the port, weight and priority numbers are in a different
309order. More than one SRV record for a given service/domain is allowed,
3d8df260 310all that match are returned.
f6b7dc47 311.TP
0a852541
SK
312.B \-Y, --txt-record=<name>[[,<text>],<text>]
313Return a TXT DNS record. The value of TXT record is a set of strings,
314so any number may be included, split by commas.
315.TP
9e4abcb5
SK
316.B \-c, --cache-size=<cachesize>
317Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching.
318.TP
319.B \-N, --no-negcache
320Disable negative caching. Negative caching allows dnsmasq to remember
321"no such domain" answers from upstream nameservers and answer
322identical queries without forwarding them again. This flag disables
323negative caching.
324.TP
0a852541 325.B \-F, --dhcp-range=[[net:]network-id,]<start-addr>,<end-addr>[[,<netmask>],<broadcast>][,<default lease time>]
9e4abcb5 326Enable the DHCP server. Addresses will be given out from the range
44a2a316
SK
327<start-addr> to <end-addr> and from statically defined addresses given
328in
329.B dhcp-host
330options. If the lease time is given, then leases
b8187c80 331will be given for that length of time. The lease time is in seconds,
9e4abcb5
SK
332or minutes (eg 45m) or hours (eg 1h) or the literal "infinite". This
333option may be repeated, with different addresses, to enable DHCP
44a2a316
SK
334service to more than one network. For directly connected networks (ie,
335networks on which the machine running dnsmasq has an interface) the
336netmask is optional. It is, however, required for networks which
b8187c80 337receive DHCP service via a relay agent. The broadcast address is
44a2a316
SK
338always optional. On some broken systems, dnsmasq can listen on only
339one interface when using DHCP, and the name of that interface must be
340given using the
341.B interface
f6b7dc47
SK
342option. This limitation currently affects OpenBSD. It is always
343allowed to have more than one dhcp-range in a single subnet. The optional
44a2a316 344network-id is a alphanumeric label which marks this network so that
0a852541
SK
345dhcp options may be specified on a per-network basis.
346When it is prefixed with 'net:' then its meaning changes from setting
cdeda28f 347a tag to matching it. Only one tag may be set, but more than one tag may be matched.
0a852541 348The end address may be replaced by the keyword
33820b7e
SK
349.B static
350which tells dnsmasq to enable DHCP for the network specified, but not
351to dynamically allocate IP addresses. Only hosts which have static
352addresses given via
353.B dhcp-host
354or from /etc/ethers will be served.
9e4abcb5 355.TP
a84fa1d0 356.B \-G, --dhcp-host=[[<hwaddr>]|[id:[<client_id>][*]]][net:<netid>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
9e4abcb5
SK
357Specify per host parameters for the DHCP server. This allows a machine
358with a particular hardware address to be always allocated the same
359hostname, IP address and lease time. A hostname specified like this
360overrides any supplied by the DHCP client on the machine. It is also
361allowable to ommit the hardware address and include the hostname, in
362which case the IP address and lease times will apply to any machine
363claiming that name. For example
364.B --dhcp-host=00:20:e0:3b:13:af,wap,infinite
365tells dnsmasq to give
cdeda28f 366the machine with hardware address 00:20:e0:3b:13:af the name wap, and
9e4abcb5
SK
367an infinite DHCP lease.
368.B --dhcp-host=lap,192.168.0.199
369tells
370dnsmasq to always allocate the machine lap the IP address
1ab84e2f 371192.168.0.199. Addresses allocated like this are not constrained to be
9e4abcb5
SK
372in the range given by the --dhcp-range option, but they must be on the
373network being served by the DHCP server. It is allowed to use client identifiers rather than
374hardware addresses to identify hosts by prefixing with 'id:'. Thus:
375.B --dhcp-host=id:01:02:03:04,.....
376refers to the host with client identifier 01:02:03:04. It is also
377allowed to specify the client ID as text, like this:
a84fa1d0
SK
378.B --dhcp-host=id:clientidastext,.....
379The special option id:* means "ignore any client-id
380and use MAC addresses only." This is useful when a client presents a client-id sometimes
381but not others.
1ab84e2f
SK
382If a name appears in /etc/hosts, the associated address can be
383allocated to a DHCP lease, but only if a
384.B --dhcp-host
33820b7e
SK
385option specifying the name also exists. The special keyword "ignore"
386tells dnsmasq to never offer a DHCP lease to a machine. The machine
387can be specified by hardware address, client ID or hostname, for
388instance
389.B --dhcp-host=00:20:e0:3b:13:af,ignore
390This is
391useful when there is another DHCP server on the network which should
3d8df260
SK
392be used by some machines. The net:<network-id> sets the network-id tag
393whenever this dhcp-host directive is in use.
394This can be used to selectively send DHCP options just
395for this host.
0a852541
SK
396Ethernet addresses (but not client-ids) may have
397wildcard bytes, so for example
398.B --dhcp-host=00:20:e0:3b:13:*,ignore
cdeda28f 399will cause dnsmasq to ignore a range of hardware addresses. Note that
0a852541 400the "*" will need to be escaped or quoted on a command line, but not
cdeda28f
SK
401in the configuration file. Hardware addresses normally match any
402network (ARP) type, but it is possible to restrict them to a single
403ARP type by preceding them with the ARP-type (in HEX) and "-". so
404.B --dhcp-host=06-00:20:e0:3b:13:af,1.2.3.4
405will only match a
406Token-Ring hardware address, since the ARP-address type for token ring
407is 6.
44a2a316
SK
408.TP
409.B \-Z, --read-ethers
410Read /etc/ethers for information about hosts for the DHCP server. The
411format of /etc/ethers is a hardware address, followed by either a
412hostname or dotted-quad IP address. When read by dnsmasq these lines
413have exactly the same effect as
414.B --dhcp-host
415options containing the same information.
9e4abcb5 416.TP
91dccd09 417.B \-O, --dhcp-option=[<network-id>,[<network-id>,]][vendor:<vendor-class>]<opt>,[<value>[,<value>]]
b8187c80 418Specify different or extra options to DHCP clients. By default,
9e4abcb5
SK
419dnsmasq sends some standard options to DHCP clients, the netmask and
420broadcast address are set to the same as the host running dnsmasq, and
421the DNS server and default route are set to the address of the machine
422running dnsmasq. If the domain name option has been set, that is sent.
423This option allows these defaults to be overridden,
424or other options specified. The <opt> is the number of the option, as
b8187c80 425specified in RFC2132. For example, to set the default route option to
9e4abcb5
SK
426192.168.4.4, do
427.B --dhcp-option=3,192.168.4.4
428and to set the time-server address to 192.168.0.4, do
a84fa1d0 429.B --dhcp-option=42,192.168.0.4
1ab84e2f 430The special address 0.0.0.0 is taken to mean "the address of the
f6b7dc47
SK
431machine running dnsmasq". Data types allowed are comma separated
432dotted-quad IP addresses, a decimal number, colon-separated hex digits
26128d27
SK
433and a text string. If the optional network-ids are given then
434this option is only sent when all the network-ids are matched.
91dccd09 435
cdeda28f
SK
436Special processing is done on a text argument for option 119, to
437conform with RFC 3397, and dotted-quad IP addresses which are followed
438by a slash and then a netmask size are encoded as described in RFC
4393442.
440
9e4abcb5 441Be careful: no checking is done that the correct type of data for the
26128d27 442option number is sent, it is quite possible to
9e4abcb5 443persuade dnsmasq to generate illegal DHCP packets with injudicious use
91dccd09
SK
444of this flag. When the value is a decimal number, dnsmasq must determine how
445large the data item is. It does this by examining the option number and/or the
b8187c80 446value, but can be overridden by appending a single letter flag as follows:
91dccd09 447b = one byte, s = two bytes, i = four bytes. This is mainly useful with
3d8df260
SK
448encapsulated vendor class options (see below) where dnsmasq cannot
449determine data size from the option number. Option data which
450consists solely of periods and digits will be interpreted by dnsmasq
451as an IP address, and inserted into an option as such. To force a
452literal string, use quotes. For instance when using option 66 to send
453a literal IP address as TFTP server name, it is necessary to do
454.B --dhcp-option=66,"1.2.3.4"
91dccd09
SK
455
456Encapsulated Vendor-class options may also be specified using
457--dhcp-option: for instance
458.B --dhcp-option=vendor:PXEClient,1,0.0.0.0
459sends the vendor class "PXEClient" and the encapsulated vendor class-specific option "mftp-address=0.0.0.0" Only one vendor class is allowed for any
460host, but multiple options are allowed, provided they all have
461the same vendor class. The address 0.0.0.0 is not treated specially in
462encapsulated vendor class options.
9e4abcb5 463.TP
a84fa1d0
SK
464.B \-U, --dhcp-vendorclass=<network-id>,<vendor-class>
465Map from a vendor-class string to a network id. Most DHCP clients provide a
a222641c 466"vendor class" which represents, in some sense, the type of host. This option
a84fa1d0
SK
467maps vendor classes to network ids, so that DHCP options may be selectively delivered
468to different classes of hosts. For example
469.B dhcp-vendorclass=printers,Hewlett-Packard JetDirect
470will allow options to be set only for HP printers like so:
a222641c
SK
471.B --dhcp-option=printers,3,192.168.4.4
472The vendor-class string is
473substring matched against the vendor-class supplied by the client, to
474allow fuzzy matching.
475.TP
476.B \-j, --dhcp-userclass=<network-id>,<user-class>
477Map from a user-class string to a network id (with substring
478matching, like vendor classes). Most DHCP clients provide a
479"user class" which is configurable. This option
480maps user classes to network ids, so that DHCP options may be selectively delivered
481to different classes of hosts. It is possible, for instance to use
482this to set a different printer server for hosts in the class
483"accounts" than for hosts in the class "engineering".
a84fa1d0 484.TP
cdeda28f
SK
485.B \-4, --dhcp-mac=<network-id>,<MAC address>
486Map from a MAC address to a network-id. The MAC address may include
487wildcards. For example
488.B --dhcp-mac=3com,01:34:23:*:*:*
489will set the tag "3com" for any host whose MAC address matches the pattern.
490.TP
491.B \-J, --dhcp-ignore=<network-id>[,<network-id>]
26128d27
SK
492When all the given network-ids match the set of network-ids derived
493from the net, host, vendor and user classes, ignore the host and do
494not allocate it a DHCP lease.
495.TP
496.B \-M, --dhcp-boot=[net:<network-id>,]<filename>,[<servername>[,<server address>]]
9e4abcb5
SK
497Set BOOTP options to be returned by the DHCP server. These are needed
498for machines which network boot, and tell the machine where to collect
26128d27
SK
499its initial configuration. If the optional network-id(s) are given,
500they must match for this configuration to be sent. Note that
501network-ids are prefixed by "net:" to distinguish them.
9e4abcb5 502.TP
44a2a316
SK
503.B \-X, --dhcp-lease-max=<number>
504Limits dnsmasq to the specified maximum number of DHCP leases. The
505default is 150. This limit is to prevent DoS attacks from hosts which
506create thousands of leases and use lots of memory in the dnsmasq
507process.
508.TP
fd9fa481 509.B \-K, --dhcp-authoritative
b8187c80 510Should be set when dnsmasq is definately the only DHCP server on a network.
fd9fa481
SK
511It changes the behaviour from strict RFC compliance so that DHCP requests on
512unknown leases from unknown hosts are not ignored. This allows new hosts
cdeda28f
SK
513to get a lease without a tedious timeout under all circumstances. It also
514allows dnsmasq to rebuild its lease database without each client needing to
515reaquire a lease, if the database is lost.
fd9fa481 516.TP
3d8df260
SK
517.B \-3, --bootp-dynamic
518Enable dynamic allocation of IP addresses to BOOTP clients. Use this
519with care, since each address allocated to a BOOTP client is leased
520forever, and therefore becomes permanently unavailable for re-use by
521other hosts.
522.TP
5e9e0efb
SK
523.B \-5, --no-ping
524By default, the DHCP server will attempt to ensure that an address in
525not in use before allocating it to a host. It does this by sending an
526ICMP echo request (aka "ping") to the address in question. If it gets
527a reply, then the address must already be in use, and another is
528tried. This flag disables this check. Use with caution.
529.TP
9e4abcb5 530.B \-l, --dhcp-leasefile=<path>
33820b7e
SK
531Use the specified file to store DHCP lease information. If this option
532is given but no dhcp-range option is given then dnsmasq version 1
533behaviour is activated. The file given is assumed to be an ISC dhcpd
534lease file and parsed for leases which are then added to the DNS
535system if they have a hostname. This functionality may have been
536excluded from dnsmasq at compile time, in which case an error will occur.
9e4abcb5
SK
537.TP
538.B \-s, --domain=<domain>
539Specifies the domain for the DHCP server. This has two effects;
540firstly it causes the DHCP server to return the domain to any hosts
541which request it, and secondly it sets the domain which it is legal
542for DHCP-configured hosts to claim. The intention is to constrain hostnames so that an untrusted host on the LAN cannot advertise it's name via dhcp as e.g. "microsoft.com" and capture traffic not meant for it. If no domain suffix is specified, then any DHCP hostname with a domain part (ie with a period) will be disallowed and logged. If suffix is specified, then hostnames with a domain part are allowed, provided the domain part matches the suffix. In addition, when a suffix is set then hostnames without a domain part have the suffix added as an optional domain part. Eg on my network I can set
3d8df260 543.B --domain=thekelleys.org.uk
9e4abcb5
SK
544and have a machine whose DHCP hostname is "laptop". The IP address for that machine is available from
545.B dnsmasq
de37951c
SK
546both as "laptop" and "laptop.thekelleys.org.uk". If the domain is
547given as "#" then the domain is read from the first "search" directive
548in /etc/resolv.conf (or equivalent).
9e4abcb5
SK
549.TP
550.B \-E, --expand-hosts
3d8df260 551Add the domain to simple names (without a period) in /etc/hosts
9e4abcb5 552in the same way as for DHCP-derived names.
b8187c80
SK
553.TP
554.B \-C, --conf-file=<file>
555Specify a different configuration file. The conf-file option is also allowed in
556configuration files, to include multiple configuration files. Only one
557level of nesting is allowed.
9e4abcb5 558.SH CONFIG FILE
3be34541
SK
559At startup, dnsmasq reads
560.I /etc/dnsmasq.conf,
561if it exists. (On
562FreeBSD, the file is
563.I /usr/local/etc/dnsmasq.conf
b8187c80
SK
564) (but see the
565.B \-C
566option.) The format of this
9e4abcb5
SK
567file consists of one option per line, exactly as the long options detailed
568in the OPTIONS section but without the leading "--". Lines starting with # are comments and ignored. For
b49644f3 569options which may only be specified once, the configuration file overrides
b8187c80 570the command line. Quoting is allowed in a config file:
3d8df260
SK
571between " quotes the special meanings of ,:. and # are removed and the
572following escapes are allowed: \\\\ \\" \\t \\a \\b \\r and \\n. The later
573corresponding to tab, bell, backspace, return and newline.
9e4abcb5
SK
574.SH NOTES
575When it receives a SIGHUP,
576.B dnsmasq
3be34541
SK
577clears its cache and then re-loads
578.I /etc/hosts.
579If
9e4abcb5
SK
580.B
581--no-poll
3be34541
SK
582is set SIGHUP also re-reads
583.I /etc/resolv.conf.
584SIGHUP
b49644f3 585does NOT re-read the configuration file.
9e4abcb5
SK
586.PP
587When it receives a SIGUSR1,
588.B dnsmasq
589writes cache statistics to the system log. It writes the cache size,
590the number of names which have had to removed from the cache before
591they expired in order to make room for new names and the total number
592of names that have been inserted into the cache. In
593.B --no-daemon
594mode or when full logging is enabled (-q), a complete dump of the contents of the cache is made.
595.PP
9e4abcb5
SK
596Dnsmasq is a DNS query forwarder: it it not capable of recursively
597answering arbitrary queries starting from the root servers but
598forwards such queries to a fully recursive upstream DNS server which is
599typically provided by an ISP. By default, dnsmasq reads
3be34541
SK
600.I /etc/resolv.conf
601to discover the IP
9e4abcb5
SK
602addresses of the upstream nameservers it should use, since the
603information is typically stored there. Unless
604.B --no-poll
605is used,
606.B dnsmasq
3be34541
SK
607checks the modification time of
608.I /etc/resolv.conf
609(or equivalent if
9e4abcb5
SK
610.B \--resolv-file
611is used) and re-reads it if it changes. This allows the DNS servers to
612be set dynamically by PPP or DHCP since both protocols provide the
613information.
3be34541
SK
614Absence of
615.I /etc/resolv.conf
616is not an error
9e4abcb5 617since it may not have been created before a PPP connection exists. Dnsmasq
3be34541
SK
618simply keeps checking in case
619.I /etc/resolv.conf
620is created at any
9e4abcb5
SK
621time. Dnsmasq can be told to parse more than one resolv.conf
622file. This is useful on a laptop, where both PPP and DHCP may be used:
3be34541
SK
623dnsmasq can be set to poll both
624.I /etc/ppp/resolv.conf
625and
626.I /etc/dhcpc/resolv.conf
627and will use the contents of whichever changed
9e4abcb5
SK
628last, giving automatic switching between DNS servers.
629.PP
630Upstream servers may also be specified on the command line or in
b49644f3 631the configuration file. These server specifications optionally take a
9e4abcb5
SK
632domain name which tells dnsmasq to use that server only to find names
633in that particular domain.
634.PP
635In order to configure dnsmasq to act as cache for the host on which it is running, put "nameserver 127.0.0.1" in
636.I /etc/resolv.conf
637to force local processes to send queries to
638dnsmasq. Then either specify the upstream servers directly to dnsmasq
639using
640.B \--server
641options or put their addresses real in another file, say
642.I /etc/resolv.dnsmasq
643and run dnsmasq with the
644.B \-r /etc/resolv.dnsmasq
645option. This second technique allows for dynamic update of the server
646addresses by PPP or DHCP.
f6b7dc47
SK
647.PP
648Addresses in /etc/hosts will "shadow" different addresses for the same
649names in the upstream DNS, so "mycompany.com 1.2.3.4" in /etc/hosts will ensure that
650queries for "mycompany.com" always return 1.2.3.4 even if queries in
651the upstream DNS would otherwise return a different address. There is
652one exception to this: if the upstream DNS contains a CNAME which
653points to a shadowed name, then looking up the CNAME through dnsmasq
654will result in the unshadowed address associated with the target of
655the CNAME. To work around this, add the CNAME to /etc/hosts so that
656the CNAME is shadowed too.
657
3be34541 658.PP
26128d27
SK
659The network-id system works as follows: For each DHCP request, dnsmasq
660collects a set of valid network-id tags, one from the
661.B dhcp-range
662used to allocate the address, one from any matching
663.B dhcp-host
664and possibly many from matching vendor classes and user
665classes sent by the DHCP client. Any
666.B dhcp-option
667which has network-id tags will be used in preference to an untagged
668.B dhcp-option,
669provided that _all_ the tags match somewhere in the
670set collected as described above. The prefix '#' on a tag means 'not'
671so --dhcp=option=#purple,3,1.2.3.4 sends the option when the
672network-id tag purple is not in the set of valid tags.
673.PP
f6b7dc47
SK
674If the network-id in a
675.B dhcp-range
676is prefixed with 'net:' then its meaning changes from setting a
677tag to matching it. Thus if there is more than dhcp-range on a subnet,
678and one is tagged with a network-id which is set (for instance
679from a vendorclass option) then hosts which set the netid tag will be
680allocated addresses in the tagged range.
681.PP
3be34541
SK
682The DHCP server in dnsmasq will function as a BOOTP server also,
683provided that the MAC address and IP address for clients are given,
684either using
685.B dhcp-host
686configurations or in
687.I /etc/ethers
688, and a
689.B dhcp-range
690configuration option is present to activate the DHCP server
b8187c80
SK
691on a particular network. (Setting --bootp-dynamic removes the need for
692static address mappings.) The filename
3be34541
SK
693parameter in a BOOTP request is matched against netids in
694.B dhcp-option
695configurations, allowing some control over the options returned to
696different classes of hosts.
697
9e4abcb5 698.SH FILES
b49644f3
SK
699.IR /etc/dnsmasq.conf
700
701.IR /usr/local/etc/dnsmasq.conf
9e4abcb5
SK
702
703.IR /etc/resolv.conf
704
705.IR /etc/hosts
706
3be34541
SK
707.IR /etc/ethers
708
b49644f3
SK
709.IR /var/lib/misc/dnsmasq.leases
710
711.IR /var/db/dnsmasq.leases
9e4abcb5
SK
712
713.IR /var/run/dnsmasq.pid
714.SH SEE ALSO
9e4abcb5
SK
715.BR hosts (5),
716.BR resolver (5)
717.SH AUTHOR
718This manual page was written by Simon Kelley <simon@thekelleys.org.uk>.
719
720