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