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