diff options
Diffstat (limited to 'man/dnsmasq.8')
-rw-r--r-- | man/dnsmasq.8 | 1081 |
1 files changed, 921 insertions, 160 deletions
diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 index 511f57f..c8913b5 100644 --- a/man/dnsmasq.8 +++ b/man/dnsmasq.8 @@ -6,24 +6,31 @@ dnsmasq \- A lightweight DHCP and caching DNS server. .I [OPTION]... .SH "DESCRIPTION" .BR dnsmasq -is a lightweight DNS, TFTP and DHCP server. It is intended to provide +is a lightweight DNS, TFTP, PXE, router advertisement and DHCP server. It is intended to provide coupled DNS and DHCP service to a LAN. .PP Dnsmasq accepts DNS queries and either answers them from a small, local, cache or forwards them to a real, recursive, DNS server. It loads the contents of /etc/hosts so that local hostnames which do not appear in the global DNS can be resolved and also answers -DNS queries for DHCP configured hosts. +DNS queries for DHCP configured hosts. It can also act as the +authoritative DNS server for one or more domains, allowing local names +to appear in the global DNS. It can be configured to do DNSSEC +validation. .PP The dnsmasq DHCP server supports static address assignments and multiple networks. It automatically sends a sensible default set of DHCP options, and can be configured to send any desired set of DHCP options, including vendor-encapsulated options. It includes a secure, read-only, -TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP. +TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP. The PXE support is full featured, and includes a proxy mode which supplies PXE information to clients whilst DHCP address allocation is done by another server. .PP -Dnsmasq -supports IPv6 for DNS and TFTP, but not DHCP. +The dnsmasq DHCPv6 server provides the same set of features as the +DHCPv4 server, and in addition, it includes router advertisements and +a neat feature which allows nameing for clients which use DHCPv4 and +stateless autoconfiguration only for IPv6 configuration. There is support for doing address allocation (both DHCPv6 and RA) from subnets which are dynamically delegated via DHCPv6 prefix delegation. +.PP +Dnsmasq is coded with small embedded systems in mind. It aims for the smallest possible memory footprint compatible with the supported functions, and allows uneeded functions to be omitted from the compiled binary. .SH OPTIONS Note that in general missing parameters are allowed and switch off functions, for instance "--pid-file" disables writing a PID file. On @@ -43,6 +50,10 @@ Additional hosts file. Read the specified file as well as /etc/hosts. If -h is g only the specified file. This option may be repeated for more than one additional hosts file. If a directory is given, then read all the files contained in that directory. .TP +.B --hostsdir=<path> +Read all the hosts files contained in the directory. New or changed files +are read automatically. See --dhcp-hostsdir for details. +.TP .B \-E, --expand-hosts Add the domain to simple names (without a period) in /etc/hosts in the same way as for DHCP-derived names. Note that this does not @@ -51,7 +62,7 @@ apply to domain names in cnames, PTR records, TXT records etc. .B \-T, --local-ttl=<time> When replying with information from /etc/hosts or the DHCP leases file dnsmasq by default sets the time-to-live field to zero, meaning -that the requestor should not itself cache the information. This is +that the requester should not itself cache the information. This is the correct thing to do in almost all situations. This option allows a time-to-live (in seconds) to be given for these replies. This will reduce the load on the server at the expense of clients using stale @@ -71,6 +82,18 @@ maximum TTL will be given to clients instead of the true TTL value if it is lower. The true TTL value is however kept in the cache to avoid flooding the upstream DNS servers. .TP +.B --max-cache-ttl=<time> +Set a maximum TTL value for entries in the cache. +.TP +.B --min-cache-ttl=<time> +Extend short TTL values to the time given when caching them. Note that +artificially extending TTL values is in general a bad idea, do not do it +unless you have a good reason, and understand what you are doing. +Dnsmasq limits the value of this option to one hour, unless recompiled. +.TP +.B --auth-ttl=<time> +Set the TTL value returned in answers from the authoritative server. +.TP .B \-k, --keep-in-foreground Do not go into the background at startup but otherwise run as normal. This is intended for use when dnsmasq is run under daemontools @@ -80,10 +103,15 @@ or launchd. Debug mode: don't fork to the background, don't write a pid file, don't change user id, generate a complete cache dump on receipt on SIGUSR1, log to stderr as well as syslog, don't fork new processes -to handle TCP queries. +to handle TCP queries. Note that this option is for use in debugging +only, to stop dnsmasq daemonising in production, use +.B -k. .TP .B \-q, --log-queries -Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1. +Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1. If the argument "extra" is supplied, ie +.B --log-queries=extra +then the log has extra information at the start of each line. +This consists of a serial number which ties together the log lines associated with an individual query, and the IP address of the requestor. .TP .B \-8, --log-facility=<facility> Set the facility to which dnsmasq will send syslog entries, this @@ -162,7 +190,12 @@ options. IP alias interfaces (eg "eth1:0") cannot be used with .B --interface or .B --except-interface -options, use --listen-address instead. +options, use --listen-address instead. A simple wildcard, consisting +of a trailing '*', can be used in +.B \--interface +and +.B \--except-interface +options. .TP .B \-I, --except-interface=<interface name> Do not listen on the specified interface. Note that the order of @@ -173,6 +206,29 @@ and options does not matter and that .B --except-interface options always override the others. +.TP +.B --auth-server=<domain>,<interface>|<ip-address> +Enable DNS authoritative mode for queries arriving at an interface or address. Note that the interface or address +need not be mentioned in +.B --interface +or +.B --listen-address +configuration, indeed +.B --auth-server +will overide these and provide a different DNS service on the +specified interface. The <domain> is the "glue record". It should +resolve in the global DNS to a A and/or AAAA record which points to +the address dnsmasq is listening on. When an interface is specified, +it may be qualified with "/4" or "/6" to specify only the IPv4 or IPv6 +addresses associated with the interface. +.TP +.B --local-service +Accept DNS queries only from hosts whose address is on a local subnet, +ie a subnet for which an interface exists on the server. This option +only has effect is there are no --interface --except-interface, +--listen-address or --auth-server options. It is intended to be set as +a default on installation, to allow unconfigured installations to be +useful but also safe from being used for DNS amplification attacks. .TP .B \-2, --no-dhcp-interface=<interface name> Do not provide DHCP or TFTP on the specified interface, but do provide DNS service. @@ -204,6 +260,17 @@ running another nameserver (or another instance of dnsmasq) on the same machine. Setting this option also enables multiple instances of dnsmasq which provide DHCP service to run in the same machine. .TP +.B --bind-dynamic +Enable a network mode which is a hybrid between +.B --bind-interfaces +and the default. Dnsmasq binds the address of individual interfaces, +allowing multiple dnsmasq instances, but if new interfaces or +addresses appear, it automatically listens on those (subject to any +access-control configuration). This makes dynamically created +interfaces work in the same way as the default. Implementing this +option requires non-standard networking APIs and it is only available +under Linux. On other platforms it falls-back to --bind-interfaces mode. +.TP .B \-y, --localise-queries Return answers to DNS queries from /etc/hosts which depend on the interface over which the query was received. If a name in /etc/hosts has more than one address associated with @@ -239,6 +306,12 @@ an advertising web page in response to queries for unregistered names, instead of the correct NXDOMAIN response. This option tells dnsmasq to fake the correct response when it sees this behaviour. As at Sept 2003 the IP address being returned by Verisign is 64.94.110.11 +.TP +.B \-B, --ignore-address=<ipaddr> +Ignore replies to A-record queries which include the specified address. +No error is generated, dnsmasq simply continues to listen for another reply. +This is useful to defeat blocking strategies which rely on quickly supplying a +forged answer to a DNS request for certain domain, before the correct answer can arrive. .TP .B \-f, --filterwin2k Later versions of windows make periodic DNS requests which don't get sensible answers from @@ -249,8 +322,8 @@ requested name has underscores, to catch LDAP requests. .B \-r, --resolv-file=<file> Read the IP addresses of the upstream nameservers from <file>, instead of /etc/resolv.conf. For the format of this file see -.BR resolv.conf (5) -the only lines relevant to dnsmasq are nameserver ones. Dnsmasq can +.BR resolv.conf (5). +The only lines relevant to dnsmasq are nameserver ones. Dnsmasq can be told to poll more than one resolv.conf file, the first file name specified overrides the default, subsequent ones add to the list. This is only allowed when polling; the file with the currently latest modification @@ -260,11 +333,13 @@ time is the one used. Don't read /etc/resolv.conf. Get upstream servers only from the command line or the dnsmasq configuration file. .TP -.B \-1, --enable-dbus +.B \-1, --enable-dbus[=<service-name>] Allow dnsmasq configuration to be updated via DBus method calls. The configuration which can be changed is upstream DNS servers (and corresponding domains) and cache clear. Requires that dnsmasq has -been built with DBus support. +been built with DBus support. If the service name is given, dnsmasq +provides service at that name, rather than the default which is +.B uk.org.thekelleys.dnsmasq .TP .B \-o, --strict-order By default, dnsmasq will send queries to any of the upstream servers @@ -276,7 +351,17 @@ server strictly in the order they appear in /etc/resolv.conf By default, when dnsmasq has more than one upstream server available, it will send queries to just one server. Setting this flag forces dnsmasq to send all queries to all available servers. The reply from -the server which answers first will be returned to the original requestor. +the server which answers first will be returned to the original requester. +.TP +.B --dns-loop-detect +Enable code to detect DNS forwarding loops; ie the situation where a query sent to one +of the upstream server eventually returns as a new query to the dnsmasq instance. The +process works by generating TXT queries of the form <hex>.test and sending them to +each upstream server. The hex is a UID which encodes the instance of dnsmasq sending the query +and the upstream server to which it was sent. If the query returns to the server which sent it, then +the upstream server through which it was sent is disabled and this event is logged. Each time the +set of upstream servers changes, the test is re-run on all of them, including ones which +were previously disabled. .TP .B --stop-dns-rebind Reject (and log) addresses from upstream nameservers which are in the @@ -298,12 +383,13 @@ by '/', like the --server syntax, eg. Don't poll /etc/resolv.conf for changes. .TP .B --clear-on-reload -Whenever /etc/resolv.conf is re-read, clear the DNS cache. +Whenever /etc/resolv.conf is re-read or the upstream servers are set +via DBus, clear the DNS cache. This is useful when new nameservers may have different data than that held in cache. .TP .B \-D, --domain-needed -Tells dnsmasq to never forward queries for plain names, without dots +Tells dnsmasq to never forward A or AAAA 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. .TP @@ -350,6 +436,9 @@ is a synonym for .B server to make configuration files clearer in this case. +IPv6 addresses may include a %interface scope-id, eg +fe80::202:a412:4512:7bbf%eth0. + The optional string after the @ character tells dnsmasq how to set the source of the queries to this nameserver. It should be an ip-address, which should belong to the machine on which @@ -363,7 +452,15 @@ source address specified but the port may be specified directly as part of the source address. Forcing queries to an interface is not implemented on all platforms supported by dnsmasq. .TP -.B \-A, --address=/<domain>/[domain/]<ipaddr> +.B --rev-server=<ip-address>/<prefix-len>,<ipaddr>[#<port>][@<source-ip>|<interface>[#<port>]] +This is functionally the same as +.B --server, +but provides some syntactic sugar to make specifying address-to-name queries easier. For example +.B --rev-server=1.2.3.0/24,192.168.0.1 +is exactly equivalent to +.B --server=/3.2.1.in-addr.arpa/192.168.0.1 +.TP +.B \-A, --address=/<domain>/[domain/][<ipaddr>] Specify an IP address to return for any host in the given domains. Queries in the domains are never forwarded and always replied to with the specified IP address which may be IPv4 or IPv6. To give @@ -375,7 +472,16 @@ domain specification works in the same was as for --server, with the additional facility that /#/ matches any domain. Thus --address=/#/1.2.3.4 will always return 1.2.3.4 for any query not answered from /etc/hosts or DHCP and not sent to an upstream -nameserver by a more specific --server directive. +nameserver by a more specific --server directive. As for --server, +one or more domains with no address returns a no-such-domain answer, so +--address=/example.com/ is equivalent to --server=/example.com/ and returns +NXDOMAIN for example.com and all its subdomains. +.TP +.B --ipset=/<domain>/[domain/]<ipset>[,<ipset>] +Places the resolved IP addresses of queries for the specified domains +in the specified netfilter ip sets. Domains and subdomains are matched +in the same way as --address. These ip sets must already exist. See +ipset(8) for more details. .TP .B \-m, --mx-host=<mx name>[[,<hostname>],<preference>] Return an MX record named <mx name> pointing to the given hostname (if @@ -413,6 +519,24 @@ zone files: the port, weight and priority numbers are in a different order. More than one SRV record for a given service/domain is allowed, all that match are returned. .TP +.B --host-record=<name>[,<name>....],[<IPv4-address>],[<IPv6-address>] +Add A, AAAA and PTR records to the DNS. This adds one or more names to +the DNS with associated IPv4 (A) and IPv6 (AAAA) records. A name may +appear in more than one +.B host-record +and therefore be assigned more than one address. Only the first +address creates a PTR record linking the address to the name. This is +the same rule as is used reading hosts-files. +.B host-record +options are considered to be read before host-files, so a name +appearing there inhibits PTR-record creation if it appears in +hosts-file also. Unlike hosts-files, names are not expanded, even when +.B expand-hosts +is in effect. Short and long names may appear in the same +.B host-record, +eg. +.B --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100 +.TP .B \-Y, --txt-record=<name>[[,<text>],<text>] Return a TXT DNS record. The value of TXT record is a set of strings, so any number may be included, delimited by commas; use quotes to put @@ -429,21 +553,47 @@ Return an NAPTR DNS record, as specified in RFC3403. Return a CNAME record which indicates that <cname> is really <target>. There are significant limitations on the target; it must be a DNS name which is known to dnsmasq from /etc/hosts (or additional -hosts files) or from DHCP. If the target does not satisfy this +hosts files), from DHCP, from --interface-name or from another +.B --cname. +If the target does not satisfy this criteria, the whole cname is ignored. The cname must be unique, but it is permissable to have more than one cname pointing to the same target. .TP -.B --interface-name=<name>,<interface> +.B --dns-rr=<name>,<RR-number>,[<hex data>] +Return an arbitrary DNS Resource Record. The number is the type of the +record (which is always in the C_IN class). The value of the record is +given by the hex data, which may be of the form 01:23:45 or 01 23 45 or +012345 or any mixture of these. +.TP +.B --interface-name=<name>,<interface>[/4|/6] Return a DNS record associating the name with the primary address on -the given interface. This flag specifies an A record for the given +the given interface. This flag specifies an A or AAAA record for the given name in the same way as an /etc/hosts line, except that the address is -not constant, but taken from the given interface. If the interface is +not constant, but taken from the given interface. The interface may be +followed by "/4" or "/6" to specify that only IPv4 or IPv6 addresses +of the interface should be used. If the interface is down, not configured or non-existent, an empty record is returned. The matching PTR record is also created, mapping the interface address to the name. More than one name may be associated with an interface address by repeating the flag; in that case the first instance is used for the reverse address-to-name mapping. .TP +.B --synth-domain=<domain>,<address range>[,<prefix>] +Create artificial A/AAAA and PTR records for an address range. The +records use the address, with periods (or colons for IPv6) replaced +with dashes. + +An example should make this clearer. +.B --synth-domain=thekelleys.org.uk,192.168.0.0/24,internal- +will result in a query for internal-192-168-0-56.thekelleys.org.uk returning +192.168.0.56 and a reverse query vice versa. The same applies to IPv6, +but IPv6 addresses may start with '::' +but DNS labels may not start with '-' so in this case if no prefix is +configured a zero is added in front of the label. ::1 becomes 0--1. + +The address range can be of the form +<ip address>,<ip address> or <ip address>/<netmask> +.TP .B --add-mac Add the MAC address of the requestor to DNS queries which are forwarded upstream. This may be used to DNS filtering by the upstream @@ -451,7 +601,20 @@ server. The MAC address can only be added if the requestor is on the same subnet as the dnsmasq server. Note that the mechanism used to achieve this (an EDNS0 option) is not yet standardised, so this should be considered experimental. Also note that exposing MAC addresses in this way may -have security and privacy implications. +have security and privacy implications. The warning about caching +given for --add-subnet applies to --add-mac too. +.TP +.B --add-subnet[[=<IPv4 prefix length>],<IPv6 prefix length>] +Add the subnet address of the requestor to the DNS queries which are +forwarded upstream. The amount of the address forwarded depends on the +prefix length parameter: 32 (128 for IPv6) forwards the whole address, +zero forwards none of it but still marks the request so that no +upstream nameserver will add client address information either. The +default is zero for both IPv4 and IPv6. Note that upstream nameservers +may be configured to return different results based on this +information, but the dnsmasq cache does not take account. If a dnsmasq +instance is configured such that different results may be encountered, +caching should be disabled. .TP .B \-c, --cache-size=<cachesize> Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching. @@ -467,21 +630,127 @@ Set the maximum number of concurrent DNS queries. The default value is where this needs to be increased is when using web-server log file resolvers, which can generate large numbers of concurrent queries. .TP +.B --dnssec +Validate DNS replies and cache DNSSEC data. When forwarding DNS queries, dnsmasq requests the +DNSSEC records needed to validate the replies. The replies are validated and the result returned as +the Authenticated Data bit in the DNS packet. In addition the DNSSEC records are stored in the cache, making +validation by clients more efficient. Note that validation by clients is the most secure DNSSEC mode, but for +clients unable to do validation, use of the AD bit set by dnsmasq is useful, provided that the network between +the dnsmasq server and the client is trusted. Dnsmasq must be compiled with HAVE_DNSSEC enabled, and DNSSEC +trust anchors provided, see +.B --trust-anchor. +Because the DNSSEC validation process uses the cache, it is not +permitted to reduce the cache size below the default when DNSSEC is +enabled. The nameservers upstream of dnsmasq must be DNSSEC-capable, +ie capable of returning DNSSEC records with data. If they are not, +then dnsmasq will not be able to determine the trusted status of +answers. In the default mode, this menas that all replies will be +marked as untrusted. If +.B --dnssec-check-unsigned +is set and the upstream servers don't support DNSSEC, then DNS service will be entirely broken. +.TP +.B --trust-anchor=[<class>],<domain>,<key-tag>,<algorithm>,<digest-type>,<digest> +Provide DS records to act a trust anchors for DNSSEC +validation. Typically these will be the DS record(s) for Zone Signing +key(s) of the root zone, +but trust anchors for limited domains are also possible. The current +root-zone trust anchors may be downloaded from https://data.iana.org/root-anchors/root-anchors.xml +.TP +.B --dnssec-check-unsigned +As a default, dnsmasq does not check that unsigned DNS replies are +legitimate: they are assumed to be valid and passed on (without the +"authentic data" bit set, of course). This does not protect against an +attacker forging unsigned replies for signed DNS zones, but it is +fast. If this flag is set, dnsmasq will check the zones of unsigned +replies, to ensure that unsigned replies are allowed in those +zones. The cost of this is more upstream queries and slower +performance. See also the warning about upstream servers in the +section on +.B --dnssec +.TP +.B --dnssec-no-timecheck +DNSSEC signatures are only valid for specified time windows, and should be rejected outside those windows. This generates an +interesting chicken-and-egg problem for machines which don't have a hardware real time clock. For these machines to determine the correct +time typically requires use of NTP and therefore DNS, but validating DNS requires that the correct time is already known. Setting this flag +removes the time-window checks (but not other DNSSEC validation.) only until the dnsmasq process receives SIGHUP. The intention is +that dnsmasq should be started with this flag when the platform determines that reliable time is not currently available. As soon as +reliable time is established, a SIGHUP should be sent to dnsmasq, which enables time checking, and purges the cache of DNS records +which have not been throughly checked. +.TP +.B --dnssec-timestamp=<path> +Enables an alternative way of checking the validity of the system time for DNSSEC (see --dnssec-no-timecheck). In this case, the +system time is considered to be valid once it becomes later than the timestamp on the specified file. The file is created and +its timestamp set automatically by dnsmasq. The file must be stored on a persistent filesystem, so that it and its mtime are carried +over system restarts. The timestamp file is created after dnsmasq has dropped root, so it must be in a location writable by the +unprivileged user that dnsmasq runs as. +.TP .B --proxy-dnssec -A resolver on a client machine can do DNSSEC validation in two ways: it -can perform the cryptograhic operations on the reply it receives, or -it can rely on the upstream recursive nameserver to do the validation -and set a bit in the reply if it succeeds. Dnsmasq is not a DNSSEC -validator, so it cannot perform the validation role of the recursive nameserver, -but it can pass through the validation results from its own upstream -nameservers. This option enables this behaviour. You should only do -this if you trust all the configured upstream nameservers -.I and the network between you and them. -If you use the first DNSSEC mode, validating resolvers in clients, -this option is not required. Dnsmasq always returns all the data -needed for a client to do validation itself. -.TP -.B \-F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<start-addr>,<end-addr>[,<netmask>[,<broadcast>]][,<lease time>] +Copy the DNSSEC Authenticated Data bit from upstream servers to downstream clients and cache it. This is an +alternative to having dnsmasq validate DNSSEC, but it depends on the security of the network between +dnsmasq and the upstream servers, and the trustworthiness of the upstream servers. +.TP +.B --dnssec-debug +Set debugging mode for the DNSSEC validation, set the Checking Disabled bit on upstream queries, +and don't convert replies which do not validate to responses with +a return code of SERVFAIL. Note that +setting this may affect DNS behaviour in bad ways, it is not an +extra-logging flag and should not be set in production. +.TP +.B --auth-zone=<domain>[,<subnet>[/<prefix length>][,<subnet>[/<prefix length>].....]] +Define a DNS zone for which dnsmasq acts as authoritative server. Locally defined DNS records which are in the domain +will be served. If subnet(s) are given, A and AAAA records must be in one of the +specified subnets. + +As alternative to directly specifying the subnets, it's possible to +give the name of an interface, in which case the subnets implied by +that interface's configured addresses and netmask/prefix-length are +used; this is useful when using constructed DHCP ranges as the actual +address is dynamic and not known when configuring dnsmasq. The +interface addresses may be confined to only IPv6 addresses using +<interface>/6 or to only IPv4 using <interface>/4. This is useful when +an interface has dynamically determined global IPv6 addresses which should +appear in the zone, but RFC1918 IPv4 addresses which should not. +Interface-name and address-literal subnet specifications may be used +freely in the same --auth-zone declaration. + +The subnet(s) are also used to define in-addr.arpa and +ip6.arpa domains which are served for reverse-DNS queries. If not +specified, the prefix length defaults to 24 for IPv4 and 64 for IPv6. +For IPv4 subnets, the prefix length should be have the value 8, 16 or 24 +unless you are familiar with RFC 2317 and have arranged the +in-addr.arpa delegation accordingly. Note that if no subnets are +specified, then no reverse queries are answered. +.TP +.B --auth-soa=<serial>[,<hostmaster>[,<refresh>[,<retry>[,<expiry>]]]] +Specify fields in the SOA record associated with authoritative +zones. Note that this is optional, all the values are set to sane defaults. +.TP +.B --auth-sec-servers=<domain>[,<domain>[,<domain>...]] +Specify any secondary servers for a zone for which dnsmasq is +authoritative. These servers must be configured to get zone data from +dnsmasq by zone transfer, and answer queries for the same +authoritative zones as dnsmasq. +.TP +.B --auth-peer=<ip-address>[,<ip-address>[,<ip-address>...]] +Specify the addresses of secondary servers which are allowed to +initiate zone transfer (AXFR) requests for zones for which dnsmasq is +authoritative. If this option is not given, then AXFR requests will be +accepted from any secondary. +.TP +.B --conntrack +Read the Linux connection track mark associated with incoming DNS +queries and set the same mark value on upstream traffic used to answer +those queries. This allows traffic generated by dnsmasq to be +associated with the queries which cause it, useful for bandwidth +accounting and firewalling. Dnsmasq must have conntrack support +compiled in and the kernel must have conntrack support +included and configured. This option cannot be combined with +--query-port. +.TP +.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-addr>[,<end-addr>][,<mode>][,<netmask>[,<broadcast>]][,<lease time>] +.TP +.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag>,]<start-IPv6addr>[,<end-IPv6addr>|constructor:<interface>][,<mode>][,<prefix-len>][,<lease time>] + Enable the DHCP server. Addresses will be given out from the range <start-addr> to <end-addr> and from statically defined addresses given in @@ -490,29 +759,71 @@ options. If the lease time is given, then leases will be given for that length of time. The lease time is in seconds, or minutes (eg 45m) or hours (eg 1h) or "infinite". If not given, the default lease time is one hour. The -minimum lease time is two minutes. This -option may be repeated, with different addresses, to enable DHCP +minimum lease time is two minutes. For IPv6 ranges, the lease time +maybe "deprecated"; this sets the preferred lifetime sent in a DHCP +lease or router advertisement to zero, which causes clients to use +other addresses, if available, for new connections as a prelude to renumbering. + +This option may be repeated, with different addresses, to enable DHCP service to more than one network. For directly connected networks (ie, networks on which the machine running dnsmasq has an interface) the -netmask is optional. It is, however, required for networks which -receive DHCP service via a relay agent. The broadcast address is +netmask is optional: dnsmasq will determine it from the interface +configuration. For networks which receive DHCP service via a relay +agent, dnsmasq cannot determine the netmask itself, so it should be +specified, otherwise dnsmasq will have to guess, based on the class (A, B or +C) of the network address. The broadcast address is always optional. It is always allowed to have more than one dhcp-range in a single subnet. +For IPv6, the parameters are slightly different: instead of netmask +and broadcast address, there is an optional prefix length which must +be equal to or larger then the prefix length on the local interface. If not +given, this defaults to 64. Unlike the IPv4 case, the prefix length is not +automatically derived from the interface configuration. The mimimum +size of the prefix length is 64. + +IPv6 (only) supports another type of range. In this, the start address and optional end address contain only the network part (ie ::1) and they are followed by +.B constructor:<interface>. +This forms a template which describes how to create ranges, based on the addresses assigned to the interface. For instance + +.B --dhcp-range=::1,::400,constructor:eth0 + +will look for addresses on +eth0 and then create a range from <network>::1 to <network>::400. If +the interface is assigned more than one network, then the +corresponding ranges will be automatically created, and then +deprecated and finally removed again as the address is deprecated and +then deleted. The interface name may have a final "*" wildcard. Note +that just any address on eth0 will not do: it must not be an +autoconfigured or privacy address, or be deprecated. + +If a dhcp-range is only being used for stateless DHCP and/or SLAAC, +then the address can be simply :: + +.B --dhcp-range=::,constructor:eth0 + + The optional .B set:<tag> sets an alphanumeric label which marks this network so that dhcp options may be specified on a per-network basis. When it is prefixed with 'tag:' instead, then its meaning changes from setting -a tag to matching it. Only one tag may be set, but more than one tag may be matched. -The end address may be replaced by the keyword +a tag to matching it. Only one tag may be set, but more than one tag +may be matched. + +The optional <mode> keyword may be .B static which tells dnsmasq to enable DHCP for the network specified, but not to dynamically allocate IP addresses: only hosts which have static addresses given via .B dhcp-host -or from /etc/ethers will be served. The end address may be replaced by -the keyword +or from /etc/ethers will be served. A static-only subnet with address +all zeros may be used as a "catch-all" address to enable replies to all +Information-request packets on a subnet which is provided with +stateless DHCPv6, ie +.B --dhcp-range=::,static + +For IPv4, the <mode> may be .B proxy in which case dnsmasq will provide proxy-DHCP on the specified subnet. (See @@ -521,15 +832,57 @@ and .B pxe-service for details.) -The interface:<interface name> section is not normally used. See the -NOTES section for details of this. +For IPv6, the mode may be some combination of +.B ra-only, slaac, ra-names, ra-stateless, ra-advrouter, off-link. + +.B ra-only +tells dnsmasq to offer Router Advertisement only on this subnet, +and not DHCP. + +.B slaac +tells dnsmasq to offer Router Advertisement on this subnet and to set +the A bit in the router advertisement, so that the client will use +SLAAC addresses. When used with a DHCP range or static DHCP address +this results in the client having both a DHCP-assigned and a SLAAC +address. + +.B ra-stateless +sends router advertisements with the O and A bits set, and provides a +stateless DHCP service. The client will use a SLAAC address, and use +DHCP for other configuration information. + +.B ra-names +enables a mode +which gives DNS names to dual-stack hosts which do SLAAC for +IPv6. Dnsmasq uses the host's IPv4 lease to derive the name, network +segment and MAC address and assumes that the host will also have an +IPv6 address calculated using the SLAAC algorithm, on the same network +segment. The address is pinged, and if a reply is received, an AAAA +record is added to the DNS for this IPv6 +address. Note that this is only happens for directly-connected +networks, (not one doing DHCP via a relay) and it will not work +if a host is using privacy extensions. +.B ra-names +can be combined with +.B ra-stateless +and +.B slaac. + +.B ra-advrouter +enables a mode where router address(es) rather than prefix(es) are included in the advertisements. +This is described in RFC-3775 section 7.2 and is used in mobile IPv6. In this mode the interval option +is also included, as described in RFC-3775 section 7.3. + +.B off-link +tells dnsmasq to advertise the prefix without the on-link (aka L) bit set. + .TP .B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore] Specify per host parameters for the DHCP server. This allows a machine with a particular hardware address to be always allocated the same hostname, IP address and lease time. A hostname specified like this overrides any supplied by the DHCP client on the machine. It is also -allowable to ommit the hardware address and include the hostname, in +allowable to omit the hardware address and include the hostname, in which case the IP address and lease times will apply to any machine claiming that name. For example .B --dhcp-host=00:20:e0:3b:13:af,wap,infinite @@ -547,14 +900,28 @@ the same subnet as some valid dhcp-range. For subnets which don't need a pool of dynamically allocated addresses, use the "static" keyword in the dhcp-range declaration. -It is allowed to use client identifiers rather than +It is allowed to use client identifiers (called client +DUID in IPv6-land rather than hardware addresses to identify hosts by prefixing with 'id:'. Thus: .B --dhcp-host=id:01:02:03:04,..... refers to the host with client identifier 01:02:03:04. It is also allowed to specify the client ID as text, like this: .B --dhcp-host=id:clientidastext,..... -The special option id:* means "ignore any client-id +A single +.B dhcp-host +may contain an IPv4 address or an IPv6 address, or both. IPv6 addresses must be bracketed by square brackets thus: +.B --dhcp-host=laptop,[1234::56] +IPv6 addresses may contain only the host-identifier part: +.B --dhcp-host=laptop,[::56] +in which case they act as wildcards in constructed dhcp ranges, with +the appropriate network part inserted. +Note that in IPv6 DHCP, the hardware address may not be +available, though it normally is for direct-connected clients, or +clients using DHCP relays which support RFC 6939. + + +For DHCPv4, the special option id:* means "ignore any client-id and use MAC addresses only." This is useful when a client presents a client-id sometimes but not others. @@ -577,7 +944,7 @@ This is useful when there is another DHCP server on the network which should be used by some machines. -The set:<tag> contruct sets the tag +The set:<tag> construct sets the tag whenever this dhcp-host directive is in use. This can be used to selectively send DHCP options just for this host. More than one tag can be set in a dhcp-host directive (but not in other places where @@ -601,7 +968,7 @@ will only match a Token-Ring hardware address, since the ARP-address type for token ring is 6. -As a special case, it is possible to include more than one +As a special case, in DHCPv4, it is possible to include more than one hardware address. eg: .B --dhcp-host=11:22:33:44:55:66,12:34:56:78:90:12,192.168.0.2 This allows an IP address to be associated with @@ -627,6 +994,18 @@ is given, then read all the files contained in that directory. The advantage of using this option is the same as for --dhcp-hostsfile: the dhcp-optsfile will be re-read when dnsmasq receives SIGHUP. Note that it is possible to encode the information in a +.TP +.B --dhcp-hostsdir=<path> +This is equivalent to dhcp-hostsfile, except for the following. The path MUST be a +directory, and not an individual file. Changed or new files within +the directory are read automatically, without the need to send SIGHUP. +If a file is deleted for changed after it has been read by dnsmasq, then the +host record it contained will remain until dnsmasq recieves a SIGHUP, or +is restarted; ie host records are only added dynamically. +.TP +.B --dhcp-optsdir=<path> +This is equivalent to dhcp-optsfile, with the differences noted for --dhcp-hostsdir. +.TP .B --dhcp-boot flag as DHCP options, using the options names bootfile-name, server-ip-address and tftp-server. This allows these to be included @@ -639,14 +1018,14 @@ hostname or dotted-quad IP address. When read by dnsmasq these lines have exactly the same effect as .B --dhcp-host options containing the same information. /etc/ethers is re-read when -dnsmasq receives SIGHUP. +dnsmasq receives SIGHUP. IPv6 addresses are NOT read from /etc/ethers. .TP -.B \-O, --dhcp-option=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]] +.B \-O, --dhcp-option=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>|option6:<opt>|option6:<opt-name>],[<value>[,<value>]] Specify different or extra options to DHCP clients. By default, dnsmasq sends some standard options to DHCP clients, the netmask and broadcast address are set to the same as the host running dnsmasq, and the DNS server and default route are set to the address of the machine -running dnsmasq. If the domain name option has been set, that is sent. +running dnsmasq. (Equivalent rules apply for IPv6.) If the domain name option has been set, that is sent. This configuration allows these defaults to be overridden, or other options specified. The option, to be sent may be given as a decimal number or as "option:<option-name>" The option numbers are @@ -662,8 +1041,10 @@ and to set the time-server address to 192.168.0.4, do or .B --dhcp-option = option:ntp-server, 192.168.0.4 The special address 0.0.0.0 is taken to mean "the address of the -machine running dnsmasq". Data types allowed are comma separated -dotted-quad IP addresses, a decimal number, colon-separated hex digits +machine running dnsmasq". + +Data types allowed are comma separated +dotted-quad IPv4 addresses, []-wrapped IPv6 addresses, a decimal number, colon-separated hex digits and a text string. If the optional tags are given then this option is only sent when all the tags are matched. @@ -673,6 +1054,16 @@ to option 120 are handled as per RFC 3361. Dotted-quad IP addresses which are followed by a slash and then a netmask size are encoded as described in RFC 3442. +IPv6 options are specified using the +.B option6: +keyword, followed by the option number or option name. The IPv6 option +name space is disjoint from the IPv4 option name space. IPv6 addresses +in options must be bracketed with square brackets, eg. +.B --dhcp-option=option6:ntp-server,[1234::56] +For IPv6, [::] means "the global address of +the machine running dnsmasq", whilst [fd00::] is replaced with the +ULA, if it exists, and [fe80::] with the link-local address. + Be careful: no checking is done that the correct type of data for the option number is sent, it is quite possible to persuade dnsmasq to generate illegal DHCP packets with injudicious use @@ -688,7 +1079,7 @@ literal string, use quotes. For instance when using option 66 to send a literal IP address as TFTP server name, it is necessary to do .B --dhcp-option=66,"1.2.3.4" -Encapsulated Vendor-class options may also be specified using +Encapsulated Vendor-class options may also be specified (IPv4 only) using --dhcp-option: for instance .B --dhcp-option=vendor:PXEClient,1,0.0.0.0 sends the encapsulated vendor @@ -700,9 +1091,9 @@ for selecting encapsulated options in preference to any sent by the client. It is possible to omit the vendorclass completely; .B --dhcp-option=vendor:,1,0.0.0.0 -in which case the encapsulated option is always sent. +in which case the encapsulated option is always sent. -Options may be encapsulated within other options: for instance +Options may be encapsulated (IPv4 only) within other options: for instance .B --dhcp-option=encap:175, 190, "iscsi-client0" will send option 175, within which is the option 190. If multiple options are given which are encapsulated with the same option number @@ -713,8 +1104,9 @@ The final variant on encapsulated options is "Vendor-Identifying Vendor Options" as specified by RFC3925. These are denoted like this: .B --dhcp-option=vi-encap:2, 10, "text" The number in the vi-encap: section is the IANA enterprise number -used to identify this option. - +used to identify this option. This form of encapsulation is supported +in IPv6. + The address 0.0.0.0 is not treated specially in encapsulated options. .TP @@ -726,14 +1118,46 @@ not ask for it in the parameter request list. This is sometimes needed, for example when sending options to PXELinux. .TP .B --dhcp-no-override -Disable re-use of the DHCP servername and filename fields as extra +(IPv4 only) Disable re-use of the DHCP servername and filename fields as extra option space. If it can, dnsmasq moves the boot server and filename information (from dhcp-boot) out of their dedicated fields into DHCP options. This make extra space available in the DHCP packet for options but can, rarely, confuse old or broken clients. This flag forces "simple and safe" behaviour to avoid problems in such a case. .TP -.B \-U, --dhcp-vendorclass=set:<tag>,<vendor-class> +.B --dhcp-relay=<local address>,<server address>[,<interface] +Configure dnsmasq to do DHCP relay. The local address is an address +allocated to an interface on the host running dnsmasq. All DHCP +requests arriving on that interface will we relayed to a remote DHCP +server at the server address. It is possible to relay from a single local +address to multiple remote servers by using multiple dhcp-relay +configs with the same local address and different server +addresses. A server address must be an IP literal address, not a +domain name. In the case of DHCPv6, the server address may be the +ALL_SERVERS multicast address, ff05::1:3. In this case the interface +must be given, not be wildcard, and is used to direct the multicast to the +correct interface to reach the DHCP server. + +Access control for DHCP clients has the same rules as for the DHCP +server, see --interface, --except-interface, etc. The optional +interface name in the dhcp-relay config has a different function: it +controls on which interface DHCP replies from the server will be +accepted. This is intended for configurations which have three +interfaces: one being relayed from, a second connecting the DHCP +server, and a third untrusted network, typically the wider +internet. It avoids the possibility of spoof replies arriving via this +third interface. + +It is allowed to have dnsmasq act as a DHCP server on one set of +interfaces and relay from a disjoint set of interfaces. Note that +whilst it is quite possible to write configurations which appear to +act as a server and a relay on the same interface, this is not +supported: the relay function will take precedence. + +Both DHCPv4 and DHCPv6 relay is supported. It's not possible to relay +DHCPv4 to a DHCPv6 server or vice-versa. +.TP +.B \-U, --dhcp-vendorclass=set:<tag>,[enterprise:<IANA-enterprise number>,]<vendor-class> Map from a vendor-class string to a tag. Most DHCP clients provide a "vendor class" which represents, in some sense, the type of host. This option maps vendor classes to tags, so that DHCP options may be selectively delivered @@ -743,7 +1167,13 @@ will allow options to be set only for HP printers like so: .B --dhcp-option=tag:printers,3,192.168.4.4 The vendor-class string is substring matched against the vendor-class supplied by the client, to -allow fuzzy matching. The set: prefix is optional but allowed for consistency. +allow fuzzy matching. The set: prefix is optional but allowed for +consistency. + +Note that in IPv6 only, vendorclasses are namespaced with an +IANA-allocated enterprise number. This is given with enterprise: +keyword and specifies that only vendorclasses matching the specified +number should be searched. .TP .B \-j, --dhcp-userclass=set:<tag>,<user-class> Map from a user-class string to a tag (with substring @@ -765,16 +1195,19 @@ Map from RFC3046 relay agent options to tags. This data may be provided by DHCP relay agents. The circuit-id or remote-id is normally given as colon-separated hex, but is also allowed to be a simple string. If an exact match is achieved between the circuit or -agent ID and one provided by a relay agent, the tag is set. +agent ID and one provided by a relay agent, the tag is set. + +.B dhcp-remoteid +(but not dhcp-circuitid) is supported in IPv6. .TP .B --dhcp-subscrid=set:<tag>,<subscriber-id> -Map from RFC3993 subscriber-id relay agent options to tags. +(IPv4 and IPv6) Map from RFC3993 subscriber-id relay agent options to tags. .TP .B --dhcp-proxy[=<ip addr>]...... -A normal DHCP relay agent is only used to forward the initial parts of +(IPv4 only) A normal DHCP relay agent is only used to forward the initial parts of a DHCP interaction to the DHCP server. Once a client is configured, it communicates directly with the server. This is undesirable if the -relay agent is addding extra information to the DHCP packets, such as +relay agent is adding extra information to the DHCP packets, such as that used by .B dhcp-circuitid and @@ -791,7 +1224,7 @@ relays at those addresses are affected. Without a value, set the tag if the client sends a DHCP option of the given number or name. When a value is given, set the tag only if the option is sent and matches the value. The value may be of the form -"01:ff:*:02" in which case the value must match (apart from widcards) +"01:ff:*:02" in which case the value must match (apart from wildcards) but the option sent may have unmatched data past the end of the value. The value may also be of the same form as in .B dhcp-option @@ -804,7 +1237,7 @@ will set the tag "efi-ia32" if the the number 6 appears in the list of architectures sent by the client in option 93. (See RFC 4578 for details.) If the value is a string, substring matching is used. -The special form with vi-encap:<enterpise number> matches against +The special form with vi-encap:<enterprise number> matches against vendor-identifying vendor classes for the specified enterprise. Please see RFC 3925 for more details of these rare and interesting beasts. .TP @@ -831,22 +1264,22 @@ dhcp-host configuration in dnsmasq and the contents of /etc/hosts and /etc/ethers. .TP .B --dhcp-generate-names=tag:<tag>[,tag:<tag>] -Generate a name for DHCP clients which do not otherwise have one, -using the MAC address expressed in hex, seperated by dashes. Note that +(IPv4 only) Generate a name for DHCP clients which do not otherwise have one, +using the MAC address expressed in hex, separated by dashes. Note that if a host provides a name, it will be used by preference to this, unless .B --dhcp-ignore-names is set. .TP .B --dhcp-broadcast[=tag:<tag>[,tag:<tag>]] -When all the given tags appear in the tag set, always use broadcast to +(IPv4 only) When all the given tags appear in the tag set, always use broadcast to communicate with the host when it is unconfigured. It is permissible to supply no tags, in which case this is unconditional. Most DHCP clients which need broadcast replies set a flag in their requests so that this happens automatically, some old BOOTP clients do not. .TP -.B \-M, --dhcp-boot=[tag:<tag>,]<filename>,[<servername>[,<server address>]] -Set BOOTP options to be returned by the DHCP server. Server name and +.B \-M, --dhcp-boot=[tag:<tag>,]<filename>,[<servername>[,<server address>|<tftp_servername>]] +(IPv4 only) Set BOOTP options to be returned by the DHCP server. Server name and address are optional: if not provided, the name is left empty, and the address set to the address of the machine running dnsmasq. If dnsmasq is providing a TFTP service (see @@ -854,8 +1287,25 @@ is providing a TFTP service (see ) then only the filename is required here to enable network booting. If the optional tag(s) are given, they must match for this configuration to be sent. -.TP -.B --pxe-service=[tag:<tag>,]<CSA>,<menu text>[,<basename>|<bootservicetype>][,<server address>] +Instead of an IP address, the TFTP server address can be given as a domain +name which is looked up in /etc/hosts. This name can be associated in +/etc/hosts with multiple IP addresses, which are used round-robin. +This facility can be used to load balance the tftp load among a set of servers. +.TP +.B --dhcp-sequential-ip +Dnsmasq is designed to choose IP addresses for DHCP clients using a +hash of the client's MAC address. This normally allows a client's +address to remain stable long-term, even if the client sometimes allows its DHCP +lease to expire. In this default mode IP addresses are distributed +pseudo-randomly over the entire available address range. There are +sometimes circumstances (typically server deployment) where it is more +convenient to have IP +addresses allocated sequentially, starting from the lowest available +address, and setting this flag enables this mode. Note that in the +sequential mode, clients which allow a lease to expire are much more +likely to move IP address; for this reason it should not be generally used. +.TP +.B --pxe-service=[tag:<tag>,]<CSA>,<menu text>[,<basename>|<bootservicetype>][,<server address>|<server_name>] Most uses of PXE boot-ROMS simply allow the PXE system to obtain an IP address and then download the file specified by .B dhcp-boot @@ -871,17 +1321,19 @@ parameter after the menu text may be a file name, in which case dnsmasq acts as boot server and directs the PXE client to download the file by TFTP, either from itself ( .B enable-tftp -must be set for this to work) or another TFTP server if the final IP -address is given. +must be set for this to work) or another TFTP server if the final server +address/name is given. Note that the "layer" suffix (normally ".0") is supplied by PXE, and should not be added to the basename. If an integer boot service type, rather than a basename is given, then the PXE client will search for a suitable boot service for that type on the network. This search may be done -by broadcast, or direct to a server if its IP address is provided. +by broadcast, or direct to a server if its IP address/name is provided. If no boot service type or filename is provided (or a boot service type of 0 is specified) then the menu entry will abort the net boot procedure and -continue booting from local media. +continue booting from local media. The server address can be given as a domain +name which is looked up in /etc/hosts. This name can be associated in +/etc/hosts with multiple IP addresses, which are used round-robin. .TP .B --pxe-prompt=[tag:<tag>,]<prompt>[,<timeout>] Setting this provides a prompt to be displayed after PXE boot. If the @@ -890,7 +1342,7 @@ timeout has elapsed with no keyboard input, the first available menu option will be automatically executed. If the timeout is zero then the first available menu item will be executed immediately. If .B pxe-prompt -is ommitted the system will wait for user input if there are multiple +is omitted the system will wait for user input if there are multiple items in the menu, but boot immediately if there is only one. See .B pxe-service @@ -915,14 +1367,15 @@ process. .TP .B \-K, --dhcp-authoritative Should be set when dnsmasq is definitely the only DHCP server on a network. -It changes the behaviour from strict RFC compliance so that DHCP requests on +For DHCPv4, it changes the behaviour from strict RFC compliance so that DHCP requests on unknown leases from unknown hosts are not ignored. This allows new hosts to get a lease without a tedious timeout under all circumstances. It also allows dnsmasq to rebuild its lease database without each client needing to -reacquire a lease, if the database is lost. +reacquire a lease, if the database is lost. For DHCPv6 it sets the +priority in replies to 255 (the maximum) instead of 0 (the minimum). .TP .B --dhcp-alternate-port[=<server port>[,<client port>]] -Change the ports used for DHCP from the default. If this option is +(IPv4 only) Change the ports used for DHCP from the default. If this option is given alone, without arguments, it changes the ports used for DHCP from 67 and 68 to 1067 and 1068. If a single argument is given, that port number is used for the server and the port number plus one used @@ -930,7 +1383,7 @@ for the client. Finally, two port numbers allows arbitrary specification of both server and client ports for DHCP. .TP .B \-3, --bootp-dynamic[=<network-id>[,<network-id>]] -Enable dynamic allocation of IP addresses to BOOTP clients. Use this +(IPv4 only) Enable dynamic allocation of IP addresses to BOOTP clients. Use this with care, since each address allocated to a BOOTP client is leased forever, and therefore becomes permanently unavailable for re-use by other hosts. if this is given without tags, then it unconditionally @@ -938,7 +1391,7 @@ enables dynamic allocation. With tags, only when the tags are all set. It may be repeated with different tag sets. .TP .B \-5, --no-ping -By default, the DHCP server will attempt to ensure that an address in +(IPv4 only) By default, the DHCP server will attempt to ensure that an address is not in use before allocating it to a host. It does this by sending an ICMP echo request (aka "ping") to the address in question. If it gets a reply, then the address must already be in use, and another is @@ -948,16 +1401,32 @@ tried. This flag disables this check. Use with caution. Extra logging for DHCP: log all the options sent to DHCP clients and the tags used to determine them. .TP +.B --quiet-dhcp, --quiet-dhcp6, --quiet-ra +Suppress logging of the routine operation of these protocols. Errors and +problems will still be logged. --quiet-dhcp and quiet-dhcp6 are +over-ridden by --log-dhcp. +.TP .B \-l, --dhcp-leasefile=<path> Use the specified file to store DHCP lease information. .TP +.B --dhcp-duid=<enterprise-id>,<uid> +(IPv6 only) Specify the server persistent UID which the DHCPv6 server +will use. This option is not normally required as dnsmasq creates a +DUID automatically when it is first needed. When given, this option +provides dnsmasq the data required to create a DUID-EN type DUID. Note +that once set, the DUID is stored in the lease database, so to change between DUID-EN and +automatically created DUIDs or vice-versa, the lease database must be +re-intialised. The enterprise-id is assigned by IANA, and the uid is a +string of hex octets unique to a particular device. +.TP .B \-6 --dhcp-script=<path> -Whenever a new DHCP lease is created, or an old one destroyed, the +Whenever a new DHCP lease is created, or an old one destroyed, or a +TFTP file transfer completes, the executable specified by this option is run. <path> must be an absolute pathname, no PATH search occurs. The arguments to the process are "add", "old" or "del", the MAC -address of the host, the IP address, and the hostname, +address of the host (or DUID for IPv6) , the IP address, and the hostname, if known. "add" means a lease has been created, "del" means it has been destroyed, "old" is a notification of an existing lease when dnsmasq starts or a change to MAC address or hostname of an existing @@ -968,21 +1437,17 @@ token ring. The process is run as root (assuming that dnsmasq was originally run root) even if dnsmasq is configured to change UID to an unprivileged user. The environment is inherited from the invoker of dnsmasq, with some or -all of the following variables added. +all of the following variables added -DNSMASQ_CLIENT_ID if the host provided a client-id. +For both IPv4 and IPv6: DNSMASQ_DOMAIN if the fully-qualified domain name of the host is known, this is set to the domain part. (Note that the hostname passed to the script as an argument is never fully-qualified.) -If the client provides vendor-class, hostname or user-class, -these are provided in DNSMASQ_VENDOR_CLASS -DNSMASQ_SUPPLIED_HOSTNAME and -DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn variables, but only for -"add" actions or "old" actions when a host resumes an existing lease, -since these data are not held in dnsmasq's lease -database. +If the client provides a hostname, DNSMASQ_SUPPLIED_HOSTNAME + +If the client provides user-classes, DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn If dnsmasq was compiled with HAVE_BROKEN_RTC, then the length of the lease (in seconds) is stored in @@ -1006,6 +1471,41 @@ is known. DNSMASQ_TAGS contains all the tags set during the DHCP transaction, separated by spaces. +DNSMASQ_LOG_DHCP is set if +.B --log-dhcp +is in effect. + +For IPv4 only: + +DNSMASQ_CLIENT_ID if the host provided a client-id. + +DNSMASQ_CIRCUIT_ID, DNSMASQ_SUBSCRIBER_ID, DNSMASQ_REMOTE_ID if a +DHCP relay-agent added any of these options. + +If the client provides vendor-class, DNSMASQ_VENDOR_CLASS. + +For IPv6 only: + +If the client provides vendor-class, DNSMASQ_VENDOR_CLASS_ID, +containing the IANA enterprise id for the class, and +DNSMASQ_VENDOR_CLASS0..DNSMASQ_VENDOR_CLASSn for the data. + +DNSMASQ_SERVER_DUID containing the DUID of the server: this is the same for +every call to the script. + +DNSMASQ_IAID containing the IAID for the lease. If the lease is a +temporary allocation, this is prefixed to 'T'. + +DNSMASQ_MAC containing the MAC address of the client, if known. + +Note that the supplied hostname, vendorclass and userclass data is +only supplied for +"add" actions or "old" actions when a host resumes an existing lease, +since these data are not held in dnsmasq's lease +database. + + + All file descriptors are closed except stdin, stdout and stderr which are open to /dev/null (except in debug mode). @@ -1024,9 +1524,66 @@ all existing leases as they are read from the lease file. Expired leases will be called with "del" and others with "old". When dnsmasq receives a HUP signal, the script will be invoked for existing leases with an "old " event. + + +There are two further actions which may appear as the first argument +to the script, "init" and "tftp". More may be added in the future, so +scripts should be written to ignore unknown actions. "init" is +described below in +.B --leasefile-ro +The "tftp" action is invoked when a TFTP file transfer completes: the +arguments are the file size in bytes, the address to which the file +was sent, and the complete pathname of the file. + +.TP +.B --dhcp-luascript=<path> +Specify a script written in Lua, to be run when leases are created, +destroyed or changed. To use this option, dnsmasq must be compiled +with the correct support. The Lua interpreter is intialised once, when +dnsmasq starts, so that global variables persist between lease +events. The Lua code must define a +.B lease +function, and may provide +.B init +and +.B shutdown +functions, which are called, without arguments when dnsmasq starts up +and terminates. It may also provide a +.B tftp +function. + +The +.B lease +function receives the information detailed in +.B --dhcp-script. +It gets two arguments, firstly the action, which is a string +containing, "add", "old" or "del", and secondly a table of tag value +pairs. The tags mostly correspond to the environment variables +detailed above, for instance the tag "domain" holds the same data as +the environment variable DNSMASQ_DOMAIN. There are a few extra tags +which hold the data supplied as arguments to +.B --dhcp-script. +These are +.B mac_address, ip_address +and +.B hostname +for IPv4, and +.B client_duid, ip_address +and +.B hostname +for IPv6. + +The +.B tftp +function is called in the same way as the lease function, and the +table holds the tags +.B destination_address, +.B file_name +and +.B file_size. .TP .B --dhcp-scriptuser -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. +Specify the user as which to run the lease-change script or Lua script. This defaults to root, but can be changed to another user using this flag. .TP .B \-9, --leasefile-ro Completely suppress use of the lease database file. The file will not @@ -1043,10 +1600,13 @@ option also forces the leasechange script to be called on changes to the client-id and lease length and expiry time. .TP .B --bridge-interface=<interface>,<alias>[,<alias>] -Treat DHCP request packets arriving at any of the <alias> interfaces -as if they had arrived at <interface>. This option is necessary when -using "old style" bridging on BSD platforms, since -packets arrive at tap interfaces which don't have an IP address. +Treat DHCP (v4 and v6) request and IPv6 Router Solicit packets +arriving at any of the <alias> interfaces as if they had arrived at +<interface>. This option allows dnsmasq to provide DHCP and RA +service over unaddressed and unbridged Ethernet interfaces, e.g. on an +OpenStack compute host where each such interface is a TAP interface to +a VM, or as in "old style bridging" on BSD platforms. A trailing '*' +wildcard can be used in each <alias>. .TP .B \-s, --domain=<domain>[,<address range>[,local]] Specifies DNS domains for the DHCP server. Domains may be be given @@ -1089,7 +1649,7 @@ In the default mode, dnsmasq inserts the unqualified names of DHCP clients into the DNS. For this reason, the names must be unique, even if two clients which have the same name are in different domains. If a second DHCP client appears which has the same name as an -existing client, the name is transfered to the new client. If +existing client, the name is transferred to the new client. If .B --dhcp-fqdn is set, this behaviour changes: the unqualified name is no longer put in the DNS, only the qualified name. Two DHCP clients with the @@ -1101,12 +1661,52 @@ without an address specified when .B --dhcp-fqdn is set. .TP -.B --enable-tftp[=<interface>] +.B --dhcp-client-update +Normally, when giving a DHCP lease, dnsmasq sets flags in the FQDN +option to tell the client not to attempt a DDNS update with its name +and IP address. This is because the name-IP pair is automatically +added into dnsmasq's DNS view. This flag suppresses that behaviour, +this is useful, for instance, to allow Windows clients to update +Active Directory servers. See RFC 4702 for details. +.TP +.B --enable-ra +Enable dnsmasq's IPv6 Router Advertisement feature. DHCPv6 doesn't +handle complete network configuration in the same way as DHCPv4. Router +discovery and (possibly) prefix discovery for autonomous address +creation are handled by a different protocol. When DHCP is in use, +only a subset of this is needed, and dnsmasq can handle it, using +existing DHCP configuration to provide most data. When RA is enabled, +dnsmasq will advertise a prefix for each dhcp-range, with default +router and recursive DNS server as the relevant link-local address on +the machine running dnsmasq. By default, he "managed address" bits are set, and +the "use SLAAC" bit is reset. This can be changed for individual +subnets with the mode keywords described in +.B --dhcp-range. +RFC6106 DNS parameters are included in the advertisements. By default, +the relevant link-local address of the machine running dnsmasq is sent +as recursive DNS server. If provided, the DHCPv6 options dns-server and +domain-search are used for RDNSS and DNSSL. +.TP +.B --ra-param=<interface>,[high|low],[[<ra-interval>],<router lifetime>] +Set non-default values for router advertisements sent via an +interface. The priority field for the router may be altered from the +default of medium with eg +.B --ra-param=eth0,high. +The interval between router advertisements may be set (in seconds) with +.B --ra-param=eth0,60. +The lifetime of the route may be changed or set to zero, which allows +a router to advertise prefixes but not a route via itself. +.B --ra-parm=eth0,0,0 +(A value of zero for the interval means the default value.) All three parameters may be set at once. +.B --ra-param=low,60,1200 +The interface field may include a wildcard. +.TP +.B --enable-tftp[=<interface>[,<interface>]] Enable the TFTP server function. This is deliberately limited to that needed to net-boot a client. Only reading is allowed; the tsize and blksize extensions are supported (tsize is only supported in octet -mode). See NOTES section for use of the interface argument. - +mode). Without an argument, the TFTP service is provided to the same set of interfaces as DHCP service. +If the list of interfaces is provided, that defines which interfaces recieve TFTP service. .TP .B --tftp-root=<directory>[,<interface>] Look for files to transfer using TFTP relative to the given @@ -1116,6 +1716,9 @@ Absolute paths (starting with /) are allowed, but they must be within the tftp-root. If the optional interface argument is given, the directory is only used for TFTP requests via that interface. .TP +.B --tftp-no-fail +Do not abort startup if specified tftp root directories are inaccessible. +.TP .B --tftp-unique-root Add the IP address of the TFTP client as a path component on the end of the TFTP-root (in standard dotted-quad format). Only valid if a @@ -1134,6 +1737,12 @@ are accessible. It is not recommended to run dnsmasq as root with TFTP enabled, and certainly not without specifying --tftp-root. Doing so can expose any world-readable file on the server to any host on the net. .TP +.B --tftp-lowercase +Convert filenames in TFTP requests to all lowercase. This is useful +for requests from Windows machines, which have case-insensitive +filesystems and tend to play fast-and-loose with case in filenames. +Note that dnsmasq's tftp server always converts "\\" to "/" in filenames. +.TP .B --tftp-max=<connections> Set the maximum number of concurrent TFTP connections allowed. This defaults to 50. When serving a large number of TFTP connections, @@ -1165,12 +1774,23 @@ Specify a different configuration file. The conf-file option is also allowed in configuration files, to include multiple configuration files. A filename of "-" causes dnsmasq to read configuration from stdin. .TP -.B \-7, --conf-dir=<directory>[,<file-extension>......] +.B \-7, --conf-dir=<directory>[,<file-extension>......], Read all the files in the given directory as configuration files. If extension(s) are given, any files which end in those extensions are skipped. Any files whose names end in ~ or start with . or start and end -with # are always skipped. This flag may be given on the command -line or in a configuration file. +with # are always skipped. If the extension starts with * then only files +which have that extension are loaded. So +.B --conf-dir=/path/to/dir,*.conf +loads all files with the suffix .conf in /path/to/dir. This flag may be given on the command +line or in a configuration file. If giving it on the command line, be sure to +escape * characters. +.TP +.B --servers-file=<file> +A special case of +.B --conf-file +which differs in two respects. Firstly, only --server and --rev-server are allowed +in the configuration file included. Secondly, the file is re-read and the configuration +therein is updated when dnsmasq recieves SIGHUP. .SH CONFIG FILE At startup, dnsmasq reads .I /etc/dnsmasq.conf, @@ -1196,7 +1816,8 @@ clears its cache and then re-loads .I /etc/hosts and .I /etc/ethers -and any file given by --dhcp-hostsfile, --dhcp-optsfile or --addn-hosts. +and any file given by --dhcp-hostsfile, --dhcp-hostsdir, --dhcp-optsfile, +--dhcp-optsdir, --addn-hosts or --hostsdir. The dhcp lease change script is called for all existing DHCP leases. If .B @@ -1211,12 +1832,22 @@ When it receives a SIGUSR1, writes statistics to the system log. It writes the cache size, the number of names which have had to removed from the cache before they expired in order to make room for new names and the total number -of names that have been inserted into the cache. For each upstream +of names that have been inserted into the cache. The number of cache hits and +misses and the number of authoritative queries answered are also given. For each upstream server it gives the number of queries sent, and the number which resulted in an error. In .B --no-daemon mode or when full logging is enabled (-q), a complete dump of the -contents of the cache is made. +contents of the cache is made. + +The cache statistics are also available in the DNS as answers to +queries of class CHAOS and type TXT in domain bind. The domain names are cachesize.bind, insertions.bind, evictions.bind, +misses.bind, hits.bind, auth.bind and servers.bind. An example command to query this, using the +.B dig +utility would be + +dig +short chaos txt cachesize.bind + .PP When it receives SIGUSR2 and it is logging direct to a file (see .B --log-facility @@ -1312,7 +1943,7 @@ used to allocate the address, one from any matching The tag "bootp" is set for BOOTP requests, and a tag whose name is the name of the interface on which the request arrived is also set. -Any configuration lines which includes one or more tag:<tag> contructs +Any configuration lines which include one or more tag:<tag> constructs will only be valid if all that tags are matched in the set derived above. Typically this is dhcp-option. .B dhcp-option @@ -1320,10 +1951,21 @@ which has tags will be used in preference to an untagged .B dhcp-option, provided that _all_ the tags match somewhere in the set collected as described above. The prefix '!' on a tag means 'not' -so --dhcp=option=tag:!purple,3,1.2.3.4 sends the option when the +so --dhcp-option=tag:!purple,3,1.2.3.4 sends the option when the tag purple is not in the set of valid tags. (If using this in a command line rather than a configuration file, be sure to escape !, which is a shell metacharacter) + +When selecting dhcp-options, a tag from dhcp-range is second class +relative to other tags, to make it easy to override options for +individual hosts, so +.B dhcp-range=set:interface1,...... +.B dhcp-host=set:myhost,..... +.B dhcp-option=tag:interface1,option:nis-domain,"domain1" +.B dhcp-option=tag:myhost,option:nis-domain,"domain2" +will set the NIS-domain to domain1 for hosts in the range, but +override that to domain2 for a particular host. + .PP Note that for .B dhcp-range @@ -1353,51 +1995,170 @@ parameter in a BOOTP request is used as a tag, as is the tag "bootp", allowing some control over the options returned to different classes of hosts. -.B dhcp-range -may have an interface name supplied as -"interface:<interface-name>". The semantics if this are as follows: -For DHCP, if any other dhcp-range exists _without_ an interface name, -then the interface name is ignored and and dnsmasq behaves as if the -interface parts did not exist, otherwise DHCP is only provided to -interfaces mentioned in dhcp-range -declarations. For DNS, if there are no -.B --interface -or -.B --listen-address -flags, behaviour is unchanged by the interface part. If either of -these flags are present, the interfaces mentioned in -dhcp-ranges are added to the set which get DNS service. - -Similarly, -.B enable-tftp -may take an interface name, which enables TFTP only for a particular -interface, ignoring -.B --interface -or -.B --listen-address -flags. In addition -.B --tftp-secure -and -.B --tftp-unique-root +.SH AUTHORITATIVE CONFIGURATION +.PP +Configuring dnsmasq to act as an authoritative DNS server is +complicated by the fact that it involves configuration of external DNS +servers to provide delegation. We will walk through three scenarios of +increasing complexity. Prerequisites for all of these scenarios +are a globally accessible IP address, an A or AAAA record pointing to that address, +and an external DNS server capable of doing delegation of the zone in +question. For the first part of this explanation, we will call the A (or AAAA) record +for the globally accessible address server.example.com, and the zone +for which dnsmasq is authoritative our.zone.com. + +The simplest configuration consists of two lines of dnsmasq configuration; something like + +.nf +.B auth-server=server.example.com,eth0 +.B auth-zone=our.zone.com,1.2.3.0/24 +.fi + +and two records in the external DNS + +.nf +server.example.com A 192.0.43.10 +our.zone.com NS server.example.com +.fi + +eth0 is the external network interface on which dnsmasq is listening, +and has (globally accessible) address 192.0.43.10. + +Note that the external IP address may well be dynamic (ie assigned +from an ISP by DHCP or PPP) If so, the A record must be linked to this +dynamic assignment by one of the usual dynamic-DNS systems. + +A more complex, but practically useful configuration has the address +record for the globally accessible IP address residing in the +authoritative zone which dnsmasq is serving, typically at the root. Now +we have + +.nf +.B auth-server=our.zone.com,eth0 +.B auth-zone=our.zone.com,1.2.3.0/24 +.fi + +.nf +our.zone.com A 1.2.3.4 +our.zone.com NS our.zone.com +.fi + +The A record for our.zone.com has now become a glue record, it solves +the chicken-and-egg problem of finding the IP address of the +nameserver for our.zone.com when the A record is within that +zone. Note that this is the only role of this record: as dnsmasq is +now authoritative from our.zone.com it too must provide this +record. If the external address is static, this can be done with an +.B /etc/hosts +entry or +.B --host-record. + +.nf +.B auth-server=our.zone.com,eth0 +.B host-record=our.zone.com,1.2.3.4 +.B auth-zone=our.zone.com,1.2.3.0/24 +.fi + +If the external address is dynamic, the address +associated with our.zone.com must be derived from the address of the +relevant interface. This is done using +.B interface-name +Something like: + +.nf +.B auth-server=our.zone.com,eth0 +.B interface-name=our.zone.com,eth0 +.B auth-zone=our.zone.com,1.2.3.0/24,eth0 +.fi + +(The "eth0" argument in auth-zone adds the subnet containing eth0's +dynamic address to the zone, so that the interface-name returns the +address in outside queries.) + +Our final configuration builds on that above, but also adds a +secondary DNS server. This is another DNS server which learns the DNS data +for the zone by doing zones transfer, and acts as a backup should +the primary server become inaccessible. The configuration of the +secondary is beyond the scope of this man-page, but the extra +configuration of dnsmasq is simple: + +.nf +.B auth-sec-servers=secondary.myisp.com +.fi + and -.B --tftp-no-blocksize -are ignored for requests from such interfaces. (A -.B --tftp-root -directive giving a root path and an interface should be -provided too.) - -These rules may seem odd at first sight, but they -allow a single line of the form "dhcp-range=interface:virt0,192.168.0.4,192.168.0.200" -to be added to dnsmasq configuration which then supplies -DHCP and DNS services to that interface, without affecting -what services are supplied to other interfaces and irrespective of -the existance or lack of "interface=<interface>" -lines elsewhere in the dnsmasq configuration. -"enable-tftp=virt0" and "tftp-root=<root>,virt0" do the same job for TFTP. - The idea is -that such a line can be added automatically by libvirt -or equivalent systems, without disturbing any manual -configuration. + +.nf +our.zone.com NS secondary.myisp.com +.fi + +Adding auth-sec-servers enables zone transfer in dnsmasq, to allow the +secondary to collect the DNS data. If you wish to restrict this data +to particular hosts then + +.nf +.B auth-peer=<IP address of secondary> +.fi + +will do so. + +Dnsmasq acts as an authoritative server for in-addr.arpa and +ip6.arpa domains associated with the subnets given in auth-zone +declarations, so reverse (address to name) lookups can be simply +configured with a suitable NS record, for instance in this example, +where we allow 1.2.3.0/24 addresses. + +.nf + 3.2.1.in-addr.arpa NS our.zone.com +.fi + +Note that at present, reverse (in-addr.arpa and ip6.arpa) zones are +not available in zone transfers, so there is no point arranging +secondary servers for reverse lookups. + +.PP +When dnsmasq is configured to act as an authoritative server, the +following data is used to populate the authoritative zone. +.PP +.B --mx-host, --srv-host, --dns-rr, --txt-record, --naptr-record +, as long as the record names are in the authoritative domain. +.PP +.B --cname +as long as the record name is in the authoritative domain. If the +target of the CNAME is unqualified, then it is qualified with the +authoritative zone name. +.PP +IPv4 and IPv6 addresses from /etc/hosts (and +.B --addn-hosts +) and +.B --host-record +and +.B --interface-name +provided the address falls into one of the subnets specified in the +.B --auth-zone. +.PP +Addresses of DHCP leases, provided the address falls into one of the subnets specified in the +.B --auth-zone. +(If contructed DHCP ranges are is use, which depend on the address dynamically +assigned to an interface, then the form of +.B --auth-zone +which defines subnets by the dynamic address of an interface should +be used to ensure this condition is met.) +.PP +In the default mode, where a DHCP lease +has an unqualified name, and possibly a qualified name constructed +using +.B --domain +then the name in the authoritative zone is constructed from the +unqualified name and the zone's domain. This may or may not equal +that specified by +.B --domain. +If +.B --dhcp-fqdn +is set, then the fully qualified names associated with DHCP leases are +used, and must match the zone's domain. + + .SH EXIT CODES .PP |