IrineSistiana / mosdns

一个 DNS 转发器

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] 配置文件为 wiki 中的简单转发器配置文件,mosdns 无法正常工作

zwyyy456 opened this issue · comments

在提交之前,请确认

  • 我已经尝试搜索过 Issue ,但没有找到相关问题。
  • 我正在使用最新的 mosdns 版本(或者最新的 commit),问题依旧存在。
  • 我仔细看过 wiki 后仍然无法自行解决该问题。
  • 我非常确定这是 mosdns 核心的问题。(如果是通过第三方衍生软件使用 mosdns 核心,不确定问题源头时,请先向衍生软件开发者提交问题。)

mosdns 版本

v5.3.1-0-ga281fdb

操作系统

armbian (N1)

Bug 描述和复现步骤

mosdns 可执行文件位于 N1 /root/mosdns 目录下,ip 为 192.168.6.206,配置文件 config.yaml 同样位于 /root/mosdns 目录下,config.yaml 的内容为

log:
  level: info

plugins:
  # 转发至 Google 服务器的插件
  - tag: forward_google
    type: forward
    args:
      upstreams:
        - addr: https://8.8.8.8/dns-query

 # 在同一端口启动 udp 和 tcp 服务器。
  - type: udp_server
    args:
      entry: forward_google
      listen: 127.0.0.1:5533
  - type: tcp_server
    args:
      entry: forward_google
      listen: 127.0.0.1:5533

/root/mosdns 目录下执行 ./mosdns start,输出为

2023-12-21T17:20:30.765+0800    INFO    main config loaded      {"file": "/root/mosdns/config.yaml"}
2023-12-21T17:20:30.767+0800    INFO    loading plugin  {"tag": "forward_google", "type": "forward"}
2023-12-21T17:20:30.767+0800    INFO    loading plugin  {"tag": "anonymouse_udp_server_2", "type": "udp_server"}
2023-12-21T17:20:30.768+0800    INFO    anonymouse_udp_server_2 udp server started      {"addr": "127.0.0.1:5533"}
2023-12-21T17:20:30.769+0800    INFO    loading plugin  {"tag": "anonymouse_tcp_server_3", "type": "tcp_server"}
2023-12-21T17:20:30.770+0800    INFO    anonymouse_tcp_server_3 tcp server started      {"addr": "127.0.0.1:5533", "tls": false}
2023-12-21T17:20:30.770+0800    INFO    all plugins are loaded

执行 lsof -i :5533,输出为

root@armbian ~# lsof -i :5533
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mosdns  2706 root    3u  IPv4  44106      0t0  UDP localhost:5533
mosdns  2706 root    7u  IPv4  44107      0t0  TCP localhost:5533 (LISTEN)

在我的 mac(与 N1 位与同一个局域网下,ip 获取方式为 dhcp)的终端中,执行 dig www.google.com @192.168.6.206 -p 5533,输出为:

; <<>> DiG 9.10.6 <<>> www.baidu.com @192.168.6.206 -p 5533
;; global options: +cmd
;; connection timed out; no servers could be reached

执行 dig www.google.com,输出为:

zwyyy@zwy-mbp14 ~/.c/tpclash (main) [9]> dig www.google.com                                                                                                                               (base)

; <<>> DiG 9.10.6 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7884
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; MBZ: 0x0001, udp: 4095
;; QUESTION SECTION:
;www.google.com.                        IN      A

;; ANSWER SECTION:
www.google.com.         1       IN      A       198.18.0.46

;; Query time: 5 msec
;; SERVER: 100.100.100.100#53(100.100.100.100)
;; WHEN: Thu Dec 21 17:24:30 CST 2023
;; MSG SIZE  rcvd: 59

尝试将 配置文件中的 https://8.8.8.8/dns-query 替换成 https://223.5.5.5/dns-query,执行 dig www.google.com @192.168.6.206 -p 5533 的结果依旧是:

; <<>> DiG 9.10.6 <<>> www.baidu.com @192.168.6.206 -p 5533
;; global options: +cmd
;; connection timed out; no servers could be reached

使用的配置文件

log:
  level: info

plugins:
  # 转发至 Google 服务器的插件
  - tag: forward_google
    type: forward
    args:
      upstreams:
        - addr: https://223.5.5.5/dns-query

 # 在同一端口启动 udp 和 tcp 服务器。
  - type: udp_server
    args:
      entry: forward_google
      listen: 127.0.0.1:5533
  - type: tcp_server
    args:
      entry: forward_google
      listen: 127.0.0.1:5533

mosdns 的 log 记录

2023-12-21T17:26:50.005+0800    INFO    main config loaded      {"file": "/root/mosdns/config.yaml"}
2023-12-21T17:26:50.007+0800    INFO    loading plugin  {"tag": "forward_google", "type": "forward"}
2023-12-21T17:26:50.007+0800    INFO    loading plugin  {"tag": "anonymouse_udp_server_2", "type": "udp_server"}
2023-12-21T17:26:50.007+0800    INFO    anonymouse_udp_server_2 udp server started      {"addr": "127.0.0.1:5533"}
2023-12-21T17:26:50.008+0800    INFO    loading plugin  {"tag": "anonymouse_tcp_server_3", "type": "tcp_server"}
2023-12-21T17:26:50.008+0800    INFO    anonymouse_tcp_server_3 tcp server started      {"addr": "127.0.0.1:5533", "tls": false}
2023-12-21T17:26:50.008+0800    INFO    all plugins are loaded
commented

把两个listen后的127.0.0.1删除了,如下:
listen: ":5533"

把两个listen后的127.0.0.1删除了,如下: listen: ":5533"

感谢,已解决!