qsnow6
V2EX  ›  DNS

dnsmasq 缓存不生效

  •  
  •   qsnow6 · May 6, 2018 · 6606 views
    This topic created in 2947 days ago, the information mentioned may be changed or developed.

    在 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 地址表示已经解析成功了,但是为什么没有缓存?

    10 replies    2018-08-25 10:30:37 +08:00
    crysislinux
        1
    crysislinux  
       May 6, 2018 via Android
    生效了,129 变成 128 了
    qsnow6
        2
    qsnow6  
    OP
       May 6, 2018
    @crysislinux #1 不是看 Query time 吗
    crysislinux
        3
    crysislinux  
       May 6, 2018 via Android
    query time 确实不太好。但是那个时间感觉就是再算 ttl
    param
        4
    param  
       May 7, 2018 via Android
    我是緩存清不掉。。
    hzqim
        5
    hzqim  
       May 7, 2018
    设置 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
        6
    krisbai  
       May 7, 2018
    有没有开启客户端缓存服务?
    qsnow6
        7
    qsnow6  
    OP
       May 8, 2018
    @krisbai #6 这个配置是开启了吗

    resolv-file=/usr/local/etc/resolv.dnsmasq.conf
    strict-order
    cache-size=32768
    listen-address=127.0.0.1
    q0000x
        8
    q0000x  
       May 16, 2018   ❤️ 1
    @qsnow6 少了 min-cache-ttl=3600 这个配置,3600 是秒
    taobibi
        9
    taobibi  
       May 24, 2018
    @qsnow6 listen-address=0.0.0.0
    这样其他设备都能解析
    cache-size=32768
    min-cache-ttl=3600
    zhouyut001
        10
    zhouyut001  
       Aug 25, 2018
    用 all-servers,并发查询多个 dns,优选最快的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3723 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 10:32 · PVG 18:32 · LAX 03:32 · JFK 06:32
    ♥ Do have faith in what you're doing.