-讓小型網路的管理變得優雅且迅速。dnsmasq 專為資源受限的環境設計,它能輕易地取代體積龐大的 BIND 或 ISC DHCP,為局域網提供快速的 DNS 快取、自動化 IP 分配以及簡便的主機名稱管理。
–多功能合一介面: 在單一二進位檔案中同時提供 DNS 轉發、DHCPv4/v6、TFTP 以及廣告攔截基礎功能。
–極致輕量與低耗能: 記憶體佔用極低,即使是在只有幾 MB 記憶體的路由器或樹莓派零(Pi Zero)上也能穩定運行 。
- 與本地系統完美整合: 能自動讀取
/etc/hosts檔案,讓您只需修改主機檔案即可同步更新局域網內的 DNS 解析紀錄。
–靈活的 DNS 轉發: 支援根據不同的網域(Domain)向不同的上游 DNS 伺服器查詢,並能有效過濾不需要的廣告或惡意網域 。
–支援 PXE 網路開機: 內建 TFTP 伺服器支援,可配合 DHCP 功能輕鬆建構 PXE 環境,進行大規模系統部署。
主要功能、特點
–介紹: dnsmasq 是一款旨在為小型區域網路提供 DNS、DHCP 與相關網路引導服務的開源工具。它是目前許多家用路由器韌體與 Linux 發行版默認的 DNS 解決方案。
- 服務: 提供高速 DNS 快取以減少重複查詢、自動化的 IP 位址租約管理、IPv6 路由器通告、以及針對特定硬體位址(MAC)的靜態 IP 綁定功能。
指令
–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.
-w, –help
Display all command-line options. –help dhcp will display known DHCPv4 configuration options, and –help dhcp6 will display DHCPv6 options.
-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 –no-hosts 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 in alphabetical order.
–hostsdir=<path>
Read all the hosts files contained in the directory. New or changed files are read automatically and modified and deleted files have removed records automatically deleted.
-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 configuration or the DHCP leases file dnsmasq by default sets the time-to-live field to zero, meaning that the requester should not itself cache the information. This is the correct thing to do 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.
–dhcp-ttl=<time>
As for –local-ttl, but affects only replies with information from DHCP leases. If both are given, –dhcp-ttl applies for DHCP information, and –local-ttl for others. Setting this to zero eliminates the effect of –local-ttl for DHCP.
–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.
–max-cache-ttl=<time>
Set a maximum TTL value for entries in the cache.
–min-cache-ttl=<time>
Extend short TTL values to the time given when caching them. Note that artificially extending TTL values is in general a bad idea, do not do it unless you have a good reason, and understand what you are doing. Dnsmasq limits the value of this option to one hour, unless recompiled.
–auth-ttl=<time>
Set the TTL value returned in answers from the authoritative server.


