mokeyish / smartdns-rs

A cross platform local DNS server (Dnsmasq like) written in rust to obtain the fastest website IP for the best Internet experience, supports DoT, DoQ, DoH, DoH3.
GNU General Public License v3.0
556 stars 38 forks source link

没有任何 ipv6 查询结果 #218

Closed PikuZheng closed 3 months ago

PikuZheng commented 8 months ago

查询

C:\Users\Admin>nslookup -qt=a+aaaa www.baidu.com.
DNS request timed out.
    timeout was 2 seconds.
服务器:  UnKnown
Address:  ?????????????????

非权威应答:
名称:    www.a.shifen.com
Addresses:  110.242.68.4
          110.242.68.3

日志

2023-12-26 12:44:26.879:DEBUG:smartdns::app:365: request:2 src:UDP://::ffff:11.20.3.23#52589 type:QUERY dnssec:false QUERY:www.baidu.com.:A:IN qflags:RD
2023-12-26 12:44:26.879:DEBUG:smartdns::dns_mw_cache:345: name: www.baidu.com. using caching
2023-12-26 12:44:26.879:DEBUG:smartdns::dns_mw_ns:102: query name: www.baidu.com. type: A via [Group: mainland]
2023-12-26 12:44:26.883:DEBUG:smartdns::app:365: request:3 src:UDP://::ffff:11.20.3.23#52590 type:QUERY dnssec:false QUERY:www.baidu.com.:AAAA:IN qflags:RD

感觉是直接无视了所有AAAA类型的查询

mokeyish commented 8 months ago

image

百度我也查不到 AAAA,但是 v.qq.com 有。

PikuZheng commented 8 months ago

上游说应该有

C:\Users\Admin>nslookup -qt=a+aaaa www.baidu.com. 119.29.29.29
服务器:  pdns.dnspod.cn
Address:  119.29.29.29

非权威应答:
名称:    www.a.shifen.com
Addresses:  2408:871a:2100:2:0:ff:b09f:237
          2408:871a:2100:3:0:ff:b025:348d
          110.242.68.4
          110.242.68.3
Aliases:  www.baidu.com

但是v.qq.com我这查也没有

C:\Users\Admin>nslookup -qt=a+aaaa v.qq.com. 
DNS request timed out.
    timeout was 2 seconds.
服务器:  UnKnown
Address:  ??????????

非权威应答:
名称:    v.qq.com.sched.px-dk.tdnsv6.com
Addresses:  124.95.177.117
          218.60.37.52
          218.60.10.19
          218.60.37.139
          124.95.177.121
          124.95.177.119
          124.95.177.122
          116.140.45.51
          218.24.83.80

所以是配置加载问题(相同配置原版smartdns正常)?编译问题?

mokeyish commented 8 months ago

应该不是编译问题,可能是测速模式。比如最快响应,就是谁响应快用谁,可能是错误的响应。

PikuZheng commented 8 months ago

为避免混淆,采用单一上游

server-https https://120.53.53.53/dns-query -host-name doh.pub -group mainland -blacklist-ip

查询www.baidu.com仍没有ipv6结果。但是直接打开网页是有的 https://120.53.53.53/dns-query?name=www.baidu.com&type=28

{"Status":0,"TC":false,"RD":true,"RA":true,"AD":false,"CD":false,"Question":[{"name":"www.baidu.com.","type":28}],"Answer":[{"name":"www.baidu.com.","type":5,"TTL":1113,"data":"www.a.shifen.com."},{"name":"www.a.shifen.com.","type":28,"TTL":33,"data":"240e:e9:6002:15b:0:ff:b03c:259e"}]}

在改为单一上游后,试了v.qq.com也是没有ipv6结果

mokeyish commented 8 months ago

貌似可以重现了,我找时间看下。你能否提供最简重现配置?

PikuZheng commented 8 months ago
server-https https://120.53.53.53/dns-query  -group mainland -blacklist-ip

bind [::]:53
dualstack-ip-selection no

domain-set -name mainland -file /etc/smartdns/mainland.txt
domain-set -name outbound -file /etc/smartdns/geoip.txt
domain-set -name outbound -file /etc/smartdns/google.txt

domain-rules /domain-set:mainland/ -speed-check-mode ping -nameserver mainland
domain-rules /domain-set:outbound/ -speed-check-mode none -nameserver outbound -address #6

response-mode fastest-response

注: baidu.com 仅在文件 mainland.txt 中 baidu.jp 仅在文件 geoip.txt 中

mokeyish commented 8 months ago

image

我又重现不了了,好像是上游确实没给

mokeyish commented 8 months ago

用 server-https https://doh.sb/dns-query 拿不到 百度的 IPv6。 用 server-https https://120.53.53.53/dns-query 可以拿到。

PikuZheng commented 8 months ago

当且仅当存在两个同名的domain-set且文件内容与目标域名无关时,该故障重现

mokeyish commented 8 months ago

我又无法重现了,按你说的测了下都是正常的。我怀疑是不是原版的 最快响应模式是,最快的满足查询类型的响应,而不单单是最快而已。

PikuZheng commented 8 months ago

单一上游不存在应答模式问题

mokeyish commented 8 months ago

219 修复了。上游结果测速,再增加查询类型的检查,没有 IPv6 的结果会忽略,如果都没有只能 SOA 了。

同时上面的 UnKnown 服务器,应该也修复了。

PikuZheng commented 8 months ago

未解决。。。感觉是配置加载问题 unknown是因为容器内,本地ip和请求ptr的ip不同

mokeyish commented 8 months ago

你说的 unknown 这种情况,貌似只能加配置选项,指定 IP 了,但貌似 C 版没有这选项。

没有 IPv6 的,你要先确保上游能够查的到。我是用这两个测试的

PikuZheng commented 8 months ago

现在的版本更不对了,查询A+AAAA时,整个返回nxdomain了(以前的版本只有a记录)

配置

server-https https://dns.alidns.com/dns-query -group mainland

bind [::]:53
dualstack-ip-selection no

domain-set -name mainland -file /etc/smartdns/mainland.txt
#domain-set -name outbound -file /etc/smartdns/geoip.txt
domain-set -name outbound -file /etc/smartdns/google.txt
domain-set -name outbound -file /etc/smartdns/outbound.txt

domain-rules /domain-set:mainland/ -speed-check-mode ping -nameserver mainland
domain-rules /domain-set:outbound/ -speed-check-mode none -nameserver outbound -address #6

response-mode fastest-response

其中 baidu.com在文件 mainland.txt 中,baidu.jp 在文件 geoip.txt 中

查询

C:\Users\Administrator>nslookup www.baidu.com. 11.20.3.171
服务器:  UnKnown
Address:  11.20.3.171

非权威应答:
名称:    www.a.shifen.com
Addresses:  110.242.68.4
          110.242.68.3
Aliases:  www.baidu.com

C:\Users\Administrator>nslookup -qt=a+aaaa www.baidu.com. 11.20.3.171
服务器:  UnKnown
Address:  11.20.3.171

*** 没有 www.baidu.com. 可以使用的 internal type for both IPv4 and IPv6 Addresses (A+AAAA)记录

C:\Users\Administrator>

日志

localhost:~# docker logs smartdns-rs-test
2023-12-31 03:04:18.503:INFO: Smart-DNS 🐋 0.7.1 starting
2023-12-31 03:04:18.504:INFO: loading configuration from: "/etc/smartdns/smartdns-test.conf"
2023-12-31 03:04:18.505:INFO: DoaminSet load 272 records into mainland
2023-12-31 03:04:18.506:INFO: DoaminSet load 216 records into outbound
2023-12-31 03:04:18.507:INFO: DoaminSet load 99 records into outbound
2023-12-31 03:04:18.517:INFO: whoami 👉 8fbd2ed6a67c
2023-12-31 03:04:18.517:INFO: upstream server: https://dns.alidns.com/dns-query [Group: ["mainland"]]
2023-12-31 03:04:18.517:INFO: upstream server: https://dns.alidns.com/dns-query [Group: default]
2023-12-31 03:04:18.525:WARN:smartdns::dns_client:131: not bootstrap-dns found, use system_conf instead.
2023-12-31 03:04:18.525:DEBUG:smartdns::dns_client:183: append https://dns.alidns.com/dns-query to default group.
2023-12-31 03:04:18.525:DEBUG:smartdns::dns_client:196: create name server [Group: Default], servers 1
2023-12-31 03:04:18.525:DEBUG:smartdns::dns_client:196: create name server [Group: mainland], servers 1
2023-12-31 03:04:18.525:DEBUG:smartdns::server::net:319: binding UDP to [::]:53
2023-12-31 03:04:18.525:INFO: listening for UDP on [::]:53
2023-12-31 03:04:18.525:INFO:
2023-12-31 03:04:18.525:INFO:      _____                      _       _____  _   _  _____
2023-12-31 03:04:18.525:INFO:     / ____|                    | |     |  __ \| \ | |/ ____|
2023-12-31 03:04:18.525:INFO:    | (___  _ __ ___   __ _ _ __| |_    | |  | |  \| | (___
2023-12-31 03:04:18.525:INFO:     \___ \| '_ ` _ \ / _` | '__| __|   | |  | | . ` |\___ \
2023-12-31 03:04:18.525:INFO:     ____) | | | | | | (_| | |  | |_    | |__| | |\  |____) |
2023-12-31 03:04:18.525:INFO:    |_____/|_| |_| |_|\__,_|_|   \__|   |_____/|_| \_|_____/
2023-12-31 03:04:18.525:INFO:
2023-12-31 03:04:18.525:INFO: awaiting connections...
2023-12-31 03:04:18.525:INFO: server starting up
2023-12-31 03:04:41.36:DEBUG:smartdns::server::udp:43: received udp request from: [::ffff:11.20.3.12]:57397
2023-12-31 03:04:41.36:DEBUG:smartdns::app:365: request:1 src:UDP://::ffff:11.20.3.12#57397 type:QUERY dnssec:false QUERY:171.3.20.11.in-addr.arpa.:PTR:IN qflags:RD
2023-12-31 03:04:41.36:ERROR:smartdns::dns_mw_ns:99: no available nameserver found for 171.3.20.11.in-addr.arpa.
2023-12-31 03:04:41.36:DEBUG:smartdns::app:399: error resolving: Forward resolution error: No connections available
2023-12-31 03:04:41.45:DEBUG:smartdns::server::udp:43: received udp request from: [::ffff:11.20.3.12]:57398
2023-12-31 03:04:41.45:DEBUG:smartdns::app:365: request:2 src:UDP://::ffff:11.20.3.12#57398 type:QUERY dnssec:false QUERY:www.baidu.com.:A:IN qflags:RD
2023-12-31 03:04:41.45:DEBUG:smartdns::dns_client:248: initialize name server [Group: mainland]
2023-12-31 03:04:41.57:DEBUG:smartdns::dns_client::bootstrap:1195: lookup nameserver dns.alidns.com A, [223.5.5.5]
2023-12-31 03:04:41.57:DEBUG:smartdns::dns_mw_ns:104: query name: www.baidu.com. type: A via [Group: mainland]
2023-12-31 03:04:41.210:DEBUG:smartdns::server::udp:43: received udp request from: [::ffff:11.20.3.12]:57399
2023-12-31 03:04:41.210:DEBUG:smartdns::app:365: request:3 src:UDP://::ffff:11.20.3.12#57399 type:QUERY dnssec:false QUERY:www.baidu.com.:AAAA:IN qflags:RD
mokeyish commented 8 months ago

😵‍💫没法重现你的问题。

image

PikuZheng commented 8 months ago

你这肯定不是 fastest-response ,fastest-response 是不测速的

mokeyish commented 8 months ago

不测速,返回两个 ipv6 地址:

image

mokeyish commented 8 months ago

方便的话,你可以调试看看的。vscode 也支持容器内部远程调试的。

image

PikuZheng commented 8 months ago

没有windows环境。。纯容器编译运行

另外您这测试的配置还是不对,没有为上游服务器指定组

mokeyish commented 3 months ago

新版做了这块优化,不知道是否解决你这个问题。

FastestIp 在获取第一个响应后,其他上游必须200毫秒内响应Ip用于测速,否则放弃。之前是等待所有上游取得Ip测速,一个上游慢,会拖慢整个请求超时。

FastestResponse 也调整了,当两个上游都返回一样的错误(SOA 也算错误),就直接返回了。之前是找第一个没错的结果,如果都错,那得等完所有上游结果。

PikuZheng commented 3 months ago

新版正常了 而且查询速度比以前快了很多