我遇到过这种情况:我的 hosts 文件不断变化。因此,我不希望客户端缓存使用 hosts 文件解析的 IP 地址。以下是启动 dnsmasq 的命令:
/usr/sbin/dnsmasq -K -R -y -Z -b -E -S 8.8.8.8 -l /tmp/dhcp.leases -r /tmp/resolv.conf.auto --stop-dns-rebind --rebind-localhost-ok --dhcp-range=lan,192.168.2.2,192.168.2.249,255.255.255.0,12h -2 eth0
在查看此站点时:http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
我看到 -T 选项有这样的描述:
-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.
我的命令没有 -T 选项。我需要它吗?或者如果没有它,dnsmasq 是否会将 TTL 默认为零?
答案1
正确,如果您省略-T
或--local-ttl
标志,它将默认为零(对于来自本地机器的请求,例如来自您的hosts
文件的请求)。
您还可以设置一个--max-ttl
标志来指示传回客户端的递归请求的最大 TTL 值。