IrineSistiana / mosdns

一个 DNS 转发器

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Linux kernel 3.4 无法监听UDP端口

xfl12345 opened this issue · comments

在提交之前,请确认

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

mosdns 版本

v5.3.1

操作系统

hiboy汉化版padavan 2023_7-1

Bug 描述和复现步骤

监听 UDP 端口失败,进而启动失败。(mosdns报错,自动退出)
v5.3.0 同样报错
v5.2.1 报其它错
v5.1.3 一切正常

v5.2.1 日志打印有大量的
ERROR udp_server failed to get dst address from oob {"error": "control msg does not have dst address"}

使用的配置文件

log:
  level: info

plugins:
  # 国内域名
  - tag: china_domain
    type: domain_set
    args:
      exps:
        - "cn"
      # files:
      #   - "./geosite_cn.txt"

  # 国外域名
  - tag: gfw_domain
    type: domain_set
    args:
      exps:
        - "google.com"
      # files:
      #   - "./geosite_gfw.txt"

  # 内网域名
  - tag: local_domain
    type: domain_set
    args:
      exps: 
        - "lan"

  # 缓存
  - tag: cache
    type: cache
    args:
      size: 10240
      lazy_cache_ttl: 120




  # (主力DNS服务器)转发至国内DNS,并发查询
  - tag: forward_china_primary
    type: forward
    args:
      concurrent: 3
      upstreams:
        # # 广东联通 DNS
        # - addr: 116.116.116.116
        # - addr: 221.5.88.88
        # - addr: 2408:8888::8
        # - addr: 2408:8899::8
        # 国内互联网大厂公共 DNS
        - addr: 119.29.29.29
        - addr: 223.5.5.5
        # 国内互联网大厂公共 DNS 
        - addr: 114.114.114.114

  # (主力DNS服务器)转发至国外DNS,并发查询
  - tag: forward_remote_primary
    type: forward
    args:
      concurrent: 2
      upstreams:
        - addr: https://[2606:4700:4700::1111]/dns-query # Cloudflare DNS 主服务器 IPv6 DoH (国内解析有问题)
        # - addr: tls://1.1.1.1 # Cloudflare DNS 主服务器 DoT
        # doh.opendns.com
        - addr: https://208.67.222.222/dns-query # OpenDNS Standard DNS 1 DoH
        - addr: https://[2620:119:35::35]/dns-query # OpenDNS Standard DNS 1 IPv6 DoH
        # - addr: tls://208.67.222.222 # OpenDNS Standard DNS 1 DoT
        # - addr: tls://208.67.222.123 # OpenDNS FamilyShield 1 DoT

  # 国内DNS请求主力流水线
  - tag: china_sequence_primary
    type: sequence
    args:
      # - exec: debug_print query
      - exec: prefer_ipv4 # IPv4 优先,双栈域名只返回IPv4地址
      - exec: $forward_china_primary

  # 国外DNS请求主力流水线
  - tag: remote_sequence_primary
    type: sequence
    args:
      # - exec: debug_print query
      - exec: $forward_remote_primary

  # 未知域名请求主力流水线
  - tag: default_sequence_primary
    type: sequence
    args:
      # - exec: debug_print query
      #(自己定夺。如果要想国内打游戏延迟低点,就必须请求国内DNS)
      - exec: $forward_china_primary
      - matches:
        - has_wanted_ans
        exec: accept
      - exec: $forward_remote_primary
      - matches:
        - has_wanted_ans
        exec: accept

  # 主力流水线
  - tag: primary_sequence
    type: sequence
    args:
      # 如果是国内域名,走国内DNS请求流水线
      - matches: 
        - qname $china_domain
        exec: jump china_sequence_primary
      - matches:
        - has_wanted_ans
        exec: accept
      # 如果是GFWh黑名单域名,走国外DNS请求流水线
      - matches: 
        - qname $gfw_domain
        exec: goto remote_sequence_primary
      - matches:
        - has_wanted_ans
        exec: accept
      # 其它域名走默认请求流水线
      - exec: goto default_sequence_primary






  # (备用DNS服务器)转发至国内DNS,并发查询
  - tag: forward_china_secondary
    type: forward
    args:
      concurrent: 2
      upstreams:
        # 国内互联网大厂公共 DNS DoH 
        - addr: https://223.5.5.5/dns-query # 阿里云 AliDNS DoH
        - addr: https://120.53.53.53/dns-query # 腾讯云 DNSPod DoH
        # - addr: https://sm2.doh.pub/dns-query # 腾讯云 DNSPod 国密 DoH
        # - addr: https://doh.360.cn/dns-query # 360 DNS DoH
        - addr: https://1.12.12.12/dns-query # 腾讯云 DNSPod 备用服务器 DoH
        - addr: https://223.6.6.6/dns-query # 阿里云 AliDNS 备用服务器 DoH
        # 谷歌Google DNS (救场)
        - addr: 8.8.8.8
        # tuna DNS
        # - addr: https://101.6.6.6:8443/dns-query # 清华大学TUNA协会双栈域名递归查询DNS服务器 DoH
        # - addr: tls://dot.pub # 腾讯云 DNSPod DNS DoT
        # - addr: tls://dns.alidns.com # 阿里云 AliDNS DoT
        # - addr: tls://dot.360.cn # 360 DNS DoT
        # tuna DNS
        # - addr: tls://dns.tuna.tsinghua.edu.cn:8853 # 清华大学TUNA协会双栈域名递归查询DNS服务器 DoT

  # (备用DNS服务器)转发至国外DNS,并发查询
  - tag: forward_remote_secondary
    type: forward
    args:
      concurrent: 1
      upstreams:
        # - addr: https://1.1.1.1/dns-query # Cloudflare DNS 主服务器 DoH (国内连不上)
        - addr: https://[2606:4700:4700::1001]/dns-query # Cloudflare DNS 备用服务器 IPv6 DoH (国内解析有问题)
        # doh.familyshield.opendns.com
        - addr: https://208.67.222.123/dns-query # OpenDNS FamilyShield 1 DoH
        - addr: https://[2620:119:35::123]/dns-query # OpenDNS FamilyShield 1 IPv6 DoH
        # doh.opendns.com
        - addr: https://208.67.220.220/dns-query # OpenDNS Standard DNS 2 DoH
        - addr: https://[2620:119:53::53]/dns-query # OpenDNS Standard DNS 2 IPv6 DoH
        # doh.familyshield.opendns.com
        - addr: https://208.67.220.123/dns-query # OpenDNS FamilyShield 2 DoH
        - addr: https://[2620:119:53::123]/dns-query # OpenDNS FamilyShield 2 IPv6 DoH
        # - addr: https://1.0.0.1/dns-query # Cloudflare DNS 备用服务器 DoH
        # - addr: https://8.8.8.8/dns-query # Google DNS DoH
        # doh.sb
        - addr: https://185.222.222.222/dns-query # DNS.SB DoH  
        - addr: https://45.11.45.11/dns-query # DNS.SB DoH  
        # 实验性 DNS over HTTP3
        # - addr: https://dns.cloudflare.com/dns-query
        #   enable_http3: true
        # - addr: https://dns.nextdns.io
        #   enable_http3: true
        - addr: https://dns.adguard-dns.com/dns-query
          enable_http3: true
        - addr: https://dns-unfiltered.adguard.com/dns-query
          enable_http3: true

  # 国内DNS请求备用流水线
  - tag: china_sequence_secondary
    type: sequence
    args:
      - exec: prefer_ipv4 # IPv4 优先,双栈域名只返回IPv4地址
      - exec: $forward_china_secondary

  # 国外DNS请求主力流水线
  - tag: remote_sequence_secondary
    type: sequence
    args:
      # - exec: debug_print query
      - exec: $forward_remote_secondary

  # 未知域名请求备用流水线
  - tag: default_sequence_secondary
    type: sequence
    args:
      # - exec: debug_print query
      - exec: jump china_sequence_secondary
      - matches:
        - has_resp
        exec: accept
      - exec: jump remote_sequence_secondary
      - matches:
        - has_resp
        exec: accept
      - exec: reject

  # 备用流水线
  - tag: secondary_sequence
    type: sequence
    args:
      # 如果是国内域名,走国内DNS请求流水线
      - matches: 
        - qname $china_domain
        exec: jump china_sequence_secondary
      - matches:
        - has_wanted_ans
        exec: accept
      # 如果是GFWh黑名单域名,走国外DNS请求流水线
      - matches: 
        - qname $gfw_domain
        exec: goto remote_sequence_secondary
      - matches:
        - has_wanted_ans
        exec: accept
      # 其它域名走默认请求流水线
      - exec: goto default_sequence_secondary







  # 容灾机制 - 主备DNS
  - tag: fallback
    type: fallback
    args:
      primary: primary_sequence
      secondary: secondary_sequence
      threshold: 3000
      always_standby: true


  # 内网域名请求序列
  - tag: local_sequence
    type: sequence
    args:
      # - exec: debug_print query
      # exec: reject
      - matches:
        - has_resp
        exec: accept








    # 主运行序列
  - tag: main_sequence
    type: sequence
    args:
      - exec: $cache
      - matches:
        - qname $local_domain
        exec: goto local_sequence
      - exec: $fallback


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

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

mosdns 的 log 记录

2023-11-06T12:34:50.227Z        INFO    main config loaded      {"file": "/tmp/mosdns/config.yaml"}
2023-11-06T12:34:50.232Z        INFO    loading plugin  {"tag": "china_domain", "type": "domain_set"}
2023-11-06T12:34:51.508Z        INFO    loading plugin  {"tag": "gfw_domain", "type": "domain_set"}
2023-11-06T12:34:51.642Z        INFO    loading plugin  {"tag": "local_domain", "type": "domain_set"}
2023-11-06T12:34:51.643Z        INFO    loading plugin  {"tag": "cache", "type": "cache"}
2023-11-06T12:34:51.649Z        INFO    loading plugin  {"tag": "forward_china_primary", "type": "forward"}
2023-11-06T12:34:51.653Z        INFO    loading plugin  {"tag": "forward_remote_primary", "type": "forward"}
2023-11-06T12:34:51.656Z        INFO    loading plugin  {"tag": "china_sequence_primary", "type": "sequence"}
2023-11-06T12:34:51.658Z        INFO    loading plugin  {"tag": "remote_sequence_primary", "type": "sequence"}
2023-11-06T12:34:51.658Z        INFO    loading plugin  {"tag": "default_sequence_primary", "type": "sequence"}
2023-11-06T12:34:51.660Z        INFO    loading plugin  {"tag": "primary_sequence", "type": "sequence"}
2023-11-06T12:34:51.664Z        INFO    loading plugin  {"tag": "forward_china_secondary", "type": "forward"}
2023-11-06T12:34:51.673Z        INFO    loading plugin  {"tag": "forward_remote_secondary", "type": "forward"}
2023-11-06T12:34:51.683Z        INFO    loading plugin  {"tag": "china_sequence_secondary", "type": "sequence"}
2023-11-06T12:34:51.684Z        INFO    loading plugin  {"tag": "remote_sequence_secondary", "type": "sequence"}
2023-11-06T12:34:51.685Z        INFO    loading plugin  {"tag": "default_sequence_secondary", "type": "sequence"}
2023-11-06T12:34:51.687Z        INFO    loading plugin  {"tag": "secondary_sequence", "type": "sequence"}
2023-11-06T12:34:51.688Z        INFO    loading plugin  {"tag": "fallback", "type": "fallback"}
2023-11-06T12:34:51.688Z        INFO    loading plugin  {"tag": "local_sequence", "type": "sequence"}
2023-11-06T12:34:51.689Z        INFO    loading plugin  {"tag": "main_sequence", "type": "sequence"}
2023-11-06T12:34:51.690Z        INFO    loading plugin  {"tag": "udp_server", "type": "udp_server"}
2023-11-06T12:34:51.691Z        INFO    starting shutdown sequences
2023-11-06T12:34:51.692Z        INFO    closing plugin  {"tag": "forward_china_secondary"}
2023-11-06T12:34:51.692Z        INFO    closing plugin  {"tag": "china_sequence_secondary"}
2023-11-06T12:34:51.693Z        INFO    closing plugin  {"tag": "remote_sequence_secondary"}
2023-11-06T12:34:51.693Z        INFO    closing plugin  {"tag": "default_sequence_secondary"}
2023-11-06T12:34:51.694Z        INFO    closing plugin  {"tag": "secondary_sequence"}
2023-11-06T12:34:51.694Z        INFO    closing plugin  {"tag": "main_sequence"}
2023-11-06T12:34:51.694Z        INFO    closing plugin  {"tag": "cache"}
2023-11-06T12:34:51.694Z        INFO    closing plugin  {"tag": "forward_china_primary"}
2023-11-06T12:34:51.695Z        INFO    closing plugin  {"tag": "forward_remote_primary"}
2023-11-06T12:34:51.695Z        INFO    closing plugin  {"tag": "forward_remote_secondary"}
2023-11-06T12:34:51.695Z        INFO    closing plugin  {"tag": "china_sequence_primary"}
2023-11-06T12:34:51.695Z        INFO    closing plugin  {"tag": "default_sequence_primary"}
2023-11-06T12:34:51.696Z        INFO    closing plugin  {"tag": "local_sequence"}
2023-11-06T12:34:51.696Z        INFO    closing plugin  {"tag": "remote_sequence_primary"}
2023-11-06T12:34:51.696Z        INFO    closing plugin  {"tag": "primary_sequence"}
2023-11-06T12:34:51.696Z        INFO    all plugins were closed
Error: failed to init plugin #19 udp_server, failed to init plugin: failed to create socket, listen udp 0.0.0.0:5553: protocol not available
2023-11-06T12:34:51.697Z        FATAL   failed to init plugin #19 udp_server, failed to init plugin: failed to create socket, listen udp 0.0.0.0:5553: protocol not available

内核版本?

#750 相似。

内核版本?

#750 相似。

[newifi-d2 /opt/home/admin]# uname -a
Linux newifi-d2 3.4.113 #1 SMP Fri Jun 30 01:04:48 CST 2023 mips GNU/Linux
[newifi-d2 /opt/home/admin]# cat /proc/version 
Linux version 3.4.113 (root@hiboy-VirtualBox) (gcc version 4.4.7 (GCC) ) #1 SMP Fri Jun 30 01:04:48 CST 2023
[newifi-d2 /opt/home/admin]# 

去掉0.0.0.0呢?

去掉0.0.0.0呢?

不行。他这有两个问题。

failed to create socket, listen udp 0.0.0.0:5553: protocol not available

这个是内核太老了。mosdns 最近加了一些优化,需要 3.9+

Linux 3.9 was released on April 28, 2013

3.9 内核也已经十年了。

control msg does not have dst address

#750 相似。

去掉0.0.0.0呢?

去掉 "0.0.0.0" 、换成 "127.0.0.1" 都不行

这几天在刷机弄OPENWRT,刚好也出现过未运行的情况。MT7621平台,刷机包定制的带MOSDNS,设置后无法启动。一次是联网更新了一下MOSDNS后正常(刷机包3天前定制的,版本显示是5.3.1的最新,但是联网查库显示还能更新),今天上午重新定制刷机包,集成最新版MOSDNS后设置参数显示未运行,手动安装了Goip的两个包后仍未运行,把路由器重启后显示已运行。
不知道这些情况是不是有关连。

内核版本Linux OpenWrt 5.15.137 也存在同样的问题