Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 启动一段时间后请求无响应 #148

Closed
suienzan opened this issue Aug 12, 2021 · 8 comments
Closed

[BUG] 启动一段时间后请求无响应 #148

suienzan opened this issue Aug 12, 2021 · 8 comments

Comments

@suienzan
Copy link

suienzan commented Aug 12, 2021

出现了什么问题

启动一段时间后 (一个多小时到 2 小时后), 期间有长时间链接openvpn, 之后断开连接一段时间. 请求无响应, 重启后正常.

  • drill 任意域名报错 Error: error sending query: Could not send or receive, because of network error.
~ ❯ drill www.baidu.com                                                                                                                                                                                                            15:46:11
Error: error sending query: Could not send or receive, because of network error
~ 15s ❯ ping 223.5.5.5 -c 4                                                                                                                                                                                                        15:46:37
PING 223.5.5.5 (223.5.5.5) 56(84) bytes of data.
64 バイト応答 送信元 223.5.5.5: icmp_seq=1 ttl=115 時間=11.0ミリ秒
64 バイト応答 送信元 223.5.5.5: icmp_seq=2 ttl=115 時間=13.7ミリ秒
64 バイト応答 送信元 223.5.5.5: icmp_seq=3 ttl=115 時間=11.7ミリ秒
64 バイト応答 送信元 223.5.5.5: icmp_seq=4 ttl=115 時間=10.5ミリ秒

--- 223.5.5.5 ping 統計 ---
送信パケット数 4, 受信パケット数 4, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 10.498/11.722/13.653/1.198 ms
~ ❯ tail -20 /etc/mosdns/debug.log                                                                                                                                                                                                 15:47:15
2021-08-16T15:47:03.282+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4287", "tag": "_default_cache"}
2021-08-16T15:47:03.282+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4287", "tag": "main_sequence"}
2021-08-16T15:47:03.282+0900    debug   handler/plugin_wrapper.go:99    matching query context  {"query": "www.baidu.com. IN A 62898 4287", "tag": "query_is_ad_domain", "result": false}
2021-08-16T15:47:03.282+0900    debug   handler/plugin_wrapper.go:99    matching query context  {"query": "www.baidu.com. IN A 62898 4287", "tag": "query_is_local_domain", "result": true}
2021-08-16T15:47:03.282+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4287", "tag": "forward_local"}
2021-08-16T15:47:08.533+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4288", "tag": "_default_cache"}
2021-08-16T15:47:08.533+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4288", "tag": "main_sequence"}
2021-08-16T15:47:08.533+0900    debug   handler/plugin_wrapper.go:99    matching query context  {"query": "www.baidu.com. IN A 62898 4288", "tag": "query_is_ad_domain", "result": false}
2021-08-16T15:47:08.533+0900    debug   handler/plugin_wrapper.go:99    matching query context  {"query": "www.baidu.com. IN A 62898 4288", "tag": "query_is_local_domain", "result": true}
2021-08-16T15:47:08.533+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4288", "tag": "forward_local"}
2021-08-16T15:47:13.782+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4289", "tag": "_default_cache"}
2021-08-16T15:47:13.783+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4289", "tag": "main_sequence"}
2021-08-16T15:47:13.783+0900    debug   handler/plugin_wrapper.go:99    matching query context  {"query": "www.baidu.com. IN A 62898 4289", "tag": "query_is_ad_domain", "result": false}
2021-08-16T15:47:13.783+0900    debug   handler/plugin_wrapper.go:99    matching query context  {"query": "www.baidu.com. IN A 62898 4289", "tag": "query_is_local_domain", "result": true}
2021-08-16T15:47:13.783+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4289", "tag": "forward_local"}
2021-08-16T15:47:19.033+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4290", "tag": "_default_cache"}
2021-08-16T15:47:19.033+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4290", "tag": "main_sequence"}
2021-08-16T15:47:19.033+0900    debug   handler/plugin_wrapper.go:99    matching query context  {"query": "www.baidu.com. IN A 62898 4290", "tag": "query_is_ad_domain", "result": false}
2021-08-16T15:47:19.033+0900    debug   handler/plugin_wrapper.go:99    matching query context  {"query": "www.baidu.com. IN A 62898 4290", "tag": "query_is_local_domain", "result": true}
2021-08-16T15:47:19.033+0900    debug   handler/plugin_wrapper.go:116   executing plugin        {"query": "www.baidu.com. IN A 62898 4290", "tag": "forward_local"}
~ ❯ drill @223.5.5.5 www.baidu.com                                                                                                                                                                                                 15:47:32
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 60691
;; flags: qr rd ra ; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 
;; QUESTION SECTION:
;; www.baidu.com.       IN      A

;; ANSWER SECTION:
www.baidu.com.  57      IN      CNAME   www.a.shifen.com.
www.a.shifen.com.       57      IN      A       14.215.177.38
www.a.shifen.com.       57      IN      A       14.215.177.39

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 12 msec
;; SERVER: 223.5.5.5
;; WHEN: Mon Aug 16 15:54:33 2021
;; MSG SIZE  rcvd: 90
~ ❯                                                         

如何重现

mosdns 的版本号(v1.8.6-0-gda960f3):

使用的启动参数或启动方式: systemd

[Service]
NoNewPrivileges=true
ExecStart=/usr/bin/mosdns -c /etc/mosdns/config.yaml -dir /etc/mosdns/
Restart=on-failure

操作系统和平台:Arch Linux

进行了什么操作导致了问题的出现:

启动服务后,正常使用一段时间.

使用的配置文件:

log:
  level: debug
  file: "/etc/mosdns/debug.log"

plugin:
  ################# 服务插件 ################

  # 启动服务器的插件
  - tag: main_server
    type: server
    args:
      entry:
        - _default_cache # 缓存
        - main_sequence # 分流逻辑
      server:
        - protocol: udp
          addr: 127.0.0.1:53
        - protocol: tcp
          addr: 127.0.0.1:53
        - protocol: udp
          addr: "[::1]:53"
        - protocol: tcp
          addr: "[::1]:53"

  ################# 可执行插件 ################

  # 包含分流的逻辑的插件
  - tag: main_sequence
    type: sequence
    args:
      exec:
        - if:
            - query_is_ad_domain # 已知的广告域名
          exec:
            - _block_with_nxdomain # 用 NXDOMAIN 屏蔽
            - _end

        - if:
            - query_is_local_domain # 已知的本地域名
            - "!_query_is_common" # 和不常见的请求类型
          exec:
            - forward_local # 用本地服务器
            - _end

        - if:
            - query_is_non_local_domain # 已知的非本地域名
          exec:
            - forward_remote # 用远程服务器
            - _end

        # 剩下的未知域名用 IP 分流。以下是"顺序 IP 分流"方案。先转发至本地服务器,然后
        # 判断应答 IP 再决定是否转发至远程服务器。没有竞争,很稳定,不易出错。
        # <高级> 如果想用"并发 IP 分流"方案,从下文的 <并发 IP 分流示例> 里选择一个方案,
        # 然后将下面几行替换掉。复制时注意缩进。
        # 并发分流会同时请求本地和远程服务器,延时稍低些,但存在竞争,可能出现非期望的分流结果。
        - forward_local # 先请求转发至本地服务器
        - if:
            - response_has_local_ip # 如果(本地)应答包含本地 IP
          exec:
            - _end # 就直接采用结果
        - forward_remote # 否则去请求远程服务器的结果

  # 转发请求至本地服务器的插件
  - tag: forward_local
    type: forward
    args:
      upstream:
        - addr: https://223.5.5.5/dns-query

  # 转发请求至远程服务器的插件
  - tag: forward_remote
    type: forward
    args:
      upstream:
        - addr: https://1.1.1.1/dns-query

  ################ 匹配器插件 #################

  - tag: query_is_local_domain # 匹配本地域名的插件
    type: query_matcher
    args:
      domain:
        - ext:/usr/share/v2ray/geosite.dat:cn

  - tag: query_is_non_local_domain # 匹配非本地域名的插件
    type: query_matcher
    args:
      domain:
        - ext:/usr/share/v2ray/geosite.dat:geolocation-!cn

  - tag: query_is_ad_domain # 匹配广告域名的插件
    type: query_matcher
    args:
      domain:
        - ext:/usr/share/v2ray/geosite.dat:category-ads-all

  - tag: response_has_local_ip # 匹配本地 IP的插件
    type: response_matcher
    args:
      ip:
        - ext:/usr/share/v2ray/geoip.dat:cn

include: []
@IrineSistiana
Copy link
Owner

你能不能试试把 forward 插件换成 fast_forward,看看还会不会出问题。看样子像是 forward 没响应。

@suienzan
Copy link
Author

我换过来用几天试试

@suienzan
Copy link
Author

用了几天, 没这个问题了.

@suienzan
Copy link
Author

使用 fast_forward 在切断 openvpn 之后几秒内所有请求全返回空, 然后恢复正常

@IrineSistiana
Copy link
Owner

IrineSistiana commented Sep 1, 2021

应该是网卡的问题,断openvpn但没断套接字。导致mosdns一直重用不能用的旧连接,直到超时
tcp无解。udp应该不会有问题。

无意中遇到openwrt上pppoe断掉也会出现一模一样的情况。

@suienzan
Copy link
Author

suienzan commented Sep 1, 2021

就是说这种情况只能用 fast_forward ?

@IrineSistiana
Copy link
Owner

IrineSistiana commented Sep 1, 2021

fastforward设了超时检测。
forward是用的 adhome 的东西。可能他们处理上有点问题。有空我再看。
影响大可以换udp协议。

@IrineSistiana
Copy link
Owner

forward 的上游更新了。看 adhome 的记录他们加超时限制了。应该没问题了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants