dnsmasq 缓存不生效

2018-05-06 19:06:48 +08:00
 qsnow6

在 mac 上用 brew 安装好了 dnsmasq,经过一翻配置。折腾完了,但是测试后发现,并没有缓存成功。以下是 2 次 dig 日志


deMacBook-Pro:etc $ dig g.cn

; <<>> DiG 9.10.6 <<>> g.cn
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27925
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;g.cn.				IN	A

;; ANSWER SECTION:
g.cn.			129	IN	A	203.208.50.79
g.cn.			129	IN	A	203.208.50.95
g.cn.			129	IN	A	203.208.50.87
g.cn.			129	IN	A	203.208.50.88

;; Query time: 103 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun May 06 19:01:04 CST 2018
;; MSG SIZE  rcvd: 97

deMacBook-Pro:etc $ dig g.cn

; <<>> DiG 9.10.6 <<>> g.cn
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36864
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;g.cn.				IN	A

;; ANSWER SECTION:
g.cn.			128	IN	A	203.208.50.88
g.cn.			128	IN	A	203.208.50.79
g.cn.			128	IN	A	203.208.50.95
g.cn.			128	IN	A	203.208.50.87

;; Query time: 131 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun May 06 19:01:05 CST 2018
;; MSG SIZE  rcvd: 97

dnsmasq.conf

resolv-file=/usr/local/etc/resolv.dnsmasq.conf
strict-order
cache-size=32768
listen-address=127.0.0.1
zhangsihuideMacBook-Pro:etc zhangsihui$

resolv.dnsmasq.conf

deMacBook-Pro:etc $ cat resolv.dnsmasq.conf
nameserver 61.139.2.69
nameserver 202.98.96.68
nameserver 119.29.29.29

versions

$ /usr/local/opt/dnsmasq/sbin/dnsmasq -v
Dnsmasq version 2.79  Copyright (c) 2000-2018 Simon Kelley
Compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack no-ipset auth no-DNSSEC loop-detect no-inotify

This software comes with ABSOLUTELY NO WARRANTY.
Dnsmasq is free software, and you are welcome to redistribute it
under the terms of the GNU General Public License, version 2 or 3.

这是啥原因? dig 显示的 server 地址表示已经解析成功了,但是为什么没有缓存?

6035 次点击
所在节点    DNS
10 条回复
crysislinux
2018-05-06 19:09:42 +08:00
生效了,129 变成 128 了
qsnow6
2018-05-06 19:11:25 +08:00
@crysislinux #1 不是看 Query time 吗
crysislinux
2018-05-06 19:14:28 +08:00
query time 确实不太好。但是那个时间感觉就是再算 ttl
param
2018-05-07 02:58:01 +08:00
我是緩存清不掉。。
hzqim
2018-05-07 10:25:13 +08:00
设置 min-cache-ttl=3600

效果:
root@LEDE:~# dig www.baidu.com

; <<>> DiG 9.10.4-P5 <<>> www.baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43889
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.baidu.com. IN A

;; ANSWER SECTION:
www.baidu.com. 3459 IN CNAME www.a.shifen.com.
www.a.shifen.com. 3459 IN A 14.215.177.38
www.a.shifen.com. 3459 IN A 14.215.177.39

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon May 07 10:21:00 CST 2018
;; MSG SIZE rcvd: 104
krisbai
2018-05-07 12:47:28 +08:00
有没有开启客户端缓存服务?
qsnow6
2018-05-08 22:29:23 +08:00
@krisbai #6 这个配置是开启了吗

resolv-file=/usr/local/etc/resolv.dnsmasq.conf
strict-order
cache-size=32768
listen-address=127.0.0.1
q0000x
2018-05-16 09:10:35 +08:00
@qsnow6 少了 min-cache-ttl=3600 这个配置,3600 是秒
taobibi
2018-05-24 09:27:24 +08:00
@qsnow6 listen-address=0.0.0.0
这样其他设备都能解析
cache-size=32768
min-cache-ttl=3600
zhouyut001
2018-08-25 10:30:37 +08:00
用 all-servers,并发查询多个 dns,优选最快的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/452584

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX