V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
OpenWrt 是一个专门面向嵌入式设备的 Linux 发行版。你可以将 OpenWrt 支持的型号的嵌入式设备,比如各种路由器上的系统,换成一个有更多可能性可以折腾的 Linux 系统。
OpenWrt 官方网站
nowheretoseek
V2EX  ›  OpenWrt

openwrt 经常无法提供 dhcp、dns 服务

  •  
  •   nowheretoseek · 354 天前 · 1846 次点击
    这是一个创建于 354 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在 newifi3-d2 上运行 openwrt 22.03.3 ,互联网是通过 wwan 接入的,wan 口无网线。

    问题表现为:

    1 、有时无线连不上,日志中很多 hostapd 相关信息,终端显示是卡在获取 IP 这一步
    2 、无线连接出问题时,有线连接也有同样问题,但印象里见过这时候有线可以用,只是无线连不上
    3 、出问题后,手动配置客户端的 ip 后可联网,但路由器 dns 转发功能不工作,需要手动配置公共 dns
    4 、lsof -i:53 结果为空(工作正常时,是会打印多行的文件描述符占用的),dns 转发解析不工作

    从现象看,是 dnsmasq 的问题,可 dnsmasq 显示版本号是 2.8.6 ,最近更新是 2021 ,并不是新近的版本。

    这个现象路由器重启后大概率会出现,但过段时间就好了(这段时间可能几十分钟甚至更久)。有时正常用着,突然又出了这问题。内核日志看不出异常,系统日志也看不出 dnsmasq 进程有异常。问题出现时,重启 dnsmasq 进程没用。

    我尝试过重刷系统,未作配置时,dhcp 服务无问题,恢复备份的 overlay 后重启,问题又出现。看上去是错误的配置或软件 bug ,可是有时问题过段时间又会消失,让人摸不着头脑。

    总之,从进程、日志我看不出明显的症结。怀疑是硬件或系统的问题,可以有没有搜到类似的报告。请有经验的朋友帮解惑下,谢谢!
    12 条回复    2023-05-15 14:13:00 +08:00
    br2049
        1
    br2049  
       354 天前
    试试最新的 22.03.5 ?
    Yzh361
        2
    Yzh361  
       353 天前 via Android
    换版本试试
    nowheretoseek
        3
    nowheretoseek  
    OP
       353 天前
    @br2049 刷过 22.03.5 ,恢复 overlay 备份后还是这样
    nowheretoseek
        4
    nowheretoseek  
    OP
       353 天前
    @Yzh361 另一台刷了 19.07.6 ,一直用着很稳定。我试过把有问题的这台也刷成 19.07.6 ,并恢复那台的 overlay 备份,也是不行,不过也可能是我什么疏忽给搞错了
    br2049
        5
    br2049  
       353 天前
    去 op 论坛问问吧 带上日志
    nowheretoseek
        6
    nowheretoseek  
    OP
       353 天前
    @br2049 好的,我会发发试试

    提供点额外信息,就是出问题时,系统不会监听 53 和 67 端口,为了确认不是系统问题,我新装了 samba ,发现 137-139 以及 445 端口都会被监听,另外安装 dnsmasq-full 也不解决问题。但进程列表中 dnsmasq 是在的。

    ```
    root@OpenWrt:~# ps | grep dnsmasq
    2644 root 2664 S {dnsmasq} /sbin/ujail -t 5 -n dnsmasq -u -l -r /bin/ubus -r /etc/TZ -r /etc/dnsmasq.conf -r /etc/dnsmasq.d -r /etc/ethers -r /etc/group -r /etc/hosts -r /etc/passwd
    2650 root 15996 R /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.cfg01411c.pid
    ```
    nowheretoseek
        7
    nowheretoseek  
    OP
       353 天前
    @nowheretoseek @br2049 @Yzh361 排查发现问题症结了,是 conf-dir 中引入的一个配置文件导致的,[accelerated-domains.china.conf]( https://github.com/felixonmars/dnsmasq-china-list/blob/master/accelerated-domains.china.conf),删除它重启 dnsmasq 就一切正常,恢复它重启 dnsmasq 后 53 端口和 67 端口服务就不监听。

    此文件在 19.07.6 版本 openwrt+2.80 版本 dnsmasq 也有使用,并无问题,出问题的环境是 22.03.3 版本的 openwrt+2.86 版本的 dnsmasq ,具体原因需要进一步排查。
    nowheretoseek
        8
    nowheretoseek  
    OP
       353 天前
    查询发现是因为此配置文件引入大量的 server 规则( 6w+条),dnsmasq 2.86 更新似乎引入了 bug ,导致处理这种情况无力,cpu 高占用,一直遍历完规则才会在 53 端口和 67 端口开启服务,解决办法是放弃这个规则文件或更换 dnsmasq 版本。

    ```
    Mem: 99612K used, 410224K free, 11516K shrd, 0K buff, 41192K cached
    CPU: 24% usr 0% sys 0% nic 74% idle 0% io 0% irq 0% sirq
    Load average: 1.78 1.40 1.42 3/115 9331

    PID PPID USER STAT VSZ %VSZ %CPU COMMAND
    9287 9285 root R 6456 1% 24% /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.cfg01411c.pid
    ```
    flynaj
        9
    flynaj  
       353 天前 via Android
    你的配置文件是从哪个版本升级来的,建议全部重新配置,不要覆盖。
    nowheretoseek
        10
    nowheretoseek  
    OP
       353 天前
    @flynaj 是重新配置的,问题已解决,跟自定义配置无关,跟外部引入的规则文件以及 dnsmasq 的 bug 有关,在 8 楼说明了。
    huaxie1988
        11
    huaxie1988  
       346 天前 via Android
    用 sdk backport trunk 的 dnsmasq 修改配置文件手动编译个 2.89 的
    nowheretoseek
        12
    nowheretoseek  
    OP
       345 天前
    @huaxie1988 谢谢指教,以后尝试下。搜到了一个别人编译的适用 7621 的包: https://www.right.com.cn/forum/thread-8273761-1-1.html
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1492 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 23:56 · PVG 07:56 · LAX 16:56 · JFK 19:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.