IrineSistiana / mosdns

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

[Bug] client_ip匹配ipv6 cidr未按预期工作 #784

Open yuukh opened 10 months ago

yuukh commented 10 months ago

在提交之前,请确认

mosdns 版本

v5.3.1

操作系统

debian

Bug 描述和复现步骤

mosdns的client_ip匹配器在匹配ipv6 cidr无法正常工作。复现方式:使用如下配置,通过mosdns的局域网ipv6地址(如fe80::xxxx:xxxx:xxxx:xxxx)解析”www.google.com“,日志中的client为fe80::e2ef:2ff:fe91:bebc属于fe80::/32,但日志不存在query from fakeip 1,故未进入fakeip_sequence;日志中有query from main 2;可以确定clent_ip未成功匹配,未按预期工作

使用的配置文件

log:
  level: info

plugins:
  - tag: forward_fakeip
    type: forward
    args:
      upstreams:
        - addr: "tls://223.5.5.5"

  - tag: fakeip_sequence
    type: sequence
    args:
      - exec: query_summary query from fakeip 1

      - exec: $forward_fakeip
      - exec: accept

  - tag: main_sequence
    type: sequence
    args:
      - exec: query_summary query from main 1

      - matches: 
          - client_ip fe80::/32
        exec: goto fakeip_sequence

      - exec: query_summary query from main 2

      - exec: $forward_fakeip

  - tag: udp_server
    type: udp_server
    args:
      entry: main_sequence
      listen: 0.0.0.0:53

  - tag: tcp_server
    type: tcp_server
    args:
      entry: main_sequence
      listen: 0.0.0.0:53

mosdns 的 log 记录

2024-01-08T01:22:00.097Z    INFO    main_sequence.r6    query from main 2   {"uqid": 1, "client": "fe80::35e0:2ff:fe91:15f8%eth0", "qname": "www.google.com.", "qtype": 28, "qclass": 1, "rcode": 0, "elapsed": "315.171641ms"}
2024-01-08T01:22:00.098Z    INFO    main_sequence.r2    query from main 1   {"uqid": 1, "client": "fe80::35e0:2ff:fe91:15f8%eth0", "qname": "www.google.com.", "qtype": 28, "qclass": 1, "rcode": 0, "elapsed": "316.086599ms"}
wzy105 commented 9 months ago

同样情况:

Sereinfy commented 7 months ago
    • client_ip 192.168.3.2/32 Dnsmasq的原因 试试用mosdns 监听53 。