pymumu / smartdns

A local DNS server to obtain the fastest website IP for the best Internet experience, support DoT, DoH. 一个本地DNS服务器,获取最快的网站IP,获得最佳上网体验,支持DoH,DoT。
https://pymumu.github.io/smartdns/
GNU General Public License v3.0
8.49k stars 1.09k forks source link

I have to rm cache file to let smartdns not returning STATUS:REFUSED #1838

Closed Originalimoc closed 1 month ago

Originalimoc commented 1 month ago

问题现象
nslookup www.bilibili.com 192.168.1.1 Server: router Address: 192.168.1.1

*** routercan't find www.bilibili.com: Query refused

运行环境

  1. 固件型号
    x86_64 Linux 5.15

  2. 运营商
    Hybrid upstream

  3. smartdns来源以及版本 Compiled from latest source

  4. 涉及的配置(注意去除个人相关信息) bind [::]:53 server 127.0.0.1:5355 prefetch-domain yes serve-expired-prefetch-time 21600 serve-expired yes serve-expired-ttl 259200 serve-expired-reply-ttl 5 dualstack-ip-selection yes dualstack-ip-selection-threshold 15 speed-check-mode ping,tcp:443,tcp:80 user nobody

重现步骤

  1. 上游DNS配置。
    NA

  2. 访问的域名。
    NA

信息收集
Does smartdns cache negative response? If so it needs a no-neg-cache option like dnsmasq.

PikuZheng commented 1 month ago

makesure the user running smartdns has full access to the cache file. also confirm that the user pid is the same each time it is run?

Originalimoc commented 1 month ago

not in memory? or partial memory partial on-demand read disk? if so the doc should get an update on the "user nobody" part. Recommend "sudo adduser --system --no-create-home --group smartdns" plus automatically set the ownership before it drops permission to conf defined user

PikuZheng commented 1 month ago

Smartdns reads the cache file when it starts, and periodically writes the cache in memory to the file. Based on your description, I suspect that the user who starts smartdns each time is different, or the file read and write permissions are incorrect.

Originalimoc commented 1 month ago

Well... no Query refused so far, but... Another issue. I set "user smartdns" and "cache-file /var/cache/ smartdns.cache"... Then it makes /var/cache 0750 and owned by smartdns. Don't... Remove this codepath.

PikuZheng commented 1 month ago

0640 by default (I changed it to 0644 for my own use)https://github.com/pymumu/smartdns/blob/84f217dbd19f97e30f24af640ddb4cd21ae1e3ec/src/dns_cache.c#L842

Originalimoc commented 1 month ago

You misunderstood. It somehow made the dir /var/cache its own dir. Not only the file it tries to use.

Originalimoc commented 1 month ago

No. Doesn't work, still returning the status REFUSED DNS result. I always launch smartdns with root and used "user smartdns; cachefile /var/cache/smartdns/smartdns.cache". It is caching negative results somehow.

Originalimoc commented 1 month ago

Well... It's actually returned by upstream dnsmasq but I dig upstream of it no error... Never happened in a few years. Debugging why.

Originalimoc commented 1 month ago

Not smartdns bug. I'll open another issue for that permission problem.