IrineSistiana / mosdns

一个 DNS 转发器
GNU General Public License v3.0
3k stars 340 forks source link

[Bug] 遇到有CNAME記錄無A/AAAA的返回可能會出現SERVFAIL #749

Open uenokatsura opened 1 year ago

uenokatsura commented 1 year ago

在提交之前,请确认

mosdns 版本

v5.3.1

操作系统

Debian x86_64

Bug 描述和复现步骤

使用 dig 請求 onedrive.live.com 的 A 或 AAAA 記錄

> dig onedrive.live.com AAAA

; <<>> DiG 9.16.44 <<>> onedrive.live.com AAAA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 24719
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1200
;; QUESTION SECTION:
;onedrive.live.com.             IN      AAAA

;; Query time: 107 msec
;; SERVER: 10.0.0.1#53(10.0.0.1)
;; WHEN: Mon Nov 06 15:19:40 Taipei Standard Time 2023
;; MSG SIZE  rcvd: 46

使用的配置文件

log:
  level: debug

plugins:
  - tag: geoip_cn_4
    type: ip_set
    args:
      files:
      - "./geoip_cn_4.txt"

  - tag: geoip_cn_6
    type: ip_set
    args:
      files:
      - "./geoip_cn_6.txt"

  - tag: remote_dns
    type: forward
    args:
      concurrent: 1
      upstreams:
      - tag: google_doh
        addr: "https://dns.google/dns-query"
        dial_addr: "2001:4860:4860::8888"
        enable_pipeline: true
        enable_http3: true

  - tag: local_dns
    type: forward
    args:
      concurrent: 1
      upstreams:
      - tag: alidns_doh
        addr: "https://dns.alidns.com/dns-query"
        dial_addr: "2400:3200::1"
        enable_pipeline: true
        enable_http3: true

  - tag: main
    type: sequence
    args:
      - exec: "ecs 58.32.0.0/17"
      - exec: $remote_dns
      - matches:
        - "resp_ip $geoip_cn_4 $geoip_cn_6"
        exec: $local_dns
      - matches:
        - has_resp
        exec: accept

      - exec: "ecs 104.28.211.0/24"
      - exec: $remote_dns
      - exec: accept

  - type: udp_server
    args:
      entry: main
      listen: "[::]:53"
  - type: tcp_server
    args:
      entry: main
      listen: "[::]:53"

mosdns 的 log 记录

2023-11-06T07:19:36.436Z        WARN    anonymouse_udp_server_8 entry err       {"query": {"uqid": 1, "client": "::ffff:10.1.0.30", "qname": "onedrive.live.com.", "qtype": 1, "qclass": 1, "elapsed": "776.492847ms"}, "error": "all upstream servers failed"}