table of contents
DNSMASQ(8) | System Manager's Manual | DNSMASQ(8) |
NAME¶
dnsmasq - A lightweight DHCP and caching DNS server.SYNOPSIS¶
dnsmasq [OPTION]...DESCRIPTION¶
dnsmasq is a lightweight DNS, TFTP 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. 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. 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. Dnsmasq supports IPv6 for all functions and a minimal router-advertisement daemon.OPTIONS¶
Note that in general missing parameters are allowed and switch off functions, for instance "--pid-file" disables writing a PID file. On BSD, unless the GNU getopt library is linked, the long form of the options does not work on the command line; it is still recognised in the configuration file.- --test
- Read and syntax check configuration file(s). Exit with code 0 if all is OK, or a non-zero code otherwise. Do not start up dnsmasq.
- -h, --no-hosts
- Don't read the hostnames in /etc/hosts.
- -H, --addn-hosts=<file>
- Additional hosts file. Read the specified file as well as /etc/hosts. If -h is given, read 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.
- -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 apply to domain names in cnames, PTR records, TXT records etc.
- -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 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 data under some circumstances.
- --neg-ttl=<time>
- Negative replies from upstream servers normally contain time-to-live information in SOA records which dnsmasq uses for caching. If the replies from upstream servers omit this information, dnsmasq does not cache the reply. This option gives a default value for time-to-live (in seconds) which dnsmasq uses to cache negative replies even in the absence of an SOA record.
- --max-ttl=<time>
- Set a maximum TTL value that will be handed out to clients. The specified 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.
- -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 or launchd.
- -d, --no-daemon
- 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.
- -q, --log-queries
- Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1.
- -8, --log-facility=<facility>
- Set the facility to which dnsmasq will send syslog entries, this defaults to DAEMON, and to LOCAL0 when debug mode is in operation. If the facility given contains at least one '/' character, it is taken to be a filename, and dnsmasq logs to the given file, instead of syslog. If the facility is '-' then dnsmasq logs to stderr. (Errors whilst reading configuration will still go to syslog, but all output from a successful startup, and all output whilst running, will go exclusively to the file.) When logging to a file, dnsmasq will close and reopen the file when it receives SIGUSR2. This allows the log file to be rotated without stopping dnsmasq.
- --log-async[=<lines>]
- Enable asynchronous logging and optionally set the limit on the number of lines which will be queued by dnsmasq when writing to the syslog is slow. Dnsmasq can log asynchronously: this allows it to continue functioning without being blocked by syslog, and allows syslog to use dnsmasq for DNS queries without risking deadlock. If the queue of log-lines becomes full, dnsmasq will log the overflow, and the number of messages lost. The default queue length is 5, a sane value would be 5-25, and a maximum limit of 100 is imposed.
- -x, --pid-file=<path>
- Specify an alternate path for dnsmasq to record its process-id in. Normally /var/run/dnsmasq.pid.
- -u, --user=<username>
- Specify the userid to which dnsmasq will change after startup. Dnsmasq must normally be started as root, but it will drop root privileges after startup by changing id to another user. Normally this user is "nobody" but that can be over-ridden with this switch.
- -g, --group=<groupname>
- Specify the group which dnsmasq will run as. The defaults to "dip", if available, to facilitate access to /etc/ppp/resolv.conf which is not normally world readable.
- -v, --version
- Print the version number.
- -p, --port=<port>
- Listen on <port> instead of the standard DNS port (53). Setting this to zero completely disables DNS function, leaving only DHCP and/or TFTP.
- -P, --edns-packet-max=<size>
- Specify the largest EDNS.0 UDP packet which is supported by the DNS forwarder. Defaults to 4096, which is the RFC5625-recommended size.
- -Q, --query-port=<query_port>
- Send outbound DNS queries from, and listen for their replies on, the specific UDP port <query_port> instead of using random ports. NOTE that using this option will make dnsmasq less secure against DNS spoofing attacks but it may be faster and use less resources. Setting this option to zero makes dnsmasq use a single port allocated to it by the OS: this was the default behaviour in versions prior to 2.43.
- --min-port=<port>
- Do not use ports less than that given as source for outbound DNS queries. Dnsmasq picks random ports as source for outbound queries: when this option is given, the ports used will always to larger than that specified. Useful for systems behind firewalls.
- -i, --interface=<interface name>
- Listen only on the specified interface(s). Dnsmasq automatically adds the loopback (local) interface to the list of interfaces to use when the --interface option is used. If no --interface or --listen-address options are given dnsmasq listens on all available interfaces except any given in --except-interface options. IP alias interfaces (eg "eth1:0") cannot be used with --interface or --except-interface options, use --listen-address instead.
- -I, --except-interface=<interface name>
- Do not listen on the specified interface. Note that the order of --listen-address --interface and --except-interface options does not matter and that --except-interface options always override the others.
- -2, --no-dhcp-interface=<interface name>
- Do not provide DHCP or TFTP on the specified interface, but do provide DNS service.
- -a, --listen-address=<ipaddr>
- Listen on the given IP address(es). Both --interface and --listen-address options may be given, in which case the set of both interfaces and addresses is used. Note that if no --interface option is given, but --listen-address is, dnsmasq will not automatically listen on the loopback interface. To achieve this, its IP address, 127.0.0.1, must be explicitly given as a --listen-address option.
- -z, --bind-interfaces
- On systems which support it, dnsmasq binds the wildcard address, even when it is listening on only some interfaces. It then discards requests that it shouldn't reply to. This has the advantage of working even when interfaces come and go and change address. This option forces dnsmasq to really bind only the interfaces it is listening on. About the only time when this is useful is when 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.
- -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 it, and at least one of those addresses is on the same subnet as the interface to which the query was sent, then return only the address(es) on that subnet. This allows for a server to have multiple addresses in /etc/hosts corresponding to each of its interfaces, and hosts will get the correct address based on which network they are attached to. Currently this facility is limited to IPv4.
- -b, --bogus-priv
- 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.
- -V, --alias=[<old-ip>]|[<start-ip>-<end-ip>],<new-ip>[,<mask>]
- Modify IPv4 addresses returned from upstream nameservers; old-ip is replaced by new-ip. If the optional mask is given then any address 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 map 1.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 as range, then only addresses in the range, rather than a whole subnet, are re-written. So --alias=192.168.0.10-192.168.0.40,10.0.0.0,255.255.255.0 maps 192.168.0.10->192.168.0.40 to 10.0.0.10->10.0.0.40
- -B, --bogus-nxdomain=<ipaddr>
- Transform replies which contain the IP address given into "No such domain" replies. This is intended to counteract a devious move made by Verisign in September 2003 when they started returning the address of 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
- -f, --filterwin2k
- Later versions of windows make periodic DNS requests which don't get sensible answers from the public DNS and can cause problems by triggering dial-on-demand links. This flag turns on an option to filter such requests. The requests blocked are for records of types SOA and SRV, and type ANY where the requested name has underscores, to catch LDAP requests.
- -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 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 time is the one used.
- -R, --no-resolv
- Don't read /etc/resolv.conf. Get upstream servers only from the command line or the dnsmasq configuration file.
- -1, --enable-dbus
- 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.
- -o, --strict-order
- By default, dnsmasq will send queries to any of the upstream servers it knows about and tries to favour servers that are known to be up. Setting this flag forces dnsmasq to try each query with each server strictly in the order they appear in /etc/resolv.conf
- --all-servers
- 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 requester.
- --stop-dns-rebind
- Reject (and log) addresses from upstream nameservers which are in the private IP ranges. This blocks an attack where a browser behind a firewall is used to probe machines on the local network.
- --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 may disable these services.
- --rebind-domain-ok=[<domain>]|[[/<domain>/[<domain>/]
- Do not detect and block dns-rebind on queries to these domains. The argument may be either a single domain, or multiple domains surrounded by '/', like the --server syntax, eg. --rebind-domain-ok=/domain1/domain2/domain3/
- -n, --no-poll
- Don't poll /etc/resolv.conf for changes.
- --clear-on-reload
- Whenever /etc/resolv.conf is re-read, clear the DNS cache. This is useful when new nameservers may have different data than that held in cache.
- -D, --domain-needed
- 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.
- -S, --local, --server=[/[<domain>]/[domain/]][<ipaddr>[#<port>][@<source-ip>|<interface>[#<port>]]
- Specify IP address of upstream servers directly. Setting
this flag does not suppress reading of /etc/resolv.conf, use -R to do
that. If one or more optional domains are given, that server is used only
for those domains and they are queried only using the specified server.
This is intended for private nameservers: if you have a nameserver on your
network which deals with names of the form xxx.internal.thekelleys.org.uk
at 192.168.1.1 then giving the flag -S
/internal.thekelleys.org.uk/192.168.1.1 will send all queries for
internal machines to that nameserver, everything else will go to the
servers in /etc/resolv.conf. An empty domain specification, // has
the special meaning of "unqualified names only" ie names without
any dots in them. A non-standard port may be specified as part of the IP
address using a # character. More than one -S flag is allowed, with
repeated domain or ipaddr parts as required.
- -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 both IPv4 and IPv6 addresses for a domain, use repeated -A flags. Note that /etc/hosts and DHCP leases override this for individual names. A common use of this is to redirect the entire doubleclick.net domain 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 query not answered from /etc/hosts or DHCP and not sent to an upstream nameserver by a more specific --server directive.
- -m, --mx-host=<mx name>[[,<hostname>],<preference>]
- Return an MX record named <mx name> pointing to the given hostname (if given), or the host specified in the --mx-target switch or, if that switch is not given, the host on which dnsmasq is running. The default is useful for directing mail from systems on a LAN to a central server. The preference value is optional, and defaults to 1 if not given. More than one MX record may be given for a host.
- -t, --mx-target=<hostname>
- 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 is running.
- -e, --selfmx
- Return an MX record pointing to itself for each local machine. Local machines are those in /etc/hosts or with DHCP leases.
- -L, --localmx
- Return an MX record pointing to the host given by mx-target (or the machine on which dnsmasq is running) for each local machine. Local machines are those in /etc/hosts or with DHCP leases.
- -W, --srv-host=<_service>.<_prot>.[<domain>],[<target>[,<port>[,<priority>[,<weight>]]]]
- Return a SRV DNS record. See RFC2782 for details. If not supplied, the domain defaults to that given by --domain. The default for the target domain is empty, and the default for port is one and the defaults for weight and priority are zero. Be careful if transposing data from BIND 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.
- --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 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. 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 expand-hosts is in effect. Short and long names may appear in the same host-record, eg. --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100
- -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 commas into a string. Note that the maximum length of a single string is 255 characters, longer strings are split into 255 character chunks.
- --ptr-record=<name>[,<target>]
- Return a PTR DNS record.
- --naptr-record=<name>,<order>,<preference>,<flags>,<service>,<regexp>[,<replacement>]
- Return an NAPTR DNS record, as specified in RFC3403.
- --cname=<cname>,<target>
- 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 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.
- --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 for 01:23:45 or 01 23 45 or 012345 or any mixture of these.
- --interface-name=<name>,<interface>
- Return a DNS record associating the name with the primary address on the given interface. This flag specifies an A 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 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.
- --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 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.
- -c, --cache-size=<cachesize>
- Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching.
- -N, --no-negcache
- Disable negative caching. Negative caching allows dnsmasq to remember "no such domain" answers from upstream nameservers and answer identical queries without forwarding them again.
- -0, --dns-forward-max=<queries>
- Set the maximum number of concurrent DNS queries. The default value is 150, which should be fine for most setups. The only known situation where this needs to be increased is when using web-server log file resolvers, which can generate large numbers of concurrent queries.
- --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 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.
- --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.
- -F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<start-addr>[,<end-addr>][,<mode>][,<netmask>[,<broadcast>]][,<lease time>]
- -F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<start-IPv6addr>[,<end-IPv6addr>][,<mode>][,<prefix-len>][,<lease time>]
-
- -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 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 --dhcp-host=00:20:e0:3b:13:af,wap,infinite
tells dnsmasq to 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.
- --dhcp-hostsfile=<path>
- Read DHCP host information from the specified file. If a directory is given, then read all the files contained in that directory. The file contains information about one host per line. The format of a line is the same as text to the right of '=' in --dhcp-host. The advantage of storing DHCP host information in this file is that it can be changed without re-starting dnsmasq: the file will be re-read when dnsmasq receives SIGHUP.
- --dhcp-optsfile=<path>
- Read DHCP option information from the specified file. If a directory 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 --dhcp-boot flag as DHCP options, using the options names bootfile-name, server-ip-address and tftp-server. This allows these to be included in a dhcp-optsfile.
- -Z, --read-ethers
- Read /etc/ethers for information about hosts for the DHCP server. The format of /etc/ethers is a hardware address, followed by either a hostname or dotted-quad IP address. When read by dnsmasq these lines have exactly the same effect as --dhcp-host options containing the same information. /etc/ethers is re-read when dnsmasq receives SIGHUP. IPv6 addresses are NOT read from /etc/ethers.
- -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. (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 specified in
RFC2132 and subsequent RFCs. The set of option-names known by dnsmasq can
be discovered by running "dnsmasq --help dhcp". For example, to
set the default route 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 special address 0.0.0.0 (or [::]
for DHCPv6) 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 and a text string.
If the optional tags are given then this option is only sent when all the
tags are matched.
- --dhcp-option-force=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]]
- This works in exactly the same way as --dhcp-option except that the option will always be sent, even if the client does not ask for it in the parameter request list. This is sometimes needed, for example when sending options to PXELinux.
- --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 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.
- -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 to different classes of hosts. For
example dhcp-vendorclass=set:printers,Hewlett-Packard JetDirect
will allow options to be set only for HP printers like so:
--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.
- -j, --dhcp-userclass=set:<tag>,<user-class>
- 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 different classes 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".
- -4, --dhcp-mac=set:<tag>,<MAC address>
- (IPv4 only) Map from a MAC address to a tag. The MAC address may include wildcards. For example --dhcp-mac=set:3com,01:34:23:*:*:* will set the tag "3com" for any host whose MAC address matches the pattern.
- --dhcp-circuitid=set:<tag>,<circuit-id>, --dhcp-remoteid=set:<tag>,<remote-id>
- 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.
- --dhcp-subscrid=set:<tag>,<subscriber-id>
- (IPv4 and IPv6) Map from RFC3993 subscriber-id relay agent options to tags.
- --dhcp-proxy[=<ip addr>]......
- (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 that used by dhcp-circuitid and dhcp-remoteid. A full relay implementation can use the RFC 5107 serverid-override option to force the DHCP server to use the relay as a full proxy, with all packets passing through it. This flag provides an alternative method of doing the same thing, for relays which don't support RFC 5107. Given alone, it manipulates the server-id for all interactions via relays. If a list of IP addresses is given, only interactions via relays at those addresses are affected.
- --dhcp-match=set:<tag>,<option number>|option:<option name>|vi-encap:<enterprise>[,<value>]
- 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) 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 dhcp-option in
which case the option sent is treated as an array, and one element must
match, so
- --tag-if=set:<tag>[,set:<tag>[,tag:<tag>[,tag:<tag>]]]
- 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: and tag: forms may appear, in any order. Tag-if lines ares executed in order, so if the tag in tag:<tag> is a tag set by another tag-if, the line which sets the tag must precede the one which tests it.
- -J, --dhcp-ignore=tag:<tag>[,tag:<tag>]
- When all the given tags appear in the tag set ignore the host and do not allocate it a DHCP lease.
- --dhcp-ignore-names[=tag:<tag>[,tag:<tag>]]
- When all the given tags appear in the tag set, ignore any hostname provided by the host. Note that, unlike dhcp-ignore, it is permissible to supply no tags, in which case DHCP-client supplied hostnames are always ignored, and DHCP hosts are added to the DNS using only dhcp-host configuration in dnsmasq and the contents of /etc/hosts and /etc/ethers.
- --dhcp-generate-names=tag:<tag>[,tag:<tag>]
- (IPv4 only) Generate a name for DHCP clients which do not otherwise have one, using the MAC address expressed in hex, seperated by dashes. Note that if a host provides a name, it will be used by preference to this, unless --dhcp-ignore-names is set.
- --dhcp-broadcast[=tag:<tag>[,tag:<tag>]]
- (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.
- -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 --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 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.
- --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.
- --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
dhcp-boot and execute it. However the PXE system is capable of more
complex functions when supported by a suitable DHCP server.
- --pxe-prompt=[tag:<tag>,]<prompt>[,<timeout>]
- Setting this provides a prompt to be displayed after PXE
boot. If the timeout is given then after the 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 pxe-prompt is ommitted the system will
wait for user input if there are multiple items in the menu, but boot
immediately if there is only one. See pxe-service for details of
menu items.
- -X, --dhcp-lease-max=<number>
- Limits dnsmasq to the specified maximum number of DHCP leases. The default is 1000. This limit is to prevent DoS attacks from hosts which create thousands of leases and use lots of memory in the dnsmasq process.
- -K, --dhcp-authoritative
- (IPv4 only) 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 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.
- --dhcp-alternate-port[=<server port>[,<client port>]]
- (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 for the client. Finally, two port numbers allows arbitrary specification of both server and client ports for DHCP.
- -3, --bootp-dynamic[=<network-id>[,<network-id>]]
- (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 enables dynamic allocation. With tags, only when the tags are all set. It may be repeated with different tag sets.
- -5, --no-ping
- (IPv4 only) By default, the DHCP server will attempt to ensure that an address in 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 tried. This flag disables this check. Use with caution.
- --log-dhcp
- Extra logging for DHCP: log all the options sent to DHCP clients and the tags used to determine them.
- -l, --dhcp-leasefile=<path>
- Use the specified file to store DHCP lease information.
- --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.
- -6 --dhcp-script=<path>
- 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 (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 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 if dnsmasq is configured to change UID to an unprivileged
user.
- --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 lease function, and may provide
init and shutdown functions, which are called, without
arguments when dnsmasq starts up and terminates. It may also provide a
tftp function.
- --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 another user using this flag.
- -9, --leasefile-ro
- 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 the single argument "init". When called like this the script should write the saved state of the lease database, in dnsmasq leasefile format, to stdout and exit with zero exit code. Setting this option also forces the leasechange script to be called on changes to the client-id and lease length and expiry time.
- --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.
- -s, --domain=<domain>[,<address range>[,local]]
- Specifies DNS domains for the DHCP server. Domains may be
be given unconditionally (without the IP range) or for limited IP ranges.
This has two effects; firstly it causes the DHCP server to return the
domain to any hosts which request it, and secondly it sets the domain
which it is legal for DHCP-configured hosts to claim. The intention is to
constrain hostnames so that an 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 addition, when a suffix is
set then hostnames without a domain part have the suffix added as an
optional domain part. Eg on my network I can set
--domain=thekelleys.org.uk and have a machine whose DHCP hostname
is "laptop". The IP address for that machine is available from
dnsmasq both as "laptop" and
"laptop.thekelleys.org.uk". If the domain is given as
"#" then the domain is read from the first "search"
directive in /etc/resolv.conf (or equivalent).
- --dhcp-fqdn
- 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 --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 same name may both keep the name, provided that the domain part is different (ie the fully qualified names differ.) To ensure that all names have a domain part, there must be at least --domain without an address specified when --dhcp-fqdn is set.
- --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.
- --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 --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.
- --enable-tftp[=<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.
- --tftp-root=<directory>[,<interface>]
- Look for files to transfer using TFTP relative to the given directory. When this is set, TFTP paths which include ".." are rejected, to stop clients getting outside the specified root. 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.
- --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 tftp-root is set and the directory exists. For instance, if tftp-root is "/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.4 exists or /tftp/myfile otherwise.
- --tftp-secure
- Enable TFTP secure mode: without this, any file which is readable by the dnsmasq process under normal unix access-control rules is available via TFTP. When the --tftp-secure flag is given, only files owned by the user running the dnsmasq process are accessible. If dnsmasq is being run as root, different rules apply: --tftp-secure has no effect, but only files which have the world-readable bit set 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.
- --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.
- --tftp-max=<connections>
- Set the maximum number of concurrent TFTP connections allowed. This defaults to 50. When serving a large number of TFTP connections, per-process file descriptor limits may be encountered. Dnsmasq needs one file descriptor for each concurrent TFTP connection and one file descriptor per unique file (plus a few others). So serving the same file simultaneously to n clients will 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.
- --tftp-no-blocksize
- Stop the TFTP server from negotiating the "blocksize" option with a client. Some buggy clients request this option but then behave badly when it is granted.
- --tftp-port-range=<start>,<end>
- A TFTP server listens on a well-known port (69) for connection initiation, but it also uses a dynamically-allocated port for each 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 is running as root. The number of concurrent TFTP connections is limited by the size of the port range.
- -C, --conf-file=<file>
- 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.
- -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.
CONFIG FILE¶
At startup, dnsmasq reads /etc/dnsmasq.conf, if it exists. (On FreeBSD, the file is /usr/local/etc/dnsmasq.conf ) (but see the -C and -7 options.) The format of this file consists of one option per line, exactly as the long options detailed in the OPTIONS section but without the leading "--". Lines starting with # are comments and ignored. For options which may only be specified once, the configuration file overrides the command line. Quoting is allowed in a config file: between " quotes the special meanings of ,:. and # are removed and the following escapes are allowed: \\ \" \t \e \b \r and \n. The later corresponding to tab, escape, backspace, return and newline.NOTES¶
When it receives a SIGHUP, dnsmasq clears its cache and then re-loads /etc/hosts and /etc/ethers and any file given by --dhcp-hostsfile, --dhcp-optsfile or --addn-hosts. The dhcp lease change script is called for all existing DHCP leases. If --no-poll is set SIGHUP also re-reads /etc/resolv.conf. SIGHUP does NOT re-read the configuration file. When it receives a SIGUSR1, dnsmasq 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 server it gives the number of queries sent, and the number which resulted in an error. In --no-daemon mode or when full logging is enabled (-q), a complete dump of the contents of the cache is made. When it receives SIGUSR2 and it is logging direct to a file (see --log-facility ) dnsmasq will close and reopen the log file. Note that during this operation, dnsmasq will not be running as root. When it first creates the logfile dnsmasq changes the ownership of the file to the non-root user it will run as. Logrotate should be configured to create a new log file with the ownership which matches the existing one before sending SIGUSR2. If TCP DNS queries are in progress, the old logfile will remain open in child processes which are handling TCP queries and may continue to be written. There is a limit of 150 seconds, after which all existing TCP processes will have expired: for this reason, it is not wise to configure logfile compression for logfiles which have just been rotated. Using logrotate, the required options are create and delaycompress.The idea is that such a line can be added automatically by libvirt or equivalent systems, without disturbing any manual configuration.