Linux "dnsmasq" Command Line Options and Examples
A lightweight DHCP and caching DNS server.

dnsmasq is a lightweight DNS, TFTP, PXE, router advertisement and DHCP server. It is intended to provide coupled DNS and DHCP service to a LAN. Dnsmasq accepts DNS queries and either answers them from a small, local, cache or forwards them to a real, recursive, DNS server.


Usage:

dnsmasq [OPTION]...




Command Line Options:

-w
Display all command-line options. --help dhcp will display known DHCPv4 configuration options, and --help dhcp6 will displayDHCPv6 options.
dnsmasq -w ...
-h
Don't read the hostnames in /etc/hosts.
dnsmasq -h ...
-H
Additional hosts file. Read the specified file as well as /etc/hosts. If -h is given, read only the specified file. Thisoption may be repeated for more than one additional hosts file. If a directory is given, then read all the files contained inthat directory.
dnsmasq -H ...
--hostsdir
Read all the hosts files contained in the directory. New or changed files are read automatically. See --dhcp-hostsdir fordetails.
dnsmasq --hostsdir ...
-E
Add the domain to simple names (without a period) in /etc/hosts in the same way as for DHCP-derived names. Note that this doesnot apply to domain names in cnames, PTR records, TXT records etc.
dnsmasq -E ...
-T
When replying with information from /etc/hosts or configuration or the DHCP leases file dnsmasq by default sets the time-to-live field to zero, meaning that the requester should not itself cache the information. This is the correct thing to do inalmost all situations. This option allows a time-to-live (in seconds) to be given for these replies. This will reduce the loadon the server at the expense of clients using stale data under some circumstances.
dnsmasq -T ...
--dhcp-ttl
As for --local-ttl, but affects only replies with information from DHCP leases. If both are given, --dhcp-ttl applies for DHCPinformation, and --local-ttl for others. Setting this to zero eliminates the effect of --local-ttl for DHCP.
dnsmasq --dhcp-ttl ...
--neg-ttl
Negative replies from upstream servers normally contain time-to-live information in SOA records which dnsmasq uses forcaching. If the replies from upstream servers omit this information, dnsmasq does not cache the reply. This option gives adefault value for time-to-live (in seconds) which dnsmasq uses to cache negative replies even in the absence of an SOA record.
dnsmasq --neg-ttl ...
--max-ttl
Set a maximum TTL value that will be handed out to clients. The specified maximum TTL will be given to clients instead of thetrue TTL value if it is lower. The true TTL value is however kept in the cache to avoid flooding the upstream DNS servers.
dnsmasq --max-ttl ...
--max-cache-ttl
Set a maximum TTL value for entries in the cache.
dnsmasq --max-cache-ttl ...
--min-cache-ttl
Extend short TTL values to the time given when caching them. Note that artificially extending TTL values is in general a badidea, do not do it unless you have a good reason, and understand what you are doing. Dnsmasq limits the value of this optionto one hour, unless recompiled.
dnsmasq --min-cache-ttl ...
--auth-ttl
Set the TTL value returned in answers from the authoritative server.
dnsmasq --auth-ttl ...
-k
Do not go into the background at startup but otherwise run as normal. This is intended for use when dnsmasq is run under dae‐montools or launchd.
dnsmasq -k ...
-d
Debug mode: don't fork to the background, don't write a pid file, don't change user id, generate a complete cache dump onreceipt on SIGUSR1, log to stderr as well as syslog, don't fork new processes to handle TCP queries. Note that this option isfor use in debugging only, to stop dnsmasq daemonising in production, use -k.
dnsmasq -d ...
-q
Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1. If the argument "extra" issupplied, ie --log-queries=extra then the log has extra information at the start of each line. This consists of a serial num‐ber which ties together the log lines associated with an individual query, and the IP address of the requestor.
dnsmasq -q ...
-8
Set the facility to which dnsmasq will send syslog entries, this defaults to DAEMON, and to LOCAL0 when debug mode is in oper‐ation. If the facility given contains at least one '/' character, it is taken to be a filename, and dnsmasq logs to the givenfile, instead of syslog. If the facility is '-' then dnsmasq logs to stderr. (Errors whilst reading configuration will stillgo to syslog, but all output from a successful startup, and all output whilst running, will go exclusively to the file.) Whenlogging to a file, dnsmasq will close and reopen the file when it receives SIGUSR2. This allows the log file to be rotatedwithout stopping dnsmasq.
dnsmasq -8 ...
--log-async[
Enable asynchronous logging and optionally set the limit on the number of lines which will be queued by dnsmasq when writingto the syslog is slow. Dnsmasq can log asynchronously: this allows it to continue functioning without being blocked by sys‐log, and allows syslog to use dnsmasq for DNS queries without risking deadlock. If the queue of log-lines becomes full, dns‐masq will log the overflow, and the number of messages lost. The default queue length is 5, a sane value would be 5-25, and amaximum limit of 100 is imposed.
dnsmasq --log-async[ ...
-x
Specify an alternate path for dnsmasq to record its process-id in. Normally /var/run/dnsmasq.pid.
dnsmasq -x ...
-u
Specify the userid to which dnsmasq will change after startup. Dnsmasq must normally be started as root, but it will drop rootprivileges after startup by changing id to another user. Normally this user is "nobody" but that can be over-ridden with thisswitch.
dnsmasq -u ...
-g
Specify the group which dnsmasq will run as. The defaults to "dip", if available, to facilitate access to /etc/ppp/resolv.confwhich is not normally world readable.
dnsmasq -g ...
-v
Print the version number.
dnsmasq -v ...
-p
Listen on <port> instead of the standard DNS port (53). Setting this to zero completely disables DNS function, leaving onlyDHCP and/or TFTP.
dnsmasq -p ...
-P
Specify the largest EDNS.0 UDP packet which is supported by the DNS forwarder. Defaults to 4096, which is the RFC5625-recom‐mended size.
dnsmasq -P ...
-Q
Send outbound DNS queries from, and listen for their replies on, the specific UDP port <query_port> instead of using randomports. NOTE that using this option will make dnsmasq less secure against DNS spoofing attacks but it may be faster and useless resources. Setting this option to zero makes dnsmasq use a single port allocated to it by the OS: this was the defaultbehaviour in versions prior to 2.43.
dnsmasq -Q ...
--min-port
Do not use ports less than that given as source for outbound DNS queries. Dnsmasq picks random ports as source for outboundqueries: when this option is given, the ports used will always to larger than that specified. Useful for systems behind fire‐walls. If not specified, defaults to 1024.
dnsmasq --min-port ...
--max-port
Use ports lower than that given as source for outbound DNS queries. Dnsmasq picks random ports as source for outboundqueries: when this option is given, the ports used will always be lower than that specified. Useful for systems behind fire‐walls.
dnsmasq --max-port ...
-i
Listen only on the specified interface(s). Dnsmasq automatically adds the loopback (local) interface to the list of interfacesto use when the --interface option is used. If no --interface or --listen-address options are given dnsmasq listens on allavailable interfaces except any given in --except-interface options. On Linux, when --bind-interfaces or --bind-dynamic are ineffect, IP alias interface labels (eg "eth1:0") are checked, rather than interface names. In the degenerate case when aninterface has one address, this amounts to the same thing but when an interface has multiple addresses it allows control overwhich of those addresses are accepted. The same effect is achievable in default mode by using --listen-address. A simplewildcard, consisting of a trailing '*', can be used in --interface and --except-interface options.
dnsmasq -i ...
-I
Do not listen on the specified interface. Note that the order of --listen-address --interface and --except-interface optionsdoes not matter and that --except-interface options always override the others. The comments about interface labels for --lis‐ten-address apply here.
dnsmasq -I ...
--auth-server
Enable DNS authoritative mode for queries arriving at an interface or address. Note that the interface or address need not bementioned in --interface or --listen-address configuration, indeed --auth-server will override these and provide a differentDNS service on the specified interface. The <domain> is the "glue record". It should resolve in the global DNS to an A and/orAAAA 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.
dnsmasq --auth-server ...
--local-service
Accept DNS queries only from hosts whose address is on a local subnet, ie a subnet for which an interface exists on theserver. This option only has effect if 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 frombeing used for DNS amplification attacks.
dnsmasq --local-service ...
-2
Do not provide DHCP or TFTP on the specified interface, but do provide DNS service.
dnsmasq -2 ...
-a
Listen on the given IP address(es). Both --interface and --listen-address options may be given, in which case the set of bothinterfaces and addresses is used. Note that if no --interface option is given, but --listen-address is, dnsmasq will not auto‐matically listen on the loopback interface. To achieve this, its IP address, 127.0.0.1, must be explicitly given as a --lis‐ten-address option.
dnsmasq -a ...
-z
On systems which support it, dnsmasq binds the wildcard address, even when it is listening on only some interfaces. It thendiscards requests that it shouldn't reply to. This has the advantage of working even when interfaces come and go and changeaddress. This option forces dnsmasq to really bind only the interfaces it is listening on. About the only time when this isuseful is when running another nameserver (or another instance of dnsmasq) on the same machine. Setting this option alsoenables multiple instances of dnsmasq which provide DHCP service to run in the same machine.
dnsmasq -z ...
--bind-dynamic
Enable a network mode which is a hybrid between --bind-interfaces and the default. Dnsmasq binds the address of individualinterfaces, 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 itfalls-back to --bind-interfaces mode.
dnsmasq --bind-dynamic ...
-y
Return answers to DNS queries from /etc/hosts and --interface-name which depend on the interface over which the query wasreceived. If a name has more than one address associated with it, and at least one of those addresses is on the same subnet asthe interface to which the query was sent, then return only the address(es) on that subnet. This allows for a server to havemultiple addresses in /etc/hosts corresponding to each of its interfaces, and hosts will get the correct address based onwhich network they are attached to. Currently this facility is limited to IPv4.
dnsmasq -y ...
-b
Bogus private reverse lookups. All reverse lookups for private IP ranges (ie 192.168.x.x, etc) which are not found in/etc/hosts or the DHCP leases file are answered with "no such domain" rather than being forwarded upstream. The set of pre‐fixes affected is the list given in RFC6303, for IPv4 and IPv6.
dnsmasq -b ...
-V
Modify IPv4 addresses returned from upstream nameservers; old-ip is replaced by new-ip. If the optional mask is given then anyaddress which matches the masked old-ip will be re-written. So, for instance --alias=1.2.3.0,6.7.8.0,255.255.255.0 will map1.2.3.56 to 6.7.8.56 and 1.2.3.67 to 6.7.8.67. This is what Cisco PIX routers call "DNS doctoring". If the old IP is given asrange, then only addresses in the range, rather than a whole subnet, are re-written. So
dnsmasq -V ...
--alias
maps 192.168.0.10->192
dnsmasq --alias ...
-B
Transform replies which contain the IP address given into "No such domain" replies. This is intended to counteract a deviousmove made by Verisign in September 2003 when they started returning the address of an advertising web page in response toqueries for unregistered names, instead of the correct NXDOMAIN response. This option tells dnsmasq to fake the correctresponse when it sees this behaviour. As at Sept 2003 the IP address being returned by Verisign is 64.94.110.11
dnsmasq -B ...
--ignore-address
Ignore replies to A-record queries which include the specified address. No error is generated, dnsmasq simply continues tolisten for another reply. This is useful to defeat blocking strategies which rely on quickly supplying a forged answer to aDNS request for certain domain, before the correct answer can arrive.
dnsmasq --ignore-address ...
-f
Later versions of windows make periodic DNS requests which don't get sensible answers from the public DNS and can cause prob‐lems by triggering dial-on-demand links. This flag turns on an option to filter such requests. The requests blocked are forrecords of types SOA and SRV, and type ANY where the requested name has underscores, to catch LDAP requests.
dnsmasq -f ...
-r
Read the IP addresses of the upstream nameservers from <file>, instead of /etc/resolv.conf. For the format of this file seeresolv.conf(5). The only lines relevant to dnsmasq are nameserver ones. Dnsmasq can be told to poll more than one resolv.conffile, the first file name specified overrides the default, subsequent ones add to the list. This is only allowed whenpolling; the file with the currently latest modification time is the one used.
dnsmasq -r ...
-R
Don't read /etc/resolv.conf. Get upstream servers only from the command line or the dnsmasq configuration file.
dnsmasq -R ...
-1
Allow dnsmasq configuration to be updated via DBus method calls. The configuration which can be changed is upstream DNSservers (and corresponding domains) and cache clear. Requires that dnsmasq has been built with DBus support. If the servicename is given, dnsmasq provides service at that name, rather than the default which is uk.org.thekelleys.dnsmasq
dnsmasq -1 ...
-o
By default, dnsmasq will send queries to any of the upstream servers it knows about and tries to favour servers that are knownto be up. Setting this flag forces dnsmasq to try each query with each server strictly in the order they appear in/etc/resolv.conf
dnsmasq -o ...
--all-servers
By default, when dnsmasq has more than one upstream server available, it will send queries to just one server. Setting thisflag forces dnsmasq to send all queries to all available servers. The reply from the server which answers first will bereturned to the original requester.
dnsmasq --all-servers ...
--dns-loop-detect
Enable code to detect DNS forwarding loops; ie the situation where a query sent to one of the upstream server eventuallyreturns as a new query to the dnsmasq instance. The process works by generating TXT queries of the form <hex>.test and sendingthem to each upstream server. The hex is a UID which encodes the instance of dnsmasq sending the query and the upstream serverto which it was sent. If the query returns to the server which sent it, then the upstream server through which it was sent isdisabled and this event is logged. Each time the set of upstream servers changes, the test is re-run on all of them, includingones which were previously disabled.
dnsmasq --dns-loop-detect ...
--stop-dns-rebind
Reject (and log) addresses from upstream nameservers which are in the private IP ranges. This blocks an attack where a browserbehind a firewall is used to probe machines on the local network.
dnsmasq --stop-dns-rebind ...
--rebind-localhost-ok
Exempt 127.0.0.0/8 from rebinding checks. This address range is returned by realtime black hole servers, so blocking it maydisable these services.
dnsmasq --rebind-localhost-ok ...
--rebind-domain-ok
Do not detect and block dns-rebind on queries to these domains. The argument may be either a single domain, or multipledomains surrounded by '/', like the --server syntax, eg. --rebind-domain-ok=/domain1/domain2/domain3/
dnsmasq --rebind-domain-ok ...
-n
Don't poll /etc/resolv.conf for changes.
dnsmasq -n ...
--clear-on-reload
Whenever /etc/resolv.conf is re-read or the upstream servers are set via DBus, clear the DNS cache. This is useful when newnameservers may have different data than that held in cache.
dnsmasq --clear-on-reload ...
-D
Tells dnsmasq to never forward A or AAAA queries for plain names, without dots or domain parts, to upstream nameservers. Ifthe name is not known from /etc/hosts or DHCP then a "not found" answer is returned.
dnsmasq -D ...
-S
Specify IP address of upstream servers directly. Setting this flag does not suppress reading of /etc/resolv.conf, use -R to dothat. If one or more optional domains are given, that server is used only for those domains and they are queried only usingthe specified server. This is intended for private nameservers: if you have a nameserver on your network which deals withnames of the form xxx.internal.thekelleys.org.uk at 192.168.1.1 then giving the flag -S /internal.thekel‐leys.org.uk/192.168.1.1 will send all queries for internal machines to that nameserver, everything else will go to the serversin /etc/resolv.conf. DNSSEC validation is turned off for such private nameservers, UNLESS a --trust-anchor is specified forthe domain in question. An empty domain specification, // has the special meaning of "unqualified names only" ie names withoutany dots in them. A non-standard port may be specified as part of the IP address using a # character. More than one -S flagis allowed, with repeated domain or ipaddr parts as required.More specific domains take precedence over less specific domains, so: --server=/google.com/1.2.3.4
dnsmasq -S ...
--rev-server
This is functionally the same as --server, but provides some syntactic sugar to make specifying address-to-name queries eas‐ier. For example --rev-server=1.2.3.0/24,192.168.0.1 is exactly equivalent to --server=/3.2.1.in-addr.arpa/192.168.0.1
dnsmasq --rev-server ...
-A
Specify an IP address to return for any host in the given domains. Queries in the domains are never forwarded and alwaysreplied to with the specified IP address which may be IPv4 or IPv6. To give both IPv4 and IPv6 addresses for a domain, userepeated -A flags. To include multiple IP addresses for a single query, use --addn-hosts=<path> instead. Note that/etc/hosts and DHCP leases override this for individual names. A common use of this is to redirect the entire doubleclick.netdomain to some friendly local web server to avoid banner ads. The 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 querynot answered from /etc/hosts or DHCP and not sent to an upstream nameserver by a more specific --server directive. As for
dnsmasq -A ...
--server
one or more domains with no address returns a no-such-domain answer so --address=/example.com/ is equivalent to
dnsmasq --server ...
--ipset
Places the resolved IP addresses of queries for one or more domains in the specified Netfilter IP set. If multiple setnamesare given, then the addresses are placed in each of them, subject to the limitations of an IP set (IPv4 addresses cannot bestored in an IPv6 IP set and vice versa). Domains and subdomains are matched in the same way as --address. These IP setsmust already exist. See ipset(8) for more details.
dnsmasq --ipset ...
-m
Return an MX record named <mx name> pointing to the given hostname (if given), or the host specified in the --mx-target switchor, if that switch is not given, the host on which dnsmasq is running. The default is useful for directing mail from systemson a LAN to a central server. The preference value is optional, and defaults to 1 if not given. More than one MX record may begiven for a host.
dnsmasq -m ...
-t
Specify the default target for the MX record returned by dnsmasq. See --mx-host. If --mx-target is given, but not --mx-host,then dnsmasq returns a MX record containing the MX target for MX queries on the hostname of the machine on which dnsmasq isrunning.
dnsmasq -t ...
-e
Return an MX record pointing to itself for each local machine. Local machines are those in /etc/hosts or with DHCP leases.
dnsmasq -e ...
-L
Return an MX record pointing to the host given by mx-target (or the machine on which dnsmasq is running) for each localmachine. Local machines are those in /etc/hosts or with DHCP leases.
dnsmasq -L ...
-W
Return a SRV DNS record. See RFC2782 for details. If not supplied, the domain defaults to that given by --domain. The defaultfor the target domain is empty, and the default for port is one and the defaults for weight and priority are zero. Be carefulif transposing data from BIND zone files: the port, weight and priority numbers are in a different order. More than one SRVrecord for a given service/domain is allowed, all that match are returned.
dnsmasq -W ...
--host-record
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 host-record and therefore be assigned more than one address. Only the firstaddress creates a PTR record linking the address to the name. This is the same rule as is used reading hosts-files. host-record options are considered to be read before host-files, so a name appearing there inhibits PTR-record creation if itappears in hosts-file also. Unlike hosts-files, names are not expanded, even when expand-hosts is in effect. Short and longnames may appear in the same host-record, eg. --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100If the time-to-live is given, it overrides the default, which is zero or the value of --local-ttl. The value is a positiveinteger and gives the time-to-live in seconds.
dnsmasq --host-record ...
-Y
Return a TXT DNS record. The value of TXT record is a set of strings, so any number may be included, delimited by commas; usequotes to put commas into a string. Note that the maximum length of a single string is 255 characters, longer strings aresplit into 255 character chunks.
dnsmasq -Y ...
--ptr-record
Return a PTR DNS record.
dnsmasq --ptr-record ...
--naptr-record
Return an NAPTR DNS record, as specified in RFC3403.
dnsmasq --naptr-record ...
--cname
Return a CNAME record which indicates that <cname> is really <target>. There are significant limitations on the target; itmust be a DNS name which is known to dnsmasq from /etc/hosts (or additional hosts files), from DHCP, from --interface-name orfrom another --cname. If the target does not satisfy this criteria, the whole cname is ignored. The cname must be unique, butit is permissible to have more than one cname pointing to the same target. Indeed it's possible to declare multiple cnames toa target in a single line, like so: --cname=cname1,cname2,targetIf the time-to-live is given, it overrides the default, which is zero or the value of -local-ttl. The value is a positiveinteger and gives the time-to-live in seconds.
dnsmasq --cname ...
--dns-rr=<name>,<RR-number>,[<hex
Return an arbitrary DNS Resource Record. The number is the type of the record (which is always in the C_IN class). The valueof 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.
dnsmasq --dns-rr=<name>,<RR-number>,[<hex ...
--interface-name
Return DNS records associating the name with the address(es) of the given interface. This flag specifies an A or AAAA recordfor the given name in the same way as an /etc/hosts line, except that the address is not constant, but taken from the giveninterface. The interface may be followed by "/4" or "/6" to specify that only IPv4 or IPv6 addresses of the interface shouldbe used. If the interface is down, not configured or non-existent, an empty record is returned. The matching PTR record isalso created, mapping the interface address to the name. More than one name may be associated with an interface address byrepeating the flag; in that case the first instance is used for the reverse address-to-name mapping. Note that a name used in
dnsmasq --interface-name ...
--synth-domain=<domain>,<address
Create artificial A/AAAA and PTR records for an address range. The records either seqential numbers or the address, with peri‐ods (or colons for IPv6) replaced with dashes.An examples should make this clearer. First sequential numbers. --synth-domain=thekel‐leys.org.uk,192.168.0.50,192.168.0.70,internal-* results in the name internal-0.thekelleys.org.uk. returning 192.168.0.50,internal-1.thekelleys.org.uk returning 192.168.0.51 and so on. (note the *) The same principle applies to IPv6 addresses(where the numbers may be very large). Reverse lookups from address to name behave as expected.Second, --synth-domain=thekelleys.org.uk,192.168.0.0/24,internal- (no *) will result in a query for inter‐nal-192-168-0-56.thekelleys.org.uk returning 192.168.0.56 and a reverse query vice versa. The same applies to IPv6, but IPv6addresses may start with '::' but DNS labels may not start with '-' so in this case if no prefix is configured a zero is addedin front of the label. ::1 becomes 0--1.V4 mapped IPv6 addresses, which have a representation like ::ffff:1.2.3.4 are handled specially, and become like
dnsmasq --synth-domain=<domain>,<address ...
--ffff-1-2-3-4
The address range can be of the form <ip address>,<ip address> or <ip address>/<netmask> in both forms of the option.
dnsmasq --ffff-1-2-3-4 ...
--add-mac[
Add the MAC address of the requestor to DNS queries which are forwarded upstream. This may be used to DNS filtering by theupstream server. The MAC address can only be added if the requestor is on the same subnet as the dnsmasq server. Note that themechanism used to achieve this (an EDNS0 option) is not yet standardised, so this should be considered experimental. Also notethat exposing MAC addresses in this way may have security and privacy implications. The warning about caching given for --add-subnet applies to --add-mac too. An alternative encoding of the MAC, as base64, is enabled by adding the "base64" parameterand a human-readable encoding of hex-and-colons is enabled by added the "text" parameter.
dnsmasq --add-mac[ ...
--add-cpe-id
Add an arbitrary identifying string to o DNS queries which are forwarded upstream.
dnsmasq --add-cpe-id ...
--add-subnet[[=[<IPv4
Add a subnet address to the DNS queries which are forwarded upstream. If an address is specified in the flag, it will be used,otherwise, the address of the requestor will be used. The amount of the address forwarded depends on the prefix length parame‐ter: 32 (128 for IPv6) forwards the whole address, zero forwards none of it but still marks the request so that no upstreamnameserver will add client address information either. The default is zero for both IPv4 and IPv6. Note that upstream name‐servers 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.For example, --add-subnet=24,96 will add the /24 and /96 subnets of the requestor for IPv4 and IPv6 requestors, respectively.
dnsmasq --add-subnet[[=[<IPv4 ...
-c
Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching.
dnsmasq -c ...
-N
Disable negative caching. Negative caching allows dnsmasq to remember "no such domain" answers from upstream nameservers andanswer identical queries without forwarding them again.
dnsmasq -N ...
-0
Set the maximum number of concurrent DNS queries. The default value is 150, which should be fine for most setups. The onlyknown situation where this needs to be increased is when using web-server log file resolvers, which can generate large numbersof concurrent queries.
dnsmasq -0 ...
--dnssec
Validate DNS replies and cache DNSSEC data. When forwarding DNS queries, dnsmasq requests the DNSSEC records needed to vali‐date the replies. The replies are validated and the result returned as the Authenticated Data bit in the DNS packet. In addi‐tion the DNSSEC records are stored in the cache, making validation by clients more efficient. Note that validation by clientsis the most secure DNSSEC mode, but for clients unable to do validation, use of the AD bit set by dnsmasq is useful, providedthat the network between the dnsmasq server and the client is trusted. Dnsmasq must be compiled with HAVE_DNSSEC enabled, andDNSSEC trust anchors provided, see --trust-anchor. Because the DNSSEC validation process uses the cache, it is not permittedto 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 sta‐tus of answers. In the default mode, this means that all replies will be marked as untrusted. If --dnssec-check-unsigned isset and the upstream servers don't support DNSSEC, then DNS service will be entirely broken.
dnsmasq --dnssec ...
--trust-anchor
Provide DS records to act a trust anchors for DNSSEC validation. Typically these will be the DS record(s) for Key Signingkey(s) (KSK) of the root zone, but trust anchors for limited domains are also possible. The current root-zone trust anchorsmay be downloaded from https://data.iana.org/root-anchors/root-anchors.xml
dnsmasq --trust-anchor ...
--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 forsigned DNS zones, but it is fast. If this flag is set, dnsmasq will check the zones of unsigned replies, to ensure thatunsigned replies are allowed in those zones. The cost of this is more upstream queries and slower performance. See also thewarning about upstream servers in the section on --dnssec
dnsmasq --dnssec-check-unsigned ...
--dnssec-no-timecheck
DNSSEC signatures are only valid for specified time windows, and should be rejected outside those windows. This generates aninteresting chicken-and-egg problem for machines which don't have a hardware real time clock. For these machines to determinethe correct time typically requires use of NTP and therefore DNS, but validating DNS requires that the correct time is alreadyknown. Setting this flag removes the time-window checks (but not other DNSSEC validation.) only until the dnsmasq processreceives SIGINT. The intention is that dnsmasq should be started with this flag when the platform determines that reliabletime is not currently available. As soon as reliable time is established, a SIGINT should be sent to dnsmasq, which enablestime checking, and purges the cache of DNS records which have not been thoroughly checked.Earlier versions of dnsmasq overloaded SIGHUP (which re-reads much configuration) to also enable time validation.If dnsmasq is run in debug mode (-d flag) then SIGINT retains its usual meaning of terminating the dnsmasq process.
dnsmasq --dnssec-no-timecheck ...
--dnssec-timestamp
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 createdand its timestamp set automatically by dnsmasq. The file must be stored on a persistent filesystem, so that it and its mtimeare carried over system restarts. The timestamp file is created after dnsmasq has dropped root, so it must be in a locationwritable by the unprivileged user that dnsmasq runs as.
dnsmasq --dnssec-timestamp ...
--proxy-dnssec
Copy the DNSSEC Authenticated Data bit from upstream servers to downstream clients and cache it. This is an alternative tohaving dnsmasq validate DNSSEC, but it depends on the security of the network between dnsmasq and the upstream servers, andthe trustworthiness of the upstream servers.
dnsmasq --proxy-dnssec ...
--dnssec-debug
Set debugging mode for the DNSSEC validation, set the Checking Disabled bit on upstream queries, and don't convert replieswhich do not validate to responses with a return code of SERVFAIL. Note that setting this may affect DNS behaviour in badways, it is not an extra-logging flag and should not be set in production.
dnsmasq --dnssec-debug ...
--auth-soa
Specify fields in the SOA record associated with authoritative zones. Note that this is optional, all the values are set tosane defaults.
dnsmasq --auth-soa ...
--auth-sec-servers
Specify any secondary servers for a zone for which dnsmasq is authoritative. These servers must be configured to get zone datafrom dnsmasq by zone transfer, and answer queries for the same authoritative zones as dnsmasq.
dnsmasq --auth-sec-servers ...
--auth-peer
Specify the addresses of secondary servers which are allowed to initiate zone transfer (AXFR) requests for zones for whichdnsmasq is authoritative. If this option is not given, then AXFR requests will be accepted from any secondary.
dnsmasq --auth-peer ...
--conntrack
Read the Linux connection track mark associated with incoming DNS queries and set the same mark value on upstream traffic usedto answer those queries. This allows traffic generated by dnsmasq to be associated with the queries which cause it, useful forbandwidth accounting and firewalling. Dnsmasq must have conntrack support compiled in and the kernel must have conntrack sup‐port included and configured. This option cannot be combined with --query-port.
dnsmasq --conntrack ...
-F
--dhcp-range=[tag:<tag>[ tag:<tag>] ][set:<tag> ]<start-addr>[ <end-addr>|<mode>][ <netmask>[ <broadcast>]][ <lease time>]
dnsmasq -F ...
--dhcp-range
will look for addresses on eth0 and then create a range from <network>::1 to <network>::400. If the interface is assigned morethan one network, then the corresponding ranges will be automatically created, and then deprecated and finally removed againas the address is deprecated and then deleted. The interface name may have a final "*" wildcard. Note that just any address oneth0 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 ::
dnsmasq --dhcp-range ...
-G
Specify per host parameters for the DHCP server. This allows a machine with a particular hardware address to be always allo‐cated the same hostname, IP address and lease time. A hostname specified like this overrides any supplied by the DHCP clienton the machine. It is also allowable to omit the hardware address and include the hostname, in which case the IP address andlease times will apply to any machine claiming that name. For example --dhcp-host=00:20:e0:3b:13:af,wap,infinite tells dnsmasqto give the machine with hardware address 00:20:e0:3b:13:af the name wap, and an infinite DHCP lease. --dhcp-host=lap,192.168.0.199 tells dnsmasq to always allocate the machine lap the IP address 192.168.0.199.Addresses allocated like this are not constrained to be in the range given by the --dhcp-range option, but they must be in thesame 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 (called client DUID in IPv6-land) rather than hardware addresses to identify hosts byprefixing with 'id:'. Thus: --dhcp-host=id:01:02:03:04,..... refers to the host with client identifier 01:02:03:04. It isalso allowed to specify the client ID as text, like this: --dhcp-host=id:clientidastext,.....A single dhcp-host may contain an IPv4 address or an IPv6 address, or both. IPv6 addresses must be bracketed by square brack‐ets thus: --dhcp-host=laptop,[1234::56] IPv6 addresses may contain only the host-identifier part: --dhcp-host=laptop,[::56] inwhich case they act as wildcards in constructed dhcp ranges, with the appropriate network part inserted. Note that in IPv6DHCP, the hardware address may not be available, though it normally is for direct-connected clients, or clients using DHCPrelays 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 clientpresents a client-id sometimes but not others.If a name appears in /etc/hosts, the associated address can be allocated to a DHCP lease, but only if a --dhcp-host optionspecifying the name also exists. Only one hostname can be given in a dhcp-host option, but aliases are possible by usingCNAMEs. (See --cname ).The special keyword "ignore" tells dnsmasq to never offer a DHCP lease to a machine. The machine can be specified by hardwareaddress, client ID or hostname, for instance --dhcp-host=00:20:e0:3b:13:af,ignore This is useful when there is another DHCPserver on the network which should be used by some machines.The set:<tag> construct sets the tag whenever this dhcp-host directive is in use. This can be used to selectively send DHCPoptions just for this host. More than one tag can be set in a dhcp-host directive (but not in other places where "set:<tag>"is allowed). When a host matches any dhcp-host directive (or one implied by /etc/ethers) then the special tag "known" is set.This allows dnsmasq to be configured to ignore requests from unknown machines using --dhcp-ignore=tag:!known If the hostmatches only a dhcp-host directive which cannot be used because it specifies an address on different subnet, the tag "known-othernet" is set. Ethernet addresses (but not client-ids) may have wildcard bytes, so for example --dhcp-host=00:20:e0:3b:13:*,ignore will cause dnsmasq to ignore a range of hardware addresses. Note that the "*" will need to beescaped or quoted on a command line, but not in the configuration file.Hardware addresses normally match any network (ARP) type, but it is possible to restrict them to a single ARP type by preced‐ing them with the ARP-type (in HEX) and "-". so --dhcp-host=06-00:20:e0:3b:13:af,1.2.3.4 will only match a Token-Ring hardwareaddress, since the ARP-address type for token ring is 6.As a special case, in DHCPv4, it is possible to include more than one hardware address. eg: --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 multiple hardwareaddresses, and gives dnsmasq permission to abandon a DHCP lease to one of the hardware addresses when another one asks for alease. Beware that this is a dangerous thing to do, it will only work reliably if only one of the hardware addresses is activeat any time and there is no way for dnsmasq to enforce this. It is, for instance, useful to allocate a stable IP address to alaptop which has both wired and wireless interfaces.
dnsmasq -G ...
--dhcp-hostsfile
Read DHCP host information from the specified file. If a directory is given, then read all the files contained in that direc‐tory. The file contains information about one host per line. The format of a line is the same as text to the right of '=' in
dnsmasq --dhcp-hostsfile ...
--dhcp-optsfile
Read DHCP option information from the specified file. If a directory is given, then read all the files contained in thatdirectory. The advantage of using this option is the same as for --dhcp-hostsfile: the dhcp-optsfile will be re-read when dns‐masq receives SIGHUP. Note that it is possible to encode the information in a --dhcp-boot flag as DHCP options, using theoptions names bootfile-name, server-ip-address and tftp-server. This allows these to be included in a dhcp-optsfile.
dnsmasq --dhcp-optsfile ...
--dhcp-hostsdir
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 orchanged after it has been read by dnsmasq, then the host record it contained will remain until dnsmasq receives a SIGHUP, oris restarted; ie host records are only added dynamically.
dnsmasq --dhcp-hostsdir ...
--dhcp-optsdir
This is equivalent to dhcp-optsfile, with the differences noted for --dhcp-hostsdir.
dnsmasq --dhcp-optsdir ...
-Z
Read /etc/ethers for information about hosts for the DHCP server. The format of /etc/ethers is a hardware address, followed byeither a hostname or dotted-quad IP address. When read by dnsmasq these lines have exactly the same effect as --dhcp-hostoptions containing the same information. /etc/ethers is re-read when dnsmasq receives SIGHUP. IPv6 addresses are NOT read from/etc/ethers.
dnsmasq -Z ...
-O
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 net‐mask and broadcast address are set to the same as the host running dnsmasq, and the DNS server and default route are set tothe address of the machine running dnsmasq. (Equivalent rules apply for IPv6.) If the domain name option has been set, that issent. This configuration allows these defaults to be overridden, or other options specified. The option, to be sent may begiven as a decimal number or as "option:<option-name>" The option numbers are specified in RFC2132 and subsequent RFCs. Theset of option-names known by dnsmasq can be discovered by running "dnsmasq --help dhcp". For example, to set the defaultroute option to 192.168.4.4, do --dhcp-option=3,192.168.4.4 or --dhcp-option = option:router, 192.168.4.4 and to set the time-server address to 192.168.0.4, do --dhcp-option = 42,192.168.0.4 or --dhcp-option = option:ntp-server, 192.168.0.4 The specialaddress 0.0.0.0 is taken to mean "the address of the machine running dnsmasq".Data types allowed are comma separated dotted-quad IPv4 addresses, []-wrapped IPv6 addresses, a decimal number, colon-sepa‐rated hex digits and a text string. If the optional tags are given then this option is only sent when all the tags arematched.Special processing is done on a text argument for option 119, to conform with RFC 3397. Text or dotted-quad IP addresses asarguments to option 120 are handled as per RFC 3361. Dotted-quad IP addresses which are followed by a slash and then a netmasksize are encoded as described in RFC 3442.IPv6 options are specified using the option6: keyword, followed by the option number or option name. The IPv6 option namespace is disjoint from the IPv4 option name space. IPv6 addresses in options must be bracketed with square brackets, eg.
dnsmasq -O ...
--dhcp-no-override
(IPv4 only) Disable re-use of the DHCP servername and filename fields as extra option space. If it can, dnsmasq moves the bootserver and filename information (from dhcp-boot) out of their dedicated fields into DHCP options. This make extra space avail‐able in the DHCP packet for options but can, rarely, confuse old or broken clients. This flag forces "simple and safe" behav‐iour to avoid problems in such a case.
dnsmasq --dhcp-no-override ...
--dhcp-relay=<local
Configure dnsmasq to do DHCP relay. The local address is an address allocated to an interface on the host running dnsmasq. AllDHCP requests arriving on that interface will we relayed to a remote DHCP server at the server address. It is possible torelay from a single local address to multiple remote servers by using multiple dhcp-relay configs with the same local addressand different server addresses. A server address must be an IP literal address, not a domain name. In the case of DHCPv6, theserver 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. Theoptional interface name in the dhcp-relay config has a different function: it controls on which interface DHCP replies fromthe server will be accepted. This is intended for configurations which have three interfaces: one being relayed from, a secondconnecting the DHCP server, and a third untrusted network, typically the wider internet. It avoids the possibility of spoofreplies 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. Notethat 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.
dnsmasq --dhcp-relay=<local ...
-U
Map from a vendor-class string to a tag. Most DHCP clients provide a "vendor class" which represents, in some sense, the typeof host. This option maps vendor classes to tags, so that DHCP options may be selectively delivered to different classes ofhosts. For example dhcp-vendorclass=set:printers,Hewlett-Packard JetDirect will allow options to be set only for HP printerslike so: --dhcp-option=tag:printers,3,192.168.4.4 The vendor-class string is substring matched against the vendor-class sup‐plied by the client, to 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.
dnsmasq -U ...
-j
Map from a user-class string to a tag (with substring matching, like vendor classes). Most DHCP clients provide a "user class"which is configurable. This option maps user classes to tags, so that DHCP options may be selectively delivered to differentclasses of hosts. It is possible, for instance to use this to set a different printer server for hosts in the class "accounts"than for hosts in the class "engineering".
dnsmasq -j ...
-4
Map from a MAC address to a tag. The MAC address may include wildcards. For example --dhcp-mac=set:3com,01:34:23:*:*:* willset the tag "3com" for any host whose MAC address matches the pattern.
dnsmasq -4 ...
--dhcp-circuitid=set:<tag>,<circuit-id>,
Map from RFC3046 relay agent options to tags. This data may be provided by DHCP relay agents. The circuit-id or remote-id isnormally given as colon-separated hex, but is also allowed to be a simple string. If an exact match is achieved between thecircuit or agent ID and one provided by a relay agent, the tag is set.dhcp-remoteid (but not dhcp-circuitid) is supported in IPv6.
dnsmasq --dhcp-circuitid=set:<tag>,<circuit-id>, ...
--dhcp-subscrid
(IPv4 and IPv6) Map from RFC3993 subscriber-id relay agent options to tags.
dnsmasq --dhcp-subscrid ...
--dhcp-proxy[=<ip
(IPv4 only) A normal DHCP relay agent is only used to forward the initial parts of a DHCP interaction to the DHCP server. Oncea client is configured, it communicates directly with the server. This is undesirable if the relay agent is adding extrainformation to the DHCP packets, such as that used by dhcp-circuitid and dhcp-remoteid. A full relay implementation can usethe RFC 5107 serverid-override option to force the DHCP server to use the relay as a full proxy, with all packets passingthrough it. This flag provides an alternative method of doing the same thing, for relays which don't support RFC 5107. Givenalone, it manipulates the server-id for all interactions via relays. If a list of IP addresses is given, only interactions viarelays at those addresses are affected.
dnsmasq --dhcp-proxy[=<ip ...
--dhcp-match=set:<tag>,<option
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 tagonly 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 wildcards) but the option sent may have unmatched data past the end of the value. The value may also be of thesame form as in dhcp-option in which case the option sent is treated as an array, and one element must match, so
dnsmasq --dhcp-match=set:<tag>,<option ...
--dhcp-match
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 RFC4578 for details.) If the value is a string, substring matching is used.The special form with vi-encap:<enterprise number> matches against vendor-identifying vendor classes for the specified enter‐prise. Please see RFC 3925 for more details of these rare and interesting beasts.
dnsmasq --dhcp-match ...
--tag-if
Perform boolean operations on tags. Any tag appearing as set:<tag> is set if all the tags which appear as tag:<tag> are set,(or unset when tag:!<tag> is used) If no tag:<tag> appears set:<tag> tags are set unconditionally. Any number of set: andtag: forms may appear, in any order. Tag-if lines are executed in order, so if the tag in tag:<tag> is a tag set by anothertag-if, the line which sets the tag must precede the one which tests it.
dnsmasq --tag-if ...
-J
When all the given tags appear in the tag set ignore the host and do not allocate it a DHCP lease.
dnsmasq -J ...
--dhcp-ignore-names[
When all the given tags appear in the tag set, ignore any hostname provided by the host. Note that, unlike dhcp-ignore, it ispermissible to supply no tags, in which case DHCP-client supplied hostnames are always ignored, and DHCP hosts are added tothe DNS using only dhcp-host configuration in dnsmasq and the contents of /etc/hosts and /etc/ethers.
dnsmasq --dhcp-ignore-names[ ...
--dhcp-generate-names
(IPv4 only) Generate a name for DHCP clients which do not otherwise have one, using the MAC address expressed in hex, sepa‐rated by dashes. Note that if a host provides a name, it will be used by preference to this, unless --dhcp-ignore-names isset.
dnsmasq --dhcp-generate-names ...
--dhcp-broadcast[
(IPv4 only) When all the given tags appear in the tag set, always use broadcast to communicate with the host when it is uncon‐figured. It is permissible to supply no tags, in which case this is unconditional. Most DHCP clients which need broadcastreplies set a flag in their requests so that this happens automatically, some old BOOTP clients do not.
dnsmasq --dhcp-broadcast[ ...
-M
(IPv4 only) Set BOOTP options to be returned by the DHCP server. Server name and address are optional: if not provided, thename is left empty, and the address set to the address of the machine running dnsmasq. If dnsmasq is providing a TFTP service(see --enable-tftp ) 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. Instead of an IP address, the TFTP server address can be given as a domainname which is looked up in /etc/hosts. This name can be associated in /etc/hosts with multiple IP addresses, which are usedround-robin. This facility can be used to load balance the tftp load among a set of servers.
dnsmasq -M ...
--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 aclient's address to remain stable long-term, even if the client sometimes allows its DHCP lease to expire. In this defaultmode 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 low‐est available address, and setting this flag enables this mode. Note that in the sequential mode, clients which allow a leaseto expire are much more likely to move IP address; for this reason it should not be generally used.
dnsmasq --dhcp-sequential-ip ...
--pxe-prompt
Setting this provides a prompt to be displayed after PXE boot. If the timeout is given then after the timeout has elapsed withno keyboard input, the first available menu option will be automatically executed. If the timeout is zero then the firstavailable menu item will be executed immediately. If pxe-prompt is omitted the system will wait for user input if there aremultiple items in the menu, but boot immediately if there is only one. See pxe-service for details of menu items.Dnsmasq supports PXE "proxy-DHCP", in this case another DHCP server on the network is responsible for allocating IP addresses,and dnsmasq simply provides the information given in pxe-prompt and pxe-service to allow netbooting. This mode is enabledusing the proxy keyword in dhcp-range.
dnsmasq --pxe-prompt ...
-X
Limits dnsmasq to the specified maximum number of DHCP leases. The default is 1000. This limit is to prevent DoS attacks fromhosts which create thousands of leases and use lots of memory in the dnsmasq process.
dnsmasq -X ...
-K
Should be set when dnsmasq is definitely the only DHCP server on a network. For DHCPv4, it changes the behaviour from strictRFC compliance so that DHCP requests on unknown leases from unknown hosts are not ignored. This allows new hosts to get alease without a tedious timeout under all circumstances. It also allows dnsmasq to rebuild its lease database without eachclient needing to 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).
dnsmasq -K ...
--dhcp-alternate-port[=<server
(IPv4 only) Change the ports used for DHCP from the default. If this option is given alone, without arguments, it changes theports used for DHCP from 67 and 68 to 1067 and 1068. If a single argument is given, that port number is used for the serverand the port number plus one used for the client. Finally, two port numbers allows arbitrary specification of both server andclient ports for DHCP.
dnsmasq --dhcp-alternate-port[=<server ...
-3
(IPv4 only) Enable dynamic allocation of IP addresses to BOOTP clients. Use this with care, since each address allocated to aBOOTP client is leased forever, and therefore becomes permanently unavailable for re-use by other hosts. if this is givenwithout tags, then it unconditionally enables dynamic allocation. With tags, only when the tags are all set. It may berepeated with different tag sets.
dnsmasq -3 ...
-5
(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 addressmust already be in use, and another is tried. This flag disables this check. Use with caution.
dnsmasq -5 ...
--log-dhcp
Extra logging for DHCP: log all the options sent to DHCP clients and the tags used to determine them.
dnsmasq --log-dhcp ...
--quiet-dhcp
Suppress logging of the routine operation of these protocols. Errors and problems will still be logged. --quiet-dhcp andquiet-dhcp6 are over-ridden by --log-dhcp.
dnsmasq --quiet-dhcp ...
-l
Use the specified file to store DHCP lease information.
dnsmasq -l ...
--dhcp-duid
(IPv6 only) Specify the server persistent UID which the DHCPv6 server will use. This option is not normally required as dns‐masq creates a DUID automatically when it is first needed. When given, this option provides dnsmasq the data required to cre‐ate a DUID-EN type DUID. Note that once set, the DUID is stored in the lease database, so to change between DUID-EN and auto‐matically created DUIDs or vice-versa, the lease database must be re-initialised. The enterprise-id is assigned by IANA, andthe uid is a string of hex octets unique to a particular device.
dnsmasq --dhcp-duid ...
-6
Whenever a new DHCP lease is created, or an old one destroyed, or a TFTP file transfer completes, the executable specified bythis 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 (or DUID for IPv6) , the IP address, and the hostname, if known. "add" means alease has been created, "del" means it has been destroyed, "old" is a notification of an existing lease when dnsmasq starts ora change to MAC address or hostname of an existing lease (also, lease length or expiry and client-id, if leasefile-ro is set).If the MAC address is from a network type other than ethernet, it will have the network type prepended, eg"06-01:23:45:67:89:ab" for token ring. The process is run as root (assuming that dnsmasq was originally run as root) even ifdnsmasq 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 addedFor 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 host‐name passed to the script as an argument is never fully-qualified.)If the client provides a hostname, DNSMASQ_SUPPLIED_HOSTNAMEIf the client provides user-classes, DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSnIf dnsmasq was compiled with HAVE_BROKEN_RTC, then the length of the lease (in seconds) is stored in DNSMASQ_LEASE_LENGTH,otherwise the time of lease expiry is stored in DNSMASQ_LEASE_EXPIRES. The number of seconds until lease expiry is alwaysstored in DNSMASQ_TIME_REMAINING.If a lease used to have a hostname, which is removed, an "old" event is generated with the new state of the lease, ie no name,and the former name is provided in the environment variable DNSMASQ_OLD_HOSTNAME.DNSMASQ_INTERFACE stores the name of the interface on which the request arrived; this is not set for "old" actions when dns‐masq restarts.DNSMASQ_RELAY_ADDRESS is set if the client used a DHCP relay to contact dnsmasq and the IP address of the relay is known.DNSMASQ_TAGS contains all the tags set during the DHCP transaction, separated by spaces.DNSMASQ_LOG_DHCP is set if --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.DNSMASQ_REQUESTED_OPTIONS a string containing the decimal values in the Parameter Request List option, comma separated, if theparameter request list option is provided by the client.For IPv6 only:If the client provides vendor-class, DNSMASQ_VENDOR_CLASS_ID, containing the IANA enterprise id for the class, and DNS‐MASQ_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 ahost resumes an existing lease, since these data are not held in dnsmasq's lease database.All file descriptors are closed except stdin, which is open to /dev/null, and stdout and stderr which capture output for log‐ging by dnsmasq. (In debug mode, stdio, stdout and stderr file are left as those inherited from the invoker of dnsmasq).The script is not invoked concurrently: at most one instance of the script is ever running (dnsmasq waits for an instance ofscript to exit before running the next). Changes to the lease database are which require the script to be invoked are queuedawaiting exit of a running instance. If this queueing allows multiple state changes occur to a single lease before the scriptcan be run then earlier states are discarded and the current state of that lease is reflected when the script finally runs.At dnsmasq startup, the script will be invoked for all existing leases as they are read from the lease file. Expired leaseswill be called with "del" and others with "old". When dnsmasq receives a HUP signal, the script will be invoked for existingleases with an "old" event.There are four further actions which may appear as the first argument to the script, "init", "arp-add", "arp-del" and "tftp".More may be added in the future, so scripts should be written to ignore unknown actions. "init" is described below in --lease‐file-ro The "tftp" action is invoked when a TFTP file transfer completes: the arguments are the file size in bytes, theaddress to which the file was sent, and the complete pathname of the file.The "arp-add" and "arp-del" actions are only called if enabled with --script-arp They are are supplied with a MAC address andIP address as arguments. "arp-add" indicates the arrival of a new entry in the ARP or neighbour table, and "arp-del" indicatesthe deletion of same.
dnsmasq -6 ...
--dhcp-luascript
Specify a script written in Lua, to be run when leases are created, destroyed or changed. To use this option, dnsmasq must becompiled with the correct support. The Lua interpreter is initialised once, when dnsmasq starts, so that global variables per‐sist between lease events. The Lua code must define a lease function, and may provide init and shutdown functions, which arecalled, without arguments when dnsmasq starts up and terminates. It may also provide a tftp function.The lease function receives the information detailed in --dhcp-script. It gets two arguments, firstly the action, which is astring containing, "add", "old" or "del", and secondly a table of tag value pairs. The tags mostly correspond to the environ‐ment 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 --dhcp-script. These are mac_address, ip_address andhostname for IPv4, and client_duid, ip_address and hostname for IPv6.The tftp function is called in the same way as the lease function, and the table holds the tags destination_address, file_nameand file_size.The arp and arp-old functions are called only when enabled with --script-arp and have a table which holds the tags mac_addressand client_address.
dnsmasq --dhcp-luascript ...
--dhcp-scriptuser
Specify the user as which to run the lease-change script or Lua script. This defaults to root, but can be changed to anotheruser using this flag.
dnsmasq --dhcp-scriptuser ...
--script-arp
Enable the "arp" and "arp-old" functions in the dhcp-script and dhcp-luascript.
dnsmasq --script-arp ...
-9
Completely suppress use of the lease database file. The file will not be created, read, or written. Change the way the lease-change script (if one is provided) is called, so that the lease database may be maintained in external storage by the script.In addition to the invocations given in --dhcp-script the lease-change script is called once, at dnsmasq startup, with thesingle argument "init". When called like this the script should write the saved state of the lease database, in dnsmasq lease‐file format, to stdout and exit with zero exit code. Setting this option also forces the leasechange script to be called onchanges to the client-id and lease length and expiry time.
dnsmasq -9 ...
--bridge-interface
Treat DHCP (v4 and v6) requests and IPv6 Router Solicit packets arriving at any of the <alias> interfaces as if they hadarrived at <interface>. This option allows dnsmasq to provide DHCP and RA service over unaddressed and unbridged Ethernetinterfaces, e.g. on an OpenStack compute host where each such interface is a TAP interface to a VM, or as in "old style bridg‐ing" on BSD platforms. A trailing '*' wildcard can be used in each <alias>.It is permissible to add more than one alias using more than one --bridge-interface option since --bridge-inter‐face=int1,alias1,alias2 is exactly equivalent to --bridge-interface=int1,alias1 --bridge-interface=int1,alias2
dnsmasq --bridge-interface ...
-s
Specifies DNS domains for the DHCP server. Domains may be be given unconditionally (without the IP range) or for limited IPranges. This has two effects; firstly it causes the DHCP server to return the domain to any hosts which request it, and sec‐ondly it sets the domain which it is legal for DHCP-configured hosts to claim. The intention is to constrain hostnames so thatan untrusted host on the LAN cannot advertise its name via dhcp as e.g. "microsoft.com" and capture traffic not meant for it.If no domain suffix is specified, then any DHCP hostname with a domain part (ie with a period) will be disallowed and logged.If suffix is specified, then hostnames with a domain part are allowed, provided the domain part matches the suffix. In addi‐tion, when a suffix is set then hostnames without a domain part have the suffix added as an optional domain part. Eg on mynetwork I can set --domain=thekelleys.org.uk and have a machine whose DHCP hostname is "laptop". The IP address for thatmachine is available from dnsmasq both as "laptop" and "laptop.thekelleys.org.uk". If the domain is given as "#" then thedomain is read from the first "search" directive in /etc/resolv.conf (or equivalent).The address range can be of the form <ip address>,<ip address> or <ip address>/<netmask> or just a single <ip address>. See
dnsmasq -s ...
--dhcp-fqdn
If the address range is given as ip-address/network-size, then a additional flag "local" may be supplied which has the effectof adding --local declarations for forward and reverse DNS queries. Eg. --domain=thekelleys.org.uk,192.168.0.0/24,local isidentical to --domain=thekelleys.org.uk,192.168.0.0/24 --local=/thekelleys.org.uk/ --local=/0.168.192.in-addr.arpa/ The net‐work size must be 8, 16 or 24 for this to be legal.
dnsmasq --dhcp-fqdn ...
--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 withits name and IP address. This is because the name-IP pair is automatically added into dnsmasq's DNS view. This flag suppressesthat behaviour, this is useful, for instance, to allow Windows clients to update Active Directory servers. See RFC 4702 fordetails.
dnsmasq --dhcp-client-update ...
--enable-ra
Enable dnsmasq's IPv6 Router Advertisement feature. DHCPv6 doesn't handle complete network configuration in the same way asDHCPv4. 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 providemost data. When RA is enabled, dnsmasq will advertise a prefix for each dhcp-range, with default router as the relevant link-local address on the machine running dnsmasq. By default, the "managed address" bits are set, and the "use SLAAC" bit isreset. This can be changed for individual subnets with the mode keywords described in --dhcp-range. RFC6106 DNS parametersare included in the advertisements. By default, the relevant link-local address of the machine running dnsmasq is sent asrecursive DNS server. If provided, the DHCPv6 options dns-server and domain-search are used for the DNS server (RDNSS) and thedomain search list (DNSSL).
dnsmasq --enable-ra ...
--dhcp-reply-delay
Delays sending DHCPOFFER and proxydhcp replies for at least the specified number of seconds. This can be used as workaroundfor bugs in PXE boot firmware that does not function properly when receiving an instant reply. This option takes into accountthe time already spent waiting (e.g. performing ping check) if any.
dnsmasq --dhcp-reply-delay ...
--enable-tftp[
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). Without an argument, the TFTP serviceis provided to the same set of interfaces as DHCP service. If the list of interfaces is provided, that defines which inter‐faces receive TFTP service.
dnsmasq --enable-tftp[ ...
--tftp-root
Look for files to transfer using TFTP relative to the given directory. When this is set, TFTP paths which include ".." arerejected, to stop clients getting outside the specified root. Absolute paths (starting with /) are allowed, but they must bewithin the tftp-root. If the optional interface argument is given, the directory is only used for TFTP requests via thatinterface.
dnsmasq --tftp-root ...
--tftp-no-fail
Do not abort startup if specified tftp root directories are inaccessible.
dnsmasq --tftp-no-fail ...
--tftp-unique-root[
Add the IP or hardware address of the TFTP client as a path component on the end of the TFTP-root. Only valid if a tftp-rootis set and the directory exists. Defaults to adding IP address (in standard dotted-quad format). For instance, if tftp-rootis "/tftp" and client 1.2.3.4 requests file "myfile" then the effective path will be "/tftp/1.2.3.4/myfile" if /tftp/1.2.3.4exists or /tftp/myfile otherwise. When "=mac" is specified it will append the MAC address instead, using lowercase zeropadded digits separated by dashes, e.g.: 01-02-03-04-aa-bb Note that resolving MAC addresses is only possible if the client isin the local network or obtained a DHCP lease from us.
dnsmasq --tftp-unique-root[ ...
--tftp-secure
Enable TFTP secure mode: without this, any file which is readable by the dnsmasq process under normal unix access-controlrules is available via TFTP. When the --tftp-secure flag is given, only files owned by the user running the dnsmasq processare accessible. If dnsmasq is being run as root, different rules apply: --tftp-secure has no effect, but only files which havethe world-readable bit set are accessible. It is not recommended to run dnsmasq as root with TFTP enabled, and certainly notwithout specifying --tftp-root. Doing so can expose any world-readable file on the server to any host on the net.
dnsmasq --tftp-secure ...
--tftp-lowercase
Convert filenames in TFTP requests to all lowercase. This is useful for requests from Windows machines, which have case-insen‐sitive filesystems and tend to play fast-and-loose with case in filenames. Note that dnsmasq's tftp server always converts"\" to "/" in filenames.
dnsmasq --tftp-lowercase ...
--tftp-max
Set the maximum number of concurrent TFTP connections allowed. This defaults to 50. When serving a large number of TFTP con‐nections, per-process file descriptor limits may be encountered. Dnsmasq needs one file descriptor for each concurrent TFTPconnection and one file descriptor per unique file (plus a few others). So serving the same file simultaneously to n clientswill use require about n + 10 file descriptors, serving different files simultaneously to n clients will require about (2*n) +10 descriptors. If --tftp-port-range is given, that can affect the number of concurrent connections.
dnsmasq --tftp-max ...
--tftp-mtu=<mtu
Use size as the ceiling of the MTU supported by the intervening network when negotiating TFTP blocksize, overriding the MTUsetting of the local interface if it is larger.
dnsmasq --tftp-mtu=<mtu ...
--tftp-no-blocksize
Stop the TFTP server from negotiating the "blocksize" option with a client. Some buggy clients request this option but thenbehave badly when it is granted.
dnsmasq --tftp-no-blocksize ...
--tftp-port-range
A TFTP server listens on a well-known port (69) for connection initiation, but it also uses a dynamically-allocated port foreach connection. Normally these are allocated by the OS, but this option specifies a range of ports for use by TFTP transfers.This can be useful when TFTP has to traverse a firewall. The start of the range cannot be lower than 1025 unless dnsmasq isrunning as root. The number of concurrent TFTP connections is limited by the size of the port range.
dnsmasq --tftp-port-range ...
-C
Specify a different configuration file. The conf-file option is also allowed in configuration files, to include multiple con‐figuration files. A filename of "-" causes dnsmasq to read configuration from stdin.
dnsmasq -C ...
-7
Read all the files in the given directory as configuration files. If extension(s) are given, any files which end in thoseextensions are skipped. Any files whose names end in ~ or start with . or start and end with # are always skipped. If theextension starts with * then only files which have that extension are loaded. So --conf-dir=/path/to/dir,*.conf loads allfiles with the suffix .conf in /path/to/dir. This flag may be given on the command line or in a configuration file. If givingit on the command line, be sure to escape * characters.
dnsmasq -7 ...
--servers-file
A special case of --conf-file which differs in two respects. Firstly, only --server and --rev-server are allowed in the con‐figuration file included. Secondly, the file is re-read and the configuration therein is updated when dnsmasq receives SIGHUP.CONFIG FILEAt startup, dnsmasq reads /etc/dnsmasq.conf, if it exists. (On FreeBSD, the file is /usr/local/etc/dnsmasq.conf ) (but see the -C and
dnsmasq --servers-file ...
--mx-host
--srv-host --dns-rr --txt-record --naptr-record as long as the record names are in the authoritative domain.
dnsmasq --mx-host ...
-
Dnsmasq successfully forked into the background, or terminated normally if backgrounding is not enabled.
dnsmasq - ...