MAN page from Scientific Linux 6 dnsmasq-2.48-18.el6_9.i686.rpm
Section: Maintenance Commands (8)Index
dnsmasq - A lightweight DHCP and caching DNS server.
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 thecontents of /etc/hosts so that local hostnameswhich do not appear in the global DNS can be resolved and also answersDNS queries for DHCP configured hosts.
The dnsmasq DHCP server supports static address assignments and multiplenetworks. It automaticallysends a sensible default set of DHCP options, and can be configured tosend any desired set of DHCP options, including vendor-encapsulatedoptions. It includes a secure, read-only,TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP.
Dnsmasq supports IPv6 for DNS, but not DHCP.
Note that in general missing parameters are allowed and switch offfunctions, for instance "--pid-file" disables writing a PID file. OnBSD, unless the GNU getopt library is linked, the long form of theoptions does not work on the command line; it is still recognised inthe configuration file.
- Read and syntax check configuration file(s). Exit with code 0 if allis 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, readonly the specified file. This option may be repeated for more than oneadditional 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/hostsin the same way as for DHCP-derived names.
- -T, --local-ttl=<time>
- When replying with information from /etc/hosts or the DHCP leasesfile dnsmasq by default sets the time-to-live field to zero, meaningthat the requestor should not itself cache the information. This isthe correct thing to do in almost all situations. This option allows atime-to-live (in seconds) to be given for these replies. This willreduce the load on the server at the expense of clients using staledata under some circumstances.
- Negative replies from upstream servers normally contain time-to-liveinformation in SOA records which dnsmasq uses for caching. If thereplies from upstream servers omit this information, dnsmasq does notcache 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.
- -k, --keep-in-foreground
- Do not go into the background at startup but otherwise run asnormal. This is intended for use when dnsmasq is run under daemontoolsor 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 onSIGUSR1, log to stderr as well as syslog, don't fork new processesto 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, thisdefaults to DAEMON, and to LOCAL0 when debug mode is in operation. Ifthe facility given contains at least one '/' character, it is taken tobe a filename, and dnsmasq logs to the given file, instead ofsyslog. (Errors whilst reading configuration will still go to syslog,but all output from a successful startup, and all output whilstrunning, 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.
- Enable asynchronous logging and optionally set the limit on thenumber of lineswhich will be queued by dnsmasq when writing to the syslog is slow. Dnsmasq can log asynchronously: thisallows it to continue functioning without being blocked by syslog, andallows syslog to use dnsmasq for DNS queries without risking deadlock.If the queue of log-lines becomes full, dnsmasq will log theoverflow, and the number of messages lost. The default queue length is5, 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 runas. 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 thisto 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 DNSforwarder. Defaults to 1280, which is the RFC2671-recommended maximumfor ethernet.
- -Q, --query-port=<query_port>
- Send outbound DNS queries from, and listen for their replies on, thespecific UDP port <query_port> instead of using random ports. NOTEthat using this option will make dnsmasq less secure against DNSspoofing attacks but it may be faster and use less resources. Setting this optionto zero makes dnsmasq use a single port allocated to it by theOS: this was the default behaviour in versions prior to 2.43.
- Do not use ports less than that given as source for outbound DNSqueries. Dnsmasq picks random ports as source for outbound queries:when this option is given, the ports used will always to largerthan that specified. Useful for systems behind firewalls.
- -i, --interface=<interface name>
- Listen only on the specified interface(s). Dnsmasq automatically addsthe loopback (local) interface to the list of interfaces to use whenthe--interfaceoption is used. If no--interfaceor--listen-addressoptions are given dnsmasq listens on all available interfaces except anygiven in--except-interfaceoptions. IP alias interfaces (eg "eth1:0") cannot be used with--interfaceor--except-interfaceoptions, use --listen-address instead.
- -I, --except-interface=<interface name>
- Do not listen on the specified interface. Note that the order of--listen-address--interfaceand--except-interfaceoptions does not matter and that --except-interfaceoptions 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 --interfaceand--listen-addressoptions may be given, in which case the set of both interfaces andaddresses is used. Note that if no--interfaceoption is given, but --listen-addressis, dnsmasq will not automatically listen on the loopbackinterface. To achieve this, its IP address, 127.0.0.1, must beexplicitly given as a --listen-addressoption.
- -z, --bind-interfaces
- On systems which support it, dnsmasq binds the wildcard address,even when it is listening on only some interfaces. It then discardsrequests that it shouldn't reply to. This has the advantage of working even when interfaces come and go and change address. Thisoption forces dnsmasq to really bind only the interfaces it islistening on. About the only time when this is useful is when running another nameserver (or another instance of dnsmasq) on thesame machine. Setting this option also enables multiple instances ofdnsmasq which provide DHCP service to run in the same machine.
This option has been patched to always use SO_BINDTODEVICE socket optionwhen binding to interfaces. As consequence, dnsmasqWILL NOT ANSWERto any DNS Queries that come to the socket with the correct destination IPaddress, but originally on different interface. This behavior differs fromthe original dnsmasq upstream version and is used for security reasons.
- -y, --localise-queries
- Return answers to DNS queries from /etc/hosts which depend on the interface over which the query wasreceived. If a name in /etc/hosts has more than one address associated withit, and at least one of those addresses is on the same subnet as theinterface to which the query was sent, then return only theaddress(es) on that subnet. This allows for a server to have multipleaddresses in /etc/hosts corresponding to each of its interfaces, andhosts will get the correct address based on which network they areattached 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 answeredwith "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 isreplaced by new-ip. If the optional mask is given then any addresswhich matches the masked old-ip will be re-written. So, for instance--alias=184.108.40.206,220.127.116.11,255.255.255.0 will map 18.104.22.168 to 22.214.171.124 and 126.96.36.199 to 188.8.131.52. This is whatCisco 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 --alias=192.168.0.10-192.168.0.40,10.0.0.0,255.255.255.0maps 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 suchdomain" replies. This is intended to counteract a devious move made byVerisign in September 2003 when they started returning the address ofan advertising web page in response to queries for unregistered names,instead of the correct NXDOMAIN response. This option tells dnsmasq tofake the correct response when it sees this behaviour. As at Sept 2003the IP address being returned by Verisign is 184.108.40.206
- -f, --filterwin2k
- Later versions of windows make periodic DNS requests which don't get sensible answers fromthe public DNS and can cause problems by triggering dial-on-demand links. This flag turns on an optionto 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 seeresolv.conf(5)the only lines relevant to dnsmasq are nameserver ones. Dnsmasq canbe told to poll more than one resolv.conf file, the first file name specifiedoverrides the default, subsequent ones add to the list. This is onlyallowed when polling; the file with the currently latest modificationtime is the one used.
- -R, --no-resolv
- Don't read /etc/resolv.conf. Get upstream servers only from the commandline or the dnsmasq configuration file.
- -1, --enable-dbus
- Allow dnsmasq configuration to be updated via DBus method calls. Theconfiguration which can be changed is upstream DNS servers (andcorresponding domains) and cache clear. Requires that dnsmasq hasbeen built with DBus support.
- -o, --strict-order
- By default, dnsmasq will send queries to any of the upstream serversit knows about and tries to favour servers that are known tobe up. Setting this flag forces dnsmasq to try each query with eachserver strictly in the order they appear in /etc/resolv.conf
- By default, when dnsmasq has more than one upstream server available,it will send queries to just one server. Setting this flag forcesdnsmasq to send all queries to all available servers. The reply fromthe server which answers first will be returned to the original requestor.
- Reject (and log) addresses from upstream nameservers which are in theprivate IP ranges. This blocks an attack where a browser behind afirewall is used to probe machines on the local network.
- -n, --no-poll
- Don't poll /etc/resolv.conf for changes.
- Whenever /etc/resolv.conf is re-read, clear the DNS cache.This is useful when new nameservers may have differentdata than that held in cache.
- -D, --domain-needed
- Tells dnsmasq to never forward queries for plain names, without dotsor domain parts, to upstream nameservers. If the name is not knownfrom /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 doesnot suppress reading of /etc/resolv.conf, use -R to do that. If one ormore optional domains are given, that server is used only for those domainsand they are queried only using the specified server. This isintended for private nameservers: if you have a nameserver on yournetwork which deals with names of the formxxx.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 forinternal machines to that nameserver, everything else will go to theservers in /etc/resolv.conf. An empty domain specification,// has the special meaning of "unqualified names only" ie names without anydots in them. A non-standard port may be specified as part of the IPaddress using a # character.More than one -S flag is allowed, withrepeated domain or ipaddr parts as required.
Also permitted is a -Sflag which gives a domain but no IP address; this tells dnsmasq thata domain is local and it may answer queries from /etc/hosts or DHCPbut should never forward queries on that domain to any upstreamservers.localis a synonym forserverto make configuration files clearer in this case.
The optional string after the @ character tellsdnsmasq how to set the source of the queries to thisnameserver. It should be an ip-address, which should belong to the machine on whichdnsmasq is running otherwise this server line will be logged and thenignored, or an interface name. If an interface name is given, thenqueries to the server will be forced via that interface; if anip-address is given then the source address of the queries will be setto that address.The query-port flag is ignored for any servers which have asource address specified but the port may be specified directly aspart of the source address. Forcing queries to an interface is notimplemented on all platforms supported by dnsmasq.
- -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 towith the specified IP address which may be IPv4 or IPv6. To giveboth IPv4 and IPv6 addresses for a domain, use repeated -A flags.Note that /etc/hosts and DHCP leases override this for individualnames. A common use of this is to redirect the entire doubleclick.netdomain to some friendly local web server to avoid banner ads. Thedomain specification works in the same was as for --server, with theadditional facility that /#/ matches any domain. Thus--address=/#/220.127.116.11 will always return 18.104.22.168 for any query notanswered from /etc/hosts or DHCP and not sent to an upstreamnameserver 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 (ifgiven), orthe 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 systems on a LANto a central server. The preference value is optional, and defaults to1 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 dnsmasqreturns 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 localmachine. 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 themachine on which dnsmasq is running) for eachlocal machine. Local machines are those in /etc/hosts or with DHCPleases.
- -W, --srv-host=<_service>.<_prot>.[<domain>],[<target>[,<port>[,<priority>[,<weight>]]]]
- Return a SRV DNS record. See RFC2782 for details. If not supplied, thedomain defaults to that given by--domain.The default for the target domain is empty, and the default for portis one and the defaults for weight and priority are zero. Be careful if transposing data from BINDzone files: the port, weight and priority numbers are in a differentorder. More than one SRV record for a given service/domain is allowed,all that match are returned.
- -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, split by commas.
- Return a PTR DNS record.
- Return an NAPTR DNS record, as specified in RFC3403.
- Return a CNAME record which indicates that <cname> is really<target>. There are significant limitations on the target; it must be aDNS name which is known to dnsmasq from /etc/hosts (or additionalhosts files) or from DHCP. If the target does not satisfy thiscriteria, the whole cname is ignored. The cname must be unique, but itis permissable to have more than one cname pointing to the same target.
- Return a DNS record associating the name with the primary address onthe given interface. This flag specifies an A record for the givenname in the same way as an /etc/hosts line, except that the address isnot constant, but taken from the given interface. If the interface isdown, not configured or non-existent, an empty record is returned. Thematching PTR record is also created, mapping the interface address tothe name. More than one name may be associated with an interfaceaddress by repeating the flag; in that case the first instance is usedfor the reverse address-to-name mapping.
- -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 answeridentical queries without forwarding them again.
- -0, --dns-forward-max=<queries>
- Set the maximum number of concurrent DNS queries. The default value is150, which should be fine for most setups. The only known situationwhere this needs to be increased is when using web-server log fileresolvers, which can generate large numbers of concurrent queries.
- -F, --dhcp-range=[[net:]network-id,]<start-addr>,<end-addr>[[,<netmask>],<broadcast>][,<lease time>]
- Enable the DHCP server. Addresses will be given out from the range<start-addr> to <end-addr> and from statically defined addresses givenin dhcp-hostoptions. If the lease time is given, then leaseswill be given for that length of time. The lease time is in seconds,or minutes (eg 45m) or hours (eg 1h) or "infinite". If not given,the default lease time is one hour. Theminimum lease time is two minutes. Thisoption may be repeated, with different addresses, to enable DHCPservice to more than one network. For directly connected networks (ie,networks on which the machine running dnsmasq has an interface) thenetmask is optional. It is, however, required for networks whichreceive DHCP service via a relay agent. The broadcast address isalways optional. It is alwaysallowed to have more than one dhcp-range in a single subnet. The optionalnetwork-id is a alphanumeric label which marks this network so thatdhcp options may be specified on a per-network basis. When it is prefixed with 'net:' then its meaning changes from settinga tag to matching it. Only one tag may be set, but more than one tag may be matched.The end address may be replaced by the keyword staticwhich tells dnsmasq to enable DHCP for the network specified, but notto dynamically allocate IP addresses: only hosts which have staticaddresses given via dhcp-hostor from /etc/ethers will be served. The end address may be replaced bythe keywordproxyin which case dnsmasq will provide proxy-DHCP on the specifiedsubnet. (See pxe-promptand pxe-servicefor details.)
- -G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,net:<netid>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
- Specify per host parameters for the DHCP server. This allows a machinewith a particular hardware address to be always allocated the samehostname, IP address and lease time. A hostname specified like thisoverrides any supplied by the DHCP client on the machine. It is alsoallowable to ommit the hardware address and include the hostname, inwhich case the IP address and lease times will apply to any machineclaiming that name. For example --dhcp-host=00:20:e0:3b:13:af,wap,infinite tells dnsmasq to givethe machine with hardware address 00:20:e0:3b:13:af the name wap, andan infinite DHCP lease. --dhcp-host=lap,192.168.0.199 tellsdnsmasq to always allocate the machine lap the IP address192.168.0.199. Addresses allocated like this are not constrained to bein the range given by the --dhcp-range option, but they must be on thenetwork being served by the DHCP server. It is allowed to use client identifiers rather thanhardware addresses to identify hosts by prefixing with 'id:'. Thus: --dhcp-host=id:01:02:03:04,..... refers to the host with client identifier 01:02:03:04. It is alsoallowed to specify the client ID as text, like this:--dhcp-host=id:clientidastext,.....
The special option id:* means "ignore any client-id and use MAC addresses only." This is useful when a client presents a client-id sometimes but not others.
If a name appears in /etc/hosts, the associated address can beallocated to a DHCP lease, but only if a --dhcp-hostoption specifying the name also exists. The special keyword "ignore"tells dnsmasq to never offer a DHCP lease to a machine. The machinecan be specified by hardware address, client ID or hostname, forinstance--dhcp-host=00:20:e0:3b:13:af,ignoreThis isuseful when there is another DHCP server on the network which shouldbe used by some machines.
The net:<network-id> sets the network-id tagwhenever this dhcp-host directive is in use. This can be used to selectively send DHCP options just for this host. When a host matches anydhcp-host directive (or one implied by /etc/ethers) then the specialnetwork-id tag "known" is set. This allows dnsmasq to be configured toignore requests from unknown machines using--dhcp-ignore=#knownEthernet addresses (but not client-ids) may havewildcard bytes, so for example --dhcp-host=00:20:e0:3b:13:*,ignore will cause dnsmasq to ignore a range of hardware addresses. Note thatthe "*" will need to be escaped or quoted on a command line, but notin the configuration file.
Hardware addresses normally match anynetwork (ARP) type, but it is possible to restrict them to a singleARP type by preceding them with the ARP-type (in HEX) and "-". so --dhcp-host=06-00:20:e0:3b:13:af,22.214.171.124 will only match aToken-Ring hardware address, since the ARP-address type for token ringis 6.
As a special case, it is possible to include more than onehardware address. eg:--dhcp-host=11:22:33:44:55:66,12:34:56:78:90:12,192.168.0.2This allows an IP address to be associated withmultiple hardware addresses, and gives dnsmasq permission to abandon aDHCP lease to one of the hardware addresses when another one asks fora lease. Beware that this is a dangerous thing to do, it will onlywork reliably if only one of the hardware addresses is active at anytime and there is no way for dnsmasq to enforce this. It is, for instance,useful to allocate a stable IP address to a laptop whichhas both wired and wireless interfaces.
- Read DHCP host information from the specified file. The file contains information about one host per line. The format of a line is the sameas text to the right of '=' in --dhcp-host. The advantage of storing DHCP host informationin this file is that it can be changed without re-starting dnsmasq:the file will be re-read when dnsmasq receives SIGHUP.
- Read DHCP option information from the specified file. The advantage of using this option is the same as for --dhcp-hostsfile: thedhcp-optsfile will be re-read when dnsmasq receives SIGHUP.
- -Z, --read-ethers
- Read /etc/ethers for information about hosts for the DHCP server. Theformat of /etc/ethers is a hardware address, followed by either ahostname or dotted-quad IP address. When read by dnsmasq these lineshave exactly the same effect as--dhcp-hostoptions containing the same information. /etc/ethers is re-read when dnsmasq receives SIGHUP.
- -O, --dhcp-option=[<network-id>,[<network-id>,]][encap:<opt>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]]
- Specify different or extra options to DHCP clients. By default,dnsmasq sends some standard options to DHCP clients, the netmask andbroadcast address are set to the same as the host running dnsmasq, andthe DNS server and default route are set to the address of the machinerunning dnsmasq. 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 adecimal number or as "option:<option-name>" The option numbers arespecified in RFC2132 and subsequent RFCs. The set of option-namesknown 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.4and 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.4The special address 0.0.0.0 is taken to mean "the address of themachine running dnsmasq". Data types allowed are comma separateddotted-quad IP addresses, a decimal number, colon-separated hex digitsand a text string. If the optional network-ids are given thenthis option is only sent when all the network-ids are matched.
Special processing is done on a text argument for option 119, toconform with RFC 3397. Text or dotted-quad IP addresses as argumentsto option 120 are handled as per RFC 3361. Dotted-quad IP addresses which are followed by a slash and then a netmask size are encoded asdescribed in RFC 3442.
Be careful: no checking is done that the correct type of data for theoption number is sent, it is quite possible topersuade dnsmasq to generate illegal DHCP packets with injudicious useof this flag. When the value is a decimal number, dnsmasq must determine how large the data item is. It does this by examining the option number and/or thevalue, but can be overridden by appending a single letter flag as follows:b = one byte, s = two bytes, i = four bytes. This is mainly useful with encapsulated vendor class options (see below) where dnsmasq cannotdetermine data size from the option number. Option data whichconsists solely of periods and digits will be interpreted by dnsmasqas an IP address, and inserted into an option as such. To force aliteral string, use quotes. For instance when using option 66 to senda literal IP address as TFTP server name, it is necessary to do--dhcp-option=66,126.96.36.199
Encapsulated Vendor-class options may also be specified using--dhcp-option: for instance --dhcp-option=vendor:PXEClient,1,0.0.0.0 sends the encapsulated vendorclass-specific option "mftp-address=0.0.0.0" to any client whosevendor-class matches "PXEClient". The vendor-class matching issubstring based (see --dhcp-vendorclass for details). If avendor-class option (number 60) is sent by dnsmasq, then that is used for selecting encapsulated options in preference to any sent by theclient. It ispossible to omit the vendorclass completely;--dhcp-option=vendor:,1,0.0.0.0in which case the encapsulated option is always sent.
Options may be encapsulated within other options: for instance--dhcp-option=encap:175, 190, iscsi-client0will send option 175, within which is the option 190. If multipleoptions are given which are encapsulated with the same option numberthen they will be correctly combined into one encapsulated option.encap: and vendor: are may not both be set in the same dhcp-option.
The address 0.0.0.0 is not treated specially inencapsulated options.
- This works in exactly the same way as--dhcp-optionexcept that the option will always be sent, even if the client doesnot ask for it in the parameter request list. This is sometimesneeded, for example when sending options to PXELinux.
- Disable re-use of the DHCP servername and filename fields as extraoption space. If it can, dnsmasq moves the boot server and filenameinformation (from dhcp-boot) out of their dedicated fields intoDHCP options. This make extra space available in the DHCP packet foroptions but can, rarely, confuse old or broken clients. This flagforces "simple and safe" behaviour to avoid problems in such a case.
- -U, --dhcp-vendorclass=<network-id>,<vendor-class>
- Map from a vendor-class string to a network id 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 deliveredto different classes of hosts. For example dhcp-vendorclass=printers,Hewlett-Packard JetDirectwill allow options to be set only for HP printers like so:--dhcp-option=printers,3,192.168.4.4 The vendor-class string issubstring matched against the vendor-class supplied by the client, toallow fuzzy matching.
- -j, --dhcp-userclass=<network-id>,<user-class>
- Map from a user-class string to a network id tag (with substringmatching, like vendor classes). Most DHCP clients provide a "user class" which is configurable. This optionmaps user classes to tags, so that DHCP options may be selectively deliveredto different classes of hosts. It is possible, for instance to usethis to set a different printer server for hosts in the class"accounts" than for hosts in the class "engineering".
- -4, --dhcp-mac=<network-id>,<MAC address>
- Map from a MAC address to a network-id tag. The MAC address may includewildcards. For example--dhcp-mac=3com,01:34:23:*:*:*will set the tag "3com" for any host whose MAC address matches the pattern.
- --dhcp-circuitid=<network-id>,<circuit-id>, --dhcp-remoteid=<network-id>,<remote-id>
- Map from RFC3046 relay agent options to network-id tags. This data maybe provided by DHCP relay agents. The circuit-id or remote-id isnormally given as colon-separated hex, but is also allowed to be asimple string. If an exact match is achieved between the circuit oragent ID and one provided by a relay agent, the network-id tag is set.
- Map from RFC3993 subscriber-id relay agent options to network-id tags.
- --dhcp-match=<network-id>,<option number>|option:<option name>[,<value>]
- Without a value, set the network-id tag if the client sends a DHCPoption of the given number or name. When a value is given, set the tag only ifthe 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 thevalue. The value may also be of the same form as in dhcp-optionin which case the option sent is treated as an array, and one elementmust match, so
will set the tag "efi-ia32" if the the number 6 appears in the list ofarchitectures sent by the client in option 93. (See RFC 4578 fordetails.) If the value is a string, substring matching is used.
- -J, --dhcp-ignore=<network-id>[,<network-id>]
- When all the given network-ids match the set of network-ids derivedfrom the net, host, vendor and user classes, ignore the host and donot allocate it a DHCP lease.
- When all the given network-ids match the set of network-ids derivedfrom the net, host, vendor and user classes, ignore any hostnameprovided by the host. Note that, unlike dhcp-ignore, it is permissibleto supply no netid tags, in which case DHCP-client supplied hostnamesare always ignored, and DHCP hosts are added to the DNS using onlydhcp-host configuration in dnsmasq and the contents of /etc/hosts and/etc/ethers.
- When all the given network-ids match the set of network-ids derivedfrom the net, host, vendor and user classes, always use broadcast tocommunicate with the host when it is unconfigured. Most DHCP clients whichneed broadcast replies set a flag in their requests so that thishappens automatically, some old BOOTP clients do not.
- -M, --dhcp-boot=[net:<network-id>,]<filename>,[<servername>[,<server address>]]
- Set BOOTP options to be returned by the DHCP server. Server name andaddress are optional: if not provided, the name is left empty, and theaddress set to the address of the machine running dnsmasq. If dnsmasqis providing a TFTP service (see --enable-tftp) then only the filename is required here to enable network booting.If the optional network-id(s) are given,they must match for this configuration to be sent. Note thatnetwork-ids are prefixed by "net:" to distinguish them.
- --pxe-service=[net:<network-id>,]<CSA>,<menu text>,<basename>|<bootservicetype>[,<server address>]
- Most uses of PXE boot-ROMS simply allow the PXEsystem to obtain an IP address and then download the file specified bydhcp-bootand execute it. However the PXE system is capable of more complexfunctions when supported by a suitable DHCP server.
This specifies a boot option which may appear in a PXE boot menu. <CSA> isclient system type, only services of the correct type will appear in amenu. The known types are x86PC, PC98, IA64_EFI, Alpha, Arc_x86,Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI and X86-64_EFI; aninteger may be used for other types. Theparameter after the menu text may be a file name, in which case dnsmasq acts as aboot server and directs the PXE client to download the file by TFTP,either from itself (enable-tftp must be set for this to work) or another TFTP server if the final IPaddress is given.Note that the "layer"suffix (normally ".0") is supplied by PXE, and should not be added tothe basename. If an integer boot service type, rather than a basenameis given, then the PXE client will search for asuitable boot service for that type on the network. This search may be doneby multicast or broadcast, or direct to a server if its IP address is provided. A boot servicetype of 0 is special, and will abort the net boot procedure andcontinue booting from local media.
- Setting this provides a prompt to be displayed after PXE boot. If thetimeout is given then after thetimeout has elapsed with no keyboard input, the first available menuoption will be automatically executed. If the timeout is zero then the first available menuitem will be executed immediately. If pxe-promptis ommitted the system will wait for user input if there are multipleitems in the menu, but boot immediately ifthere is only one. Seepxe-service for details of menu items.
Dnsmasq supports PXE "proxy-DHCP", in this case another DHCP server onthe network is responsible for allocating IP addresses, and dnsmasqsimply provides the information given in pxe-promptandpxe-serviceto allow netbooting. This mode is enabled using theproxykeyword indhcp-range.
- -X, --dhcp-lease-max=<number>
- Limits dnsmasq to the specified maximum number of DHCP leases. Thedefault is 150. This limit is to prevent DoS attacks from hosts whichcreate thousands of leases and use lots of memory in the dnsmasqprocess.
- -K, --dhcp-authoritative
- Should be set when dnsmasq is definitely the only DHCP server on a network.It changes the behaviour from strict RFC compliance so that DHCP requests onunknown leases from unknown hosts are not ignored. This allows new hoststo 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>]]
- Change the ports used for DHCP from the default. If this option isgiven alone, without arguments, it changes the ports used for DHCPfrom 67 and 68 to 1067 and 1068. If a single argument is given, thatport number is used for the server and the port number plus one usedfor the client. Finally, two port numbers allows arbitraryspecification of both server and client ports for DHCP.
- -3, --bootp-dynamic[=<network-id>[,<network-id>]]
- Enable dynamic allocation of IP addresses to BOOTP clients. Use thiswith care, since each address allocated to a BOOTP client is leasedforever, and therefore becomes permanently unavailable for re-use byother hosts. if this is given without tags, then it unconditionallyenables dynamic allocation. With tags, only when the tags are allset. It may be repeated with different tag sets.
- -5, --no-ping
- By default, the DHCP server will attempt to ensure that an address innot in use before allocating it to a host. It does this by sending anICMP echo request (aka "ping") to the address in question. If it getsa reply, then the address must already be in use, and another istried. This flag disables this check. Use with caution.
- Extra logging for DHCP: log all the options sent to DHCP clients andthe netid tags used to determine them.
- -l, --dhcp-leasefile=<path>
- Use the specified file to store DHCP lease information.
- -6 --dhcp-script=<path>
- Whenever a new DHCP lease is created, or an old one destroyed, theexecutable specified by this option is run. The arguments to the processare "add", "old" or "del", the MACaddress of the host, the IP address, and the hostname,if known. "add" means a lease has been created, "del" means it hasbeen destroyed, "old" is a notification of an existing lease whendnsmasq starts or a change to MAC address or hostname of an existinglease (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" fortoken ring. The process is run as root (assuming that dnsmasq was originally run asroot) even if dnsmasq is configured to change UID to an unprivileged user.The environment is inherited from the invoker of dnsmasq, and if thehost provided a client-id, this is stored in the environment variableDNSMASQ_CLIENT_ID. If the fully-qualified domain name of the host isknown, the domain part is stored in DNSMASQ_DOMAIN. If the client provides vendor-class or user-class information, these are provided in DNSMASQ_VENDOR_CLASS and DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn variables, but only for"add" actions or "old" actions when a host resumes an existing lease,since these data are not held in dnsmasq's leasedatabase. If dnsmasq was compiled with HAVE_BROKEN_RTC, thenthe length of the lease (in seconds) is stored inDNSMASQ_LEASE_LENGTH, otherwise the time of lease expiry is stored inDNSMASQ_LEASE_EXPIRES. The number of seconds until lease expiry isalways stored in DNSMASQ_TIME_REMAINING. If a lease used to have a hostname, which isremoved, 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 ofthe interface on which the request arrived; this is not set for "old"actions when dnsmasq restarts.All file descriptors areclosed except stdin, stdout and stderr which are open to /dev/null(except in debug mode).The script is not invoked concurrently: if subsequent lease changes occur, the script is not invoked again until any existing invocation exits. At dnsmasq startup, the script will be invoked forall existing leases as they are read from the lease file. Expiredleases will be called with "del" and others with "old". <path>must be an absolute pathname, no PATH search occurs. When dnsmasqreceives a HUP signal, the script will be invoked for existing leaseswith an "old " event.
- Specify the user as which to run the lease-change script. This defaults to root, but can be changed to another user using this flag.
- -9, --leasefile-ro
- Completely suppress use of the lease database file. The file will notbe created, read, or written. Change the way the lease-changescript (if one is provided) is called, so that the lease database maybe maintained in external storage by the script. In addition to theinvocations given in --dhcp-scriptthe lease-change script is called once, at dnsmasq startup, with thesingle argument "init". When called like this the script should writethe saved state of the lease database, in dnsmasq leasefile format, tostdout and exit with zero exit code. Setting thisoption also forces the leasechange script to be called on changesto the client-id and lease length and expiry time.
- Treat DHCP request packets arriving at any of the <alias> interfacesas if they had arrived at <interface>. This option is necessary whenusing "old style" bridging on BSD platforms, sincepackets arrive at tap interfaces which don't have an IP address.
- -s, --domain=<domain>[,<address range>]
- 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 hostswhich request it, and secondly it sets the domain which it is legalfor DHCP-configured hosts to claim. The intention is to constrainhostnames 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 DHCPhostname 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. Inaddition, when a suffix is set then hostnames without a domainpart have the suffix added as an optional domain part. Eg on my network I can set --domain=thekelleys.org.ukand have a machine whose DHCP hostname is "laptop". The IP address for that machine is available from dnsmasqboth as "laptop" and "laptop.thekelleys.org.uk". If the domain isgiven as "#" then the domain is read from the first "search" directivein /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 --dhcp-fqdnwhich can change the behaviour of dnsmasq with domains.
- In the default mode, dnsmasq inserts the unqualified names ofDHCP clients into the DNS. For this reason, the names must be unique,even if two clients which have the same name are in differentdomains. If a second DHCP client appears which has the same name as anexisting client, the name is transfered to the new client. If --dhcp-fqdnis set, this behaviour changes: the unqualified name is no longerput in the DNS, only the qualified name. Two DHCP clients with thesame name may both keep the name, provided that the domain part isdifferent (ie the fully qualified names differ.) To ensure that allnames have a domain part, there must be at least --domain without an address specified when --dhcp-fqdn is set.
- Enable the TFTP server function. This is deliberately limited to thatneeded to net-boot a client. Only reading is allowed; the tsize andblksize extensions are supported (tsize is only supported in octet mode).
- Look for files to transfer using TFTP relative to the givendirectory. 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 be withinthe tftp-root.
- Add the IP address of the TFTP client as a path component on the endof the TFTP-root (in standard dotted-quad format). Only valid if atftp-root is set and the directory exists. For instance, if tftp-root is "/tftp" and client 188.8.131.52 requests file "myfile" then the effective path will be"/tftp/184.108.40.206/myfile" if /tftp/220.127.116.11 exists or /tftp/myfile otherwise.
- Enable TFTP secure mode: without this, any file which is readable bythe dnsmasq process under normal unix access-control rules isavailable via TFTP. When the --tftp-secure flag is given, only filesowned by the user running the dnsmasq process are accessible. Ifdnsmasq is being run as root, different rules apply: --tftp-securehas no effect, but only files which have the world-readable bit setare accessible. It is not recommended to run dnsmasq as root with TFTPenabled, and certainly not without specifying --tftp-root. Doing socan expose any world-readable file on the server to any host on the net.
- Set the maximum number of concurrent TFTP connections allowed. Thisdefaults to 50. When serving a large number of TFTP connections,per-process file descriptor limits may be encountered. Dnsmasq needsone file descriptor for each concurrent TFTP connection and onefile descriptor per unique file (plus a few others). So serving thesame file simultaneously to n clients will use require about n + 10 filedescriptors, serving different files simultaneously to n clients willrequire about (2*n) + 10 descriptors. If --tftp-port-rangeis given, that can affect the number of concurrent connections.
- Stop the TFTP server from negotiating the "blocksize" option with aclient. Some buggy clients request this option but then behave badlywhen it is granted.
- A TFTP server listens on a well-known port (69) for connection initiation,but it also uses a dynamically-allocated port for eachconnection. Normally these are allocated by the OS, but this optionspecifies a range of ports for use by TFTP transfers. This can beuseful when TFTP has to traverse a firewall. The start of the rangecannot be lower than 1025 unless dnsmasq is running as root. The numberof 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 inconfiguration files, to include multiple configuration files.
- -7, --conf-dir=<directory>
- Read all the files in the given directory as configurationfiles. Files whose names end in ~ or start with . or start and endwith # are skipped. This flag may be given on the commandline or in a configuration file.
At startup, dnsmasq reads/etc/dnsmasq.conf,
if it exists. (OnFreeBSD, the file is /usr/local/etc/dnsmasq.conf
) (but see the -C
options.) The format of thisfile 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. Foroptions 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 thefollowing escapes are allowed: \\ \" \t \e \b \r and \n. The later corresponding to tab, escape, backspace, return and newline.
When it receives a SIGHUP, dnsmasq
clears its cache and then re-loads /etc/hosts
and any file given by --dhcp-hostsfile, --dhcp-optsfile or --addn-hosts.The dhcp lease change script is called for allexisting DHCP leases. If --no-poll
is set SIGHUP also re-reads/etc/resolv.conf.
SIGHUPdoes 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 beforethey expired in order to make room for new names and the total numberof names that have been inserted into the cache. For each upstreamserver it gives the number of queries sent, and the number whichresulted in an error. In --no-daemonmode or when full logging is enabled (-q), a complete dump of thecontents of the cache is made.
When it receives SIGUSR2 and it is logging direct to a file (see--log-facility) dnsmasqwill close and reopen the log file. Note that during this operation,dnsmasq will not be running as root. When it first creates the logfilednsmasq changes the ownership of the file to the non-root user it will runas. Logrotate should be configured to create a new log file withthe ownership which matches the existing one before sending SIGUSR2.If TCP DNS queries are in progress, the old logfile will remain open inchild processes which are handling TCP queries and may continue to bewritten. There is a limit of 150 seconds, after which all existing TCPprocesses will have expired: for this reason, it is not wise toconfigure logfile compression for logfiles which have just beenrotated. Using logrotate, the required options are create anddelaycompress.
Dnsmasq is a DNS query forwarder: it it not capable of recursivelyanswering arbitrary queries starting from the root servers butforwards such queries to a fully recursive upstream DNS server which istypically provided by an ISP. By default, dnsmasq reads/etc/resolv.confto discover the IPaddresses of the upstream nameservers it should use, since theinformation is typically stored there. Unless--no-pollis used,dnsmasqchecks the modification time of/etc/resolv.conf(or equivalent if --resolv-file is used) and re-reads it if it changes. This allows the DNS servers tobe set dynamically by PPP or DHCP since both protocols provide theinformation.Absence of/etc/resolv.confis not an errorsince it may not have been created before a PPP connection exists. Dnsmasq simply keeps checking in case/etc/resolv.conf is created at anytime. Dnsmasq can be told to parse more than one resolv.conffile. This is useful on a laptop, where both PPP and DHCP may be used:dnsmasq can be set to poll both /etc/ppp/resolv.conf and/etc/dhcpc/resolv.conf and will use the contents of whichever changedlast, giving automatic switching between DNS servers.
Upstream servers may also be specified on the command line or inthe configuration file. These server specifications optionally take adomain name which tells dnsmasq to use that server only to find namesin that particular domain.
In order to configure dnsmasq to act as cache for the host on which it is running, put "nameserver 127.0.0.1" in/etc/resolv.confto force local processes to send queries todnsmasq. Then either specify the upstream servers directly to dnsmasqusing --serveroptions or put their addresses real in another file, say/etc/resolv.dnsmasqand run dnsmasq with the -r /etc/resolv.dnsmasqoption. This second technique allows for dynamic update of the serveraddresses by PPP or DHCP.
Addresses in /etc/hosts will "shadow" different addresses for the samenames in the upstream DNS, so "mycompany.com 18.104.22.168" in /etc/hosts will ensure thatqueries for "mycompany.com" always return 22.214.171.124 even if queries inthe upstream DNS would otherwise return a different address. There isone exception to this: if the upstream DNS contains a CNAME whichpoints to a shadowed name, then looking up the CNAME through dnsmasqwill result in the unshadowed address associated with the target ofthe CNAME. To work around this, add the CNAME to /etc/hosts so thatthe CNAME is shadowed too.
The network-id system works as follows: For each DHCP request, dnsmasqcollects a set of valid network-id tags, one from the dhcp-rangeused to allocate the address, one from any matching dhcp-host(and "known" if a dhcp-host matches) the tag "bootp" for BOOTP requests, a tag whose name is the name if the interface on which the request arrived,and possibly many from matching vendor classes and userclasses sent by the DHCP client. Any dhcp-option which has network-id tags will be used in preference to an untagged dhcp-option,provided that _all_ the tags match somewhere in theset collected as described above. The prefix '#' on a tag means 'not'so --dhcp=option=#purple,3,126.96.36.199 sends the option when thenetwork-id tag purple is not in the set of valid tags.
If the network-id in adhcp-range is prefixed with 'net:' then its meaning changes from setting atag to matching it. Thus if there is more than dhcp-range on a subnet,and one is tagged with a network-id which is set (for instancefrom a vendorclass option) then hosts which set the netid tag will be allocated addresses in the tagged range.
The DHCP server in dnsmasq will function as a BOOTP server also,provided that the MAC address and IP address for clients are given,either using dhcp-host configurations or in/etc/ethers, and adhcp-range configuration option is present to activate the DHCP serveron a particular network. (Setting --bootp-dynamic removes the need forstatic address mappings.) The filenameparameter in a BOOTP request is matched against netids indhcp-option configurations, as is the tag "bootp", allowing some control over the options returned todifferent classes of hosts.
0 - Dnsmasq successfully forked into the background, or terminatednormally if backgrounding is not enabled.
1 - A problem with configuration was detected.
2 - A problem with network access occurred (address in use, attemptto use privileged ports without permission).
3 - A problem occurred with a filesystem operation (missingfile/directory, permissions).
4 - Memory allocation failure.
5 - Other miscellaneous problem.
11 or greater - a non zero return code was received from thelease-script process "init" call. The exit code from dnsmasq is thescript's exit code with 10 added.
The default values for resource limits in dnsmasq are generallyconservative, and appropriate for embedded router type devices withslow processors and limited memory. On more capable hardware, it ispossible to increase the limits, and handle many more clients. Thefollowing applies to dnsmasq-2.37: earlier versions did not scale as well.
Dnsmasq is capable of handling DNS and DHCP for at least a thousandclients. Clearly to do this the value of --dhcp-lease-maxmust be increased,and lease times should not be very short (less than one hour). Thevalue of --dns-forward-max can be increased: start with it equal tothe number of clients and increase if DNS seems slow. Note that DNSperformance depends too on the performance of the upstreamnameservers. The size of the DNS cache may be increased: the hardlimit is 10000 names and the default (150) is very low. SendingSIGUSR1 to dnsmasq makes it log information which is useful for tuningthe cache size. See the NOTESsection for details.
The built-in TFTP server is capable of many simultaneous filetransfers: the absolute limit is related to the number of file-handlesallowed to a process and the ability of the select() system call tocope with large numbers of file handles. If the limit is set too highusing --tftp-maxit will be scaled down and the actual limit logged atstart-up. Note that more transfers are possible when the same file isbeing sent than when each transfer sends a different file.
It is possible to use dnsmasq to block Web advertising by using a listof known banner-ad servers, all resolving to 127.0.0.1 or 0.0.0.0, in/etc/hosts or an additional hosts file. The list can be very long, dnsmasq has been tested successfully with one million names. That sizefile needs a 1GHz processor and about 60Mb of RAM.
This manual page was written by Simon Kelley <simonAATTthekelleys.org.uk>.
- CONFIG FILE
- EXIT CODES
- SEE ALSO
This document was created byman2html,using the manual pages.