b1b2e4ea0fc84d655cf37a39210260a50f2ab7ff
[web.git] / docs / uci_dnsmasq.txt
1 DNS and DHCP configuration
2 ==========================
3
4 include::uci_menu.inc[]
5
6 == DNS and DHCP configuration
7
8 The _dnsmasq_ and dhcpd configuration is located in **'/etc/config/dhcp'** and controls both DNS and DHCP server options on the device.
9
10 In the default configuration this file contains one _common section_ to specify DNS and daemon related options and one or more _DHCP pools_ to define DHCP ranges serving on network interfaces.
11
12 == Sections
13
14 Possible section types of the 'dhcp' configuration file are defined below. Not all types may appear in the file and most of them are only needed for special configurations. The common ones are the _Common Options_, the _DHCP Pools_ and _Static Leases_.
15
16 === Common Options
17
18 The config section type 'dnsmasq' determines values and options relevant to the overall operation of dnsmasq and the DHCP options on all interfaces served. The following table lists all available options, their default value, as well as the corresponding _dnsmasq_ command line option. See link:http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html[the dnsmasq man page] for further details.
19
20 These are the default settings for the common options:
21
22 ----
23 config 'dnsmasq'
24 option domainneeded 1
25 option boguspriv 1
26 option filterwin2k 0
27 option localise_queries 1
28 option rebind_protection 1
29 option rebind_localhost 0
30 option local '/lan/'
31 option domain 'lan'
32 option expandhosts 1
33 option nonegcache 0
34 option authoritative 1
35 option readethers 1
36 option leasefile '/tmp/dhcp.leases'
37 option resolvfile '/tmp/resolv.conf.auto'
38 ----
39
40 * Options 'local' and 'domain' enable _dnsmasq_ to serve entries in '/etc/hosts' as well as the DHCP client's names as if they were entered into the _lan_ DNS domain.
41 * Options 'domainneeded', 'boguspriv', 'localise_queries', and 'expandhosts' make sure that requests for these local host names (and the reverse lookup) never get forwarded to the upstream DNS servers.
42 * Option 'authoritative' makes the router the only DHCP server on this network; clients get their IP lease a lot faster this way.
43 * Option 'leasefile' stores the leases in a file, so that they can be picked up again if _dnsmasq_ is restarted.
44 * Option 'resolvfile' tells _dnsmasq_ to use this file to find upstream name servers; it gets created by the WAN DHCP client or the PPP client.
45
46 === All Options
47 [cols="4*1,4",options="header"]
48 |====
49 | Name | Type | Default | Option | Description
50 | 'add_local_domain' | boolean | '1' | | Add the local domain as search directive in resolv.conf.
51 | 'add_local_hostname' | boolean | '1' | | Add A and PTR records automatically for the local hostname.
52 | 'addnhosts' | list of file paths | _(none)_ | '-H' | Additional host files to read for serving DNS responses
53 | 'authoritative' | boolean | '0' | '-K' | Force _dnsmasq_ into authoritative mode. This speeds up DHCP leasing. Used if this is the only server on the network
54 | 'bogusnxdomain' | list of IP addresses | _(none)_ | '-B' | IP addresses to convert into NXDOMAIN responses (to counteract upstream DNS servers that never return NXDOMAIN).
55 | 'boguspriv' | boolean | '0' | '-b' | Reject reverse lookups to private IP ranges where no corresponding entry exists in '/etc/hosts'
56 | 'cachelocal' | boolean | '1' | | When set to '0', use each network interface's 'dns' address in the local '/etc/resolv.conf'. Normally, only the loopback address is used, and all queries go through _dnsmasq_.
57 | 'cachesize' | integer | '150' | '-c' | Size of _dnsmasq_ query cache.
58 | 'dbus' | boolean | '0' | '-1' | Enable DBus messaging for _dnsmasq_. *CAUTION*: Standard builds of _dnsmasq_ do not include DBus support.
59 | 'dhcp_boot' | string | _(none)_ |--dhcp-boot>| Specifies BOOTP options, in most cases just the file name
60 | 'dhcphostsfile' | file path | _(none)_ | --dhcp-hostsfile | Specify an external file with per host DHCP options
61 | 'dhcpleasemax' | integer | '150' | '-X' | Maximum number of DHCP leases
62 | 'dnsforwardmax' | integer | '150' | '-0' (zero) | Maximum number of concurrent connections
63 | 'domain' | domain name | _(none)_ | '-s' | DNS domain handed out to DHCP clients
64 | 'domainneeded' | boolean | '0' | '-D' | Tells _dnsmasq_ never to forward queries for plain names, without dots or domain parts, to upstream nameservers. If the name is not known from /etc/hosts or DHCP then a "not found" answer is returned
65 | 'dnssec' | boolean | '0' | --dnssec | Validate DNS replies and cache DNSSEC data. *CAUTION*: Requires the _dnsmasq-full_ package.
66 | 'dnsseccheckunsigned' | boolean | '0' | --dnssec-check-unsigned | Check the zones of unsigned replies to ensure that unsigned replies are allowed in those zones. This protects against an attacker forging unsigned replies for signed DNS zones, but is slower and requires that the nameservers upstream of _dnsmasq_ are DNSSEC-capable. *CAUTION*: Requires the _dnsmasq-full_ package.
67 | 'ednspacket_max' | integer | '1280' | '-P' | Specify the largest EDNS.0 UDP packet which is supported by the DNS forwarder
68 | 'enable_tftp' | boolean | '0' | --enable-tftp | Enable the builtin TFTP server
69 | 'expandhosts' | boolean | '0' | '-E' | Add the local domain part to names found in '/etc/hosts'
70 | 'filterwin2k' | boolean | '0' | '-f' | Do not forward requests that cannot be answered by public name servers
71 | 'fqdn' | boolean | '0' | --dhcp-fqdn | Do not resolve unqualified local hostnames. Needs 'domain' to be set.
72 | 'interface' | list of interface names | _(all interfaces)_ | '-i' | List of interfaces to listen on. If unspecified, _dnsmasq_ will listen to all interfaces except those listed in 'notinterface'. Note that _dnsmasq_ listens on loopback by default.
73 | 'leasefile' | file path | _(none)_ | '-l' (ell) | Store DHCP leases in this file
74 | 'local' | string | _(none)_ | '-S' | Look up DNS entries for this domain from '/etc/hosts'. This follows the same syntax as 'server' entries, see the man page.
75 | 'localise_queries' | boolean | '0' | '-y' | Choose IP address to match the incoming interface if multiple addresses are assigned to a host name in '/etc/hosts'. *CAUTION*: Note well the spelling of this option.
76 | 'localservice' | boolean | '1' | --local-service | Accept DNS queries only from hosts whose address is on a local subnet, ice. a subnet for which an interface exists on the server.
77 | 'logqueries' | boolean | '0' | '-q' | Log the results of DNS queries, dump cache on SIGUSR1
78 | 'nodaemon' | boolean | '0' | '-d' | Don't daemonize the _dnsmasq_ process
79 | 'nohosts' | boolean | '0' | '-h' | Don't read DNS names from '/etc/hosts'
80 | 'nonegcache' | boolean | '0' | '-N' | Disable caching of negative "no such domain" responses
81 | 'noresolv' | boolean | '0' | '-R' | Don't read upstream servers from '/etc/resolv.conf'
82 | 'notinterface' | list of interface names | _(none)_ | '-I' (eye) | Interfaces _dnsmasq_ should not listen on.
83 | 'nonwildcard' | boolean | '0' | '-z' | Bind only configured interface addresses, instead of the wildcard address.
84 | 'port' | port number | '53' | '-p' | Listening port for DNS queries, disables DNS server functionality if set to '0'
85 | 'queryport' | integer | _(none)_ | '-Q' | Use a fixed port for outbound DNS queries
86 | 'readethers' | boolean | '0' | '-Z' | Read static lease entries from '/etc/ethers', re-read on SIGHUP
87 | 'rebind_protection' | boolean | '1' | --stop-dns-rebind | Enables DNS rebind attack protection by discarding upstream RFC1918 responses
88 | 'rebind_localhost' | boolean | '0' | --rebind-localhost-ok | Allows upstream 127.0.0.0/8 responses, required for DNS based blacklist services, only takes effect if rebind protection is enabled
89 | 'rebind_domain' | list of domain names | _(none)_ | --rebind-domain-ok | List of domains to allow RFC1918 responses for, only takes effect if rebind protection is enabled
90 | 'resolvfile' | file path | '/etc/resolv.conf' | '-r' | Specifies an alternative resolv file
91 | 'server' | list of strings | _(none)_ | '-S' | List of DNS servers to forward requests to. See the _dnsmasq_ man page for syntax details.
92 | 'strictorder' | boolean | '0' | '-o' | Obey order of DNS servers in '/etc/resolv.conf'
93 | 'tftp_root' | directory path | _(none)_ | --tftp-root | Specifies the TFTP root directory
94 |====
95
96 === DHCP Pools
97
98 Sections of the type 'dhcp' specify per interface lease pools and settings for serving DHCP requests. Typically there is at least one section of this type present in the '/etc/config/dhcp' file to cover the lan interface.
99
100 You can disable a lease pool for a specific interface by specifying the 'ignore' option in the corresponding section.
101
102 A minimal example of a 'dhcp' section is listed below:
103
104 ----
105 config 'dhcp' 'lan'
106 option 'interface' 'lan'
107 option 'start' '100'
108 option 'limit' '150'
109 option 'leasetime' '12h'
110 option ra server
111 option dhcpv6 server
112 ----
113
114 * 'lan' specifies the LEDE interface that is served by this DHCP pool
115 * '100' is the offset from the network address, in the default configuration this would mean start leasing addresses from '192.168.1.100'
116 * '150' is the maximum number of addresses that may be leased, in the default configuration this would mean leasing addresses up to '192.168.1.250'
117 * '12h' specifies the time to live for handed out leases, twelve hours in this example
118 * 'server' defines the mode for IPv6 configuration (RA & DHCPv6)
119
120 Below is a listing of legal options for 'dhcp' sections.
121
122 [cols="4*1,4",options="header"]
123 |====
124 | Name | Type | Required | Default | Description
125 | 'dhcp_option' | list of strings | no | _(none)_ | The ID dhcp_option here must be with written with an underscore. The init script will translate this to --dhcp-option, with a hyphen, as ultimately used by dnsmasq. Multiple option values can be given for this _network-id_, with a a space between them and the total string between "". E.g. '26,1470' or 'option:mtu, 1470' that can assign an MTU per DHCP. Your client must accept MTU by DHCP for this to work. Or "3,192.168.1.1 6,192.168.1.1" to give out gateway and dns server addresses.
126 | 'dynamicdhcp' | boolean | no | '1' | Dynamically allocate client addresses, if set to '0' only clients present in the 'ethers' files are served
127 | 'force' | boolean | no | '0' | Forces DHCP serving on the specified interface even if another DHCP server is detected on the same network segment
128 | 'ignore' | boolean | no | '0' | Specifies whether _dnsmasq_ should ignore this pool if set to '1'
129 | 'dhcpv6' | string | no | 'none' | Specifies whether DHCPv6 server should be enabled ('server'), relayed ('relay') or disabled ('disabled')
130 | 'ra' | string | no | 'none' | Specifies whether Router Advertisements should be enabled ('server'), relayed ('relay') or disabled ('disabled')
131 | 'ndp' | string | no | 'none' | Specifies whether NDP should be relayed 'relay' or disabled 'none'
132 | 'master' | boolean | no | 0 | Specifies whether DHCPv6, RA and NDP in relay mode is a master interface or not.
133 | 'interface' | logical interface name | yes | _(none)_ | Specifies the interface associated with this DHCP address pool; must be one of the interfaces defined in '/etc/config/network'.
134 | 'leasetime' | string | yes | '12h' | Specifies the lease time of addresses handed out to clients, for example '12h' or '30m'
135 | 'limit' | integer | yes | '150' | Specifies the size of the address pool (e.g. with start=100, limit=150, maximum address will be .249)
136 | 'networkid' | string | no | _(value of 'interface')_ | The dhcp functionality defined in the dhcp section is limited to the interface indicated here through its _network-id_. In case omitted the system tries to know the network-id via the 'interface' setting in this dhcp section, through consultation of /etc/config/network. Some IDs get assigned dynamically, are not provided by network, but still can be set here.
137 | 'start' | integer | yes | '100' | Specifies the offset from the network address of the underlying interface to calculate the minimum address that may be leased to clients. It may be greater than 255 to span subnets.
138 |====
139
140 Notes:
141
142 * Although called 'interface', this is the network name, i.e. lan, wan, wifi etc. (section names in /etc/config/network), NOT the interface name used internally, like eth0, eth1, wlan0 etc. (the 'ifname' IDs in /etc/config/network).
143 * Although called 'networkid', this is the interface name used internally, i.e. eth0, eth1, wlan0 etc., not the network name (lan, wan, wifi etc.).
144 This departs from 'ifname' and 'network' as used in /etc/config/network and in /etc/config/wireless, so double check!
145
146 === Static Leases
147
148 You can assign fixed IP addresses to hosts on your network, based on their MAC (hardware) address.
149
150 The configuration options in this section are used to construct a '-G' option for _dnsmasq_.
151
152 ----
153 config host
154 option ip '192.168.1.2'
155 option mac '00:11:22:33:44:55'
156 option name 'mypc'
157 ----
158 This adds the fixed IP address 192.168.1.2 and the name "mypc" for a machine with the (Ethernet) hardware address 00:11:22:33:44:55.
159
160 ----
161 config host
162 option ip '192.168.1.3'
163 option mac '11:22:33:44:55:66 aa:bb:cc:dd:ee:ff'
164 option name 'mylaptop'
165 ----
166 This adds the fixed IP address 192.168.1.3 and the name "mylaptop" for a machine with the (Ethernet) hardware address 11:22:33:44:55:66 or aa:bb:cc:dd:ee:ff. Note that this is **unreliable** if more than one of the listed mac addresses is on the network simultaneously. It's useful for cases such as a laptop with both wireless and wired interfaces, provided that only one will be active at a given time.
167
168 [cols="4*1,4",options="header"]
169 |====
170 | Name | Type | Required | Default | Description
171 | 'ip' | string | yes | _(none)_ | 'ignore' or the IP address to be used for this host.
172 | 'mac' | string | no | _(none)_ | The hardware address(es) of this host, separated by commas.
173 | 'hostid' | string | no | _(none)_ | The IPv6 interface identifier (address suffix) as hexadecimal number (max. 8 chars)
174 | 'duid' | string | no | _(none)_ | The DHCPv6-DUID of this host.
175 | 'name' | string | no | _(none)_ | Optional hostname to assign.
176 | 'tag' | string | no | _(none)_ | Set the given tag for matching hosts.
177 | 'dns' | boolean | no | '0' | Add static forward and reverse DNS entries for this host.
178 | 'broadcast' | boolean | no | '0' | Force broadcast DHCP response.
179 | 'leasetime' | string | no | _(none)_ | Host-specific lease time, e.g. 2m, 3h, 5d. Note: introduced by r48801 in trunk
180 |====
181
182 As well as adding 'host' sections, you can also enable the 'dnsmasq' section option 'readethers', and add entries to the '/etc/ethers' file.
183
184 === DHCP OPTION example to set an alternative default gateway
185
186 You can specify an alternative default Gateway
187
188 ----
189 config 'dhcp' 'lan'
190 option 'interface' 'lan'
191 option 'start' '100'
192 option 'limit' '150'
193 option 'leasetime' '12h'
194 list 'dhcp_option' '3,192.168.1.2'
195 ----
196
197 use the list 'dhcp_option' '3,192.168.1.2' to set the default gateway. A list of options can be found here link:http://www.networksorcery.com/enp/protocol/bootp/options.htm[here]
198
199 === Booting Options
200
201 Some hosts support booting over the network (PXE booting). DHCP/BOOTP is used to tell the host which file to boot and the server to load it from. Each client can only receive one set of filename and server address options. If different hosts should boot different files, or boot from different servers, you can use _network-ids_ to map options to each client.
202
203 Usually, you need to set additional DHCP options (through 'dhcp_option') for further stages of the boot process. See the _dnsmasq_ man page for details on the syntax of the 'O' option.
204
205 The configuration options in this section are used to construct a '-M' option for _dnsmasq_.
206
207 *Note*: odhcp currently lacks support root-path specification. If you need this functionality, disable odhcpd and use dnsmasq instead.
208
209 ----
210 config boot linux
211 option filename '/tftpboot/pxelinux.0'
212 option serveraddress '192.168.1.2'
213 option servername 'fileserver'
214 list dhcp_option 'option:root-path,192.168.1.2:/data/netboot/root'
215 ----
216 This tells the client to load pxelinux.0 from the server at 192.168.1.2, and mount root from /data/netboot/root on the same server.
217 [cols="4*1,4",options="header"]
218 |====
219 | Name | Type | Required | Default | Description
220 | 'dhcp_option' | list of strings | no | _(none)_ | Additional options to be added for this network-id. *CAUTION*: If you specify this, you also need to specify the network-id.
221 | 'filename' | string | yes | _(none)_ | The filename the host should request from the boot server.
222 | 'networkid' | string | no | _(none)_ | The network-id these boot options should apply to. Applies to all clients if left unspecified.
223 | 'serveraddress' | string | yes | _(none)_ | The IP address of the boot server.
224 | 'servername' | string | yes | _(none)_ | The hostname of the boot server.
225 | 'force' | bool | no | _(none)_ | dhcp-option will always be sent, even if the client does not ask for it in the parameter request list. This is sometimes needed, for example when sending options to PXELinux.
226 |====
227
228 === Classifying Clients And Assigning Individual Options
229
230 DHCP can provide the client with numerous options, such as the domain name, NTP servers, network booting options, etc. While some settings are applicable to all hosts in a network segment, other are more specific and apply only to a group of hosts, or even only a single one. _dnsmasq_ offers to group DHCP options and their values by a _network-id_, an alphanumeric identifier, and sending options only to hosts which have been tagged with that _network-id_.
231
232 In LEDE, you can tag hosts by the DHCP range they're in (section 'dhcp'), or a number of options the client might send with their DHCP request. In each of these sections, you can use the 'dhcp_option' list to add DHCP options to be sent to hosts with this _network-id_.
233
234 Each classifying section has two configuration options: the value of the DHCP option used to distinguish clients, and the _network-id_ that these clients should be tagged with. Here's a template:
235
236 ----
237 config _classifier_
238 option _classifier_ '_value_'
239 option networkid '_network-id_'
240 list dhcp_option '_DHCP-option_'
241 ----
242
243 The placeholder '_classifier_' can be one of these values:
244 [cols="1,4",options="header"]
245 |====
246 | Classifier | Description
247 | 'mac' | Hardware address of the client
248 | 'vendorclass' | String sent by the client representing the vendor of the client. _dnsmasq_ performs a substring match on the vendor class string using this value.
249 | 'userclass' | String sent by the client representing the user of the client. _dnsmasq_ performs a substring match on the user class string using this value.
250 | 'circuitid' | Matches the circuit ID as sent by the relay agent, as defined in RFC3046.
251 | 'remoteid' | Matches the remote ID as sent by the relay agent, as defined in RFC3046.
252 | 'subscrid' | Matches the subscriber ID as sent by the relay agent, as defined in RFC3993.
253 |====
254
255
256 An example using the 'mac' classifier to create a tagged network for openvpn would look like this in the config file:
257
258 ----
259 config mac 'opnvpn'
260 option mac '00:FF:*:*:*:*'
261 option networkid 'opnvpn'
262 list dhcp_option '3'
263 ----
264
265
266 And like this in UCI
267 ----
268 dhcp.opnvpn=mac
269 dhcp.opnvpn.mac=00:FF:*:*:*:*
270 dhcp.opnvpn.networkid=opnvpn
271 dhcp.opnvpn.dhcp_option=3
272 ----
273
274 _DHCP-option_ adds a DHCP option for this _network-id_. See the _dnsmasq_ man page for a complete explanation of the syntax of the '-O' option.
275
276 _force_ is a bool option. It forces dhcp-option to always be sent, even if the client does not ask for it in the parameter request list. This is sometimes needed, for example when sending options to PXELinux.
277
278
279 == Using plain dnsmasq.conf
280
281 It is possible to mix the traditional '/etc/dnsmasq.conf' configuration file with the options found in '/etc/config/dhcp'.
282
283 The 'dnsmasq.conf' file does not exist by default but will be processed by _dnsmasq_ on startup if it is present. Note that options in '/etc/config/dhcp' take precedence over 'dnsmasq.conf' since they are translated to command line arguments.
284
285 You can have 'dnsmasq' execute a script on every action:
286
287 ----
288 dhcp-script=/sbin/action.sh
289 ----
290
291 === DNS and DHCP Ports
292
293 DNS needs TCP and UDP port 53 open on the firewall. DHCP needs UDP ports 67 and 68 open from your zone to/from the firewall. See http://wiki.openwrt.org/doc/recipes/guest-wlan and http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html (viz "--dhcp-alternate-port") for more information.
294
295 == Examples
296
297 === Static Lease (MAC address hot swap)
298
299 Define a static lease for a host with MAC addresses '00:a0:24:5a:33:69' and '00:11:22:33:44:55' (handy when you use both wired and wireless connection on the same computer/laptop - of course, you can use just one MAC address) and assign the IP address '192.168.1.230' and the hostname 'example-host' to it. We call this _MAC address hot swap_, since IP address stay same, but MAC address changes.
300
301 ----
302 config 'host'
303 option 'name' 'example-host'
304 option 'ip' '192.168.1.230'
305 option 'mac' '00:a0:24:5a:33:69 00:11:22:33:44:55'
306 ----
307
308 === Troubleshooting ===
309
310 *CAUTION*: **Windows 7** has introduced a new _Microsoft-enhanced_ feature. It won't assign IP address obtained from a DHCP server to an interface, if the IP was used before for another interface, even if that other interface is **NOT** active currently (i.e. cable disconnected). This behaviour is unique and was not reported for older Windows versions, Mac OS nor Linux.
311
312 If you try configure MAC address hot swap on your router, Windows 7 clients will end up in an infinite link:http://tools.ietf.org/html/rfc1531#section-3.1[DORA] loop.
313
314 Solution:
315 - Create a bridge from the wireless and ethernet interfaces on your client
316
317 * it's trivial: google->windows 7 create bridge
318 * you will have to add the MAC address of the bridge to '/etc/config/dhcp'
319 *
320 ----
321 config 'host'
322 option 'name' 'example-host'
323 option 'ip' '192.168.1.230'
324 option 'mac' '00:a0:24:5a:33:69 00:11:22:33:44:55 02:a0:24:5a:33:69 02:11:22:33:44:55'
325 ----
326 * Since the bridge will probably take and alter your ethernet MAC address, you will lose SLAAC on wifi interface, making your laptop IPv6-disabled when only wireless is up.
327 - Another solution is IPv6 friendly, you don't need to create a bridge, nor add MAC address to dnsmasq config file, but it involves user interaction:
328 * When you plug the ethernet cable in, disable wireless interface in control panel (power off wireless won't do it).
329 * When you unplug ethernet cable, enable wireless and disable ethernet.
330
331 Notes:
332
333 * http://answers.microsoft.com/en-us/windows/forum/windows_7-networking/windows-7-refuses-dhcp-addresses-if-they-were/1b72b289-0f58-492f-afb8-e76c80a81f00
334 * _force_ is a bool option that will force dhcp-option to always be sent, even if the client does not ask for it in the parameter request list. This is sometimes needed, for example when sending options to PXELinux.
335
336 === Only allow static leases
337
338 If you want to distribute IPv4 addresses to known clients only (static leases), use:
339
340 ----
341 config dhcp 'lan'
342 ...
343 option dynamicdhcp 0
344 ----
345
346 With this, dnsmasq will consider static leases defined in "config host" blocks and in /etc/ethers, and refuse to hand out any IPv4 address to unknown clients.
347
348 Note that you shouldn't use this as a security feature to prevent unwanted clients from connecting. A client can simply configure a static IP in the right range to have access to the network.
349
350 === Custom Domain
351
352 Define a custom domain name and the corresponding PTR record - assigns the IP address '192.168.1.140' to the domain name 'typhoon' and construct an appropriate reverse record '140.1.168.192.in-addr.arpa'. It works like an entry in '/etc/hosts' but more flexible
353 and integrated.
354
355 ----
356 config 'domain'
357 option 'name' 'typhoon'
358 option 'ip' '192.168.1.140'
359 ----
360
361 another example: redirect www.example.com to 1.2.3.4
362 ----
363 config 'domain'
364 option 'name' 'www.example.com'
365 option 'ip' '1.2.3.4'
366 ----
367
368 === SRV RR for SIP
369
370 To define an SRV record for SIP over UDP, with the default port of 5060 on the host pbx.mydomain.com, with a class of 0 and a weight of 10 one would use:
371
372 ----
373 config 'srvhost'
374 option srv '_sip._udp.mydomain.com'
375 option target 'pbx.mydomain.com'
376 option port 5060
377 option class 0
378 option weight 10
379 ----
380
381 === CNAME RR
382
383 A Canonical Name record specifies that a domain name is an alias for another domain, the "canonical" domain. To specify that the web server also doubles as the FTP server, one might use:
384
385 ----
386 config 'cname'
387 option cname 'ftp.example.com'
388 option target 'www.example.com'
389 ----
390 Note that it is necessary to use fully qualified domain names.
391
392 === MX RR
393
394 If you're running the mail server for your domain behind a firewall (and therefore, with split-horizon for your own domain) then you might need to convince that mailer that it's actually authoritative for your domain.
395
396 If sendmail tells you "Domain of sender address xxx@yyy.zzz does not exist" this is because it isn't finding an MX record confirming that it's an MX relay for that domain.
397
398 Adding:
399
400 ----
401 config 'mxhost'
402 option domain 'yyy.zzz'
403 option relay 'my.host.com'
404 option pref 10
405 ----
406
407 will mitigate the issues caused by split-horizon.
408
409 === TFTP Boot
410
411 Direct BOOTP requests to the TFTP server at the IP address '192.168.1.2' and use '/tftpboot/pxelinux.0' as boot file name.
412
413 ----
414 config 'boot'
415 option 'filename' 'pxelinux.0'
416 option 'servername' 'data'
417 option 'serveraddress' '192.168.1.2'
418 ----
419
420 === Multiple DHCP options
421
422 Multiple DHCP options can be configured under a single dhcp_option object. In this case, option 66 (tftp-server) and option 150 (multiple tftp servers) were used for a Cisco Callmanager deployment.
423
424 ----
425 config 'dhcp' 'lan'
426 option 'interface' 'lan'
427 option 'start' '62'
428 option 'limit' '192'
429 option 'leasetime' '600h'
430 list 'dhcp_option' '66,172.16.60.64'
431 list 'dhcp_option' '150,172.16.60.64'
432 ----
433
434 === Multiple DHCP/DNS server/forwarder instances
435
436 If you need multiple DNS forwarders with different configurations or DHCP server with different sets of lease files,
437 have a look at this link:https:_dev.openwrt.org/ticket/8862[patch].
438 Multiple dnsmasq "named" instances can be configured:
439 ----
440 config 'dnsmasq' 'hotspot'
441 option nonwildcard '1' # Tell dnsmasq to bind specific address(es)
442 option resolvfile '/tmp/resolv.conf.hotspot'
443 ...
444 ----
445
446 Your configs are usually active for all instances, but you can limit them to single instances by:
447 ----
448 config 'dhcp' 'lan'
449 option 'interface' 'lan'
450 option 'dnsmasq_config' 'hotspot'
451
452 config 'host'
453 option 'name' 'chef'
454 option 'mac' '00:00:00:00:00:00'
455 option 'ip' '192.168.1.66'
456 option 'dnsmasq_config' 'hotspot'
457 ----
458
459 The web interface (luci) has not been updated for this patch yet.
460
461 === Assigning DHCP pool to a subnet in a large network
462
463 In DHCP pool limit setting, the start and limit values do *not* refer to the "last digit", they're relative offsets to the network address.
464 * the network address of 10.0.0.1 / 255.0.0.0 is 10.0.0.0
465 * the 10.22.0.1 start address is 22 x /16 subnets away: (2^16) * 22 = 1441792
466 * 10.0.0.0 + 1441792 + 1 = 10.22.0.1 -> start = 1441793
467 * 10.22.0.254 - 10.22.0.1 = 253 -> limit = 253
468
469 ----
470 config dhcp lan
471 option interface lan
472 option start 1441793
473 option limit 253
474 ----
475
476 Test:
477
478 ----
479 root@lede:~# ipcalc.sh 10.0.0.1 255.0.0.0 1441793 253
480 IP=10.0.0.1
481 NETMASK=255.0.0.0
482 BROADCAST=10.255.255.255
483 NETWORK=10.0.0.0
484 PREFIX=8
485 START=10.22.0.1
486 END=10.22.0.254
487 root@lede:~#
488 ----
489
490 === Classifying Clients And Assigning Individual Options
491
492 Assign different dhcp-options to a single MAC address:
493
494 ----
495 uci batch <<'EOF'
496 add dhcp mac
497 set dhcp.@mac[-1].mac=00:11:22:33:44:55
498 set dhcp.@mac[-1].networkid=someone
499 add_list dhcp.@mac[-1].dhcp_option=6,192.168.1.3,192.168.1.2,192.168.1.1
500 add_list dhcp.@mac[-1].dhcp_option=3,192.168.1.2
501 add_list dhcp.@mac[-1].dhcp_option=44,192.168.1.3
502 commit dhcp
503 EOF
504 uci commit dhcp
505 /etc/init.d/dnsmasq reload
506 ----
507 Where 6=DNS, 3=Default Gateway, 44=WINS
508
509 Assign different dhcp-options to multiple hosts:
510
511 ----
512 config host
513 option name 'j400'
514 option mac '00:21:63:75:aa:17'
515 option ip '10.11.12.14'
516 option tag 'vpn' # assign tag "vpn" to this host
517
518 config host
519 option name 'j500'
520 option mac '01:22:64:76:bb:18'
521 option ip '10.11.12.15'
522 option tag 'vpn' # assign tag "vpn" to this host
523
524 config tag 'vpn' # match tag "vpn"
525 list dhcp_option '6,8.8.8.8,8.8.4.4' # assign arbitrary extra dhcp options to this tag
526 option force '1' #dhcp-option will always be sent, even if the client does not ask for it in the parameter request list. This is sometimes needed, for example when sending options to PXELinux.
527 ----
528
529 *CAUTION*: Specifying a dhcp option without any value, would disable that option. so for example you can use:
530 ----
531 list dhcp_option '3'
532 ----
533 to disable sending a default gateway to a specific client
534
535 === Enabling DHCP without enabling DNS
536
537 This is useful when you just want to hand out addresses to clients, without doing any DNS.
538
539 ----
540 config dnsmasq
541 ...
542 option port 0
543 option domain ''
544 ----
545
546 The second option prevents dnsmasq from giving out a domain name and DNS search list to clients: this is useless without DNS resolving.
547
548 Of course, you will want to hand out the address of a DNS resolver to clients:
549
550 ----
551 config dhcp lan
552 option interface lan
553 ...
554 list dhcp_option "6,80.67.188.188,6,80.67.169.12"
555 list dns "2001:913::8"
556 list dns "2001:910:800::12"
557 ----
558
559 The `dhcp_option` entry is meant for dnsmasq, while the more elegant `dns` entries are understood by odhcpd. By default, odhcpd is only used for IPv6, but if you also use odhcpd for IPv4, you can just use `dns` entries for everything.
560
561 === Several DNS servers
562
563 ----
564 config dnsmasq
565 option domainneeded '1'
566 option localise_queries '1'
567 option local '/lan/'
568 option domain 'lan'
569 option expandhosts '1'
570 option authoritative '1'
571 option readethers '1'
572 option leasefile '/tmp/dhcp.leases'
573 option resolvfile '/tmp/resolv.conf.auto'
574 list server '/subdomain.example.com/192.0.2.1'
575 #be careful that some options should be absent (or set to False)
576 #to allow the forwarding towards the "so defined" private networks
577 #http://en.wikipedia.org/wiki/Private_network
578 # likely 'bogusprivat'
579 list server '/example.com/208.67.222.222'
580 option rebind_protection '0'
581 ----
582
583 === Conditional DNS Forwarding for Windows Active Directory Domains / DNS Dependent Directory Based Authentication Services
584
585 1. Install dnsmasq using your local package manager
586 2. Edit /etc/dnsmasq.conf
587 . Tells dnsmasq to forward anything with the domain of remote.local to dns server 10.25.11.2
588 server=/remote.local/10.25.11.2
589 . Listen to requests only coming from the local machine
590 listen-address=127.0.0.1
591 . Do not cache anything
592 . A decent dns server will already cache for your local network
593 cache-size=0
594 3. Edit /etc/resolv.conf
595
596 . Local LAN Domain
597 domain ion.lan
598
599 . local dnsmasq server
600 nameserver 127.0.0.1
601
602 . Your main dns server (dnsmasq will forward all requests to this server)
603 nameserver 10.20.1.1
604 4. Start dnsmasq
605
606 5. Test – ping a local server and remote server using the FQDN
607
608 All dns requests will be forwarded to 10.20.1.1 except any matching *.remote.local. server.remote.local will be forwarded to 10.25.11.2
609
610 Credit: link:http://pyther.net/2010/12/dns-conditional-forwarding-dnsmasq/[here]
611
612 ----
613
614 cat /etc/config/dhcp
615
616 config dnsmasq
617 option localise_queries '1'
618 option rebind_protection '0'
619 option authoritative '1'
620 option leasefile '/tmp/dhcp.leases'
621 option localservice '1'
622 option dnssec '0'
623 option cachesize '0'
624 option domain 'example.local'
625 option readethers '1'
626 option logqueries '1'
627 option fliterwin2k '0'
628 #Define your Domain and Domain Controllers IP address here.
629 option local '/example.local/192.168.1.X'**
630 list server '/0.openwrt.pool.ntp.org/8.8.8.8'
631 list server '/1.openwrt.pool.ntp.org/8.8.8.8'
632 list server '/2.openwrt.pool.ntp.org/8.8.8.8'
633 list server '/3.openwrt.pool.ntp.org/8.8.8.8'
634 option resolvfile '/etc/resolv.conf'
635 option boguspriv '1'
636
637 config dhcp 'lan'
638 option interface 'lan'
639 option start '100'
640 option limit '150'
641 option leasetime '12h'
642 ----
643 Almost completed, Now on to the finalisation of the /etc/resolv.conf Traditionally /etc/resolv.conf is populated via symlink based on interface settings which get inserted via script into /tmp/resolv.conf. We're going to disable this symlink because without doing so it would override our static settings.
644
645 You'll want to remove /etc/resolv.conf
646 That will remove the resolv.conf symlink. Then we will add the ip address of the secondary DNS and external resolving address inside the /etc/resolv.conf file finally establishing conditional forwarding, something that should be specified for easy configuration via the GUI.
647
648 ----
649 rm /etc/resolv.conf
650 echo "domain example.local">>/etc/resolv.conf
651 echo "nameserver 127.0.0.1">>/etc/resolv.conf
652 echo "nameserver 208.67.220.220">>/etc/resolv.conf
653
654 ----
655
656 ----
657
658 cat /etc/resolv.conf
659 #Define your Domain Below & Public DNS you desire.
660
661 domain example.local
662 nameserver 127.0.0.1
663 nameserver 208.67.220.220
664
665 ----