惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Forbes - Security
Forbes - Security
WordPress大学
WordPress大学
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
Spread Privacy
Spread Privacy
D
Darknet – Hacking Tools, Hacker News & Cyber Security
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
P
Privacy International News Feed
A
About on SuperTechFans
T
Tailwind CSS Blog
I
InfoQ
S
Securelist
云风的 BLOG
云风的 BLOG
罗磊的独立博客
Recent Announcements
Recent Announcements
T
The Exploit Database - CXSecurity.com
B
Blog RSS Feed
V
Visual Studio Blog
Know Your Adversary
Know Your Adversary
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
腾讯CDC
Cyberwarzone
Cyberwarzone
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
博客园 - 【当耐特】
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Full Disclosure
S
Secure Thoughts
博客园 - 司徒正美
J
Java Code Geeks
Y
Y Combinator Blog
Google Online Security Blog
Google Online Security Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
Help Net Security
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Project Zero
Project Zero
T
Tenable Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tor Project blog
MyScale Blog
MyScale Blog
Scott Helme
Scott Helme
小众软件
小众软件
K
Kaspersky official blog

Allen Hua 的网络博客

由于 Linux 桌面没有一个好用的天气程序就写了一个跨平台的CheckitoutWeather 给 caesium-image-compressor 图片压缩程序构建了 Linux AppImage v2.8.5 最新版 debian13(debian trixie)安装了nvidia闭源驱动后从x11切换到wayland的方法 山间摩旅追风,偶遇一场绚烂晚霞 最近使用debian系统的一些心得 机械革命无界14Pro笔记本debian forky成功驱动内置扬声器和麦克风 记录 typecho 1.2.0 升级到 1.3.0 过程 开发了一款openwrt插件:文本剪贴板 解决机械革命笔记本内屏高刷240Hz闪屏问题 使用 Java 写了一个局域网端口扫描器 - Allen Hua 的网络博客 openwrt使用外置根extroot机制扩展根分区大小 - Allen Hua 的网络博客 将机场ss节点批量转换成ss字符串链接批量添加到passwall - Allen Hua 的网络博客 给机械革命钛钽plus换屏:NY2换成NZ2 - Allen Hua 的网络博客 记录一次pve宿主机和上面的debian虚机无故down机事件 - Allen Hua 的网络博客 给图床部署cdn腾讯云的edgeone并排查Cache-Control max-age 3600的问题 - Allen Hua 的网络博客 从高山草甸到徽派古村:武功山反穿与皖浙赣自驾行记 - Allen Hua 的网络博客 增程器就是充电宝?别被忽悠了 - Allen Hua 的网络博客 浦口龙虎巷扫街,记录人间真实 博客图片压缩方案更新|AVIF|WebP|MozJPEG|标准JPEG Windows 电脑使用 Obs Studio 录制各个网站视频/桌面画面教程 为typecho博客添加latex支持 新能源汽车之纯电车使用交流慢充和直流快充的充电损耗对比 2025年3月更新全国5A景区名录 2025最新查看小米/红米手机电池健康度和循环次数方法 完美解决 seafile FILE_SERVER_ROOT 配置导致的内网外网不能同时访问和上传下载的问题 纯css实现typecho博客文章文字spoiler剧透效果 我对Typecho Facile主题的一些修改,图片懒加载优化,样式定制 2024年8月我的宜昌 - 重庆 - 川西小环线自驾旅行分享 2022年打卡南京市区人防工程纳凉点 2024年带着A7C2+腾龙28-200 再次来到红山森林动物园 入手a7c2第一个变焦镜头腾龙28-200体验分享 使用 exiftool 方便快捷写入图片的 exif metadata 使用JavaScript抓取易车销量排行榜数据到一个页面上展示 使用JavaScript脚本快速获取B站观看历史记录页面的视频标题和URL 入门三脚架推荐|云腾VCT-668配合索尼A7C2+FE 35mm F1.8 第一次夜景出片 Windows 11 Docker Desktop 更换默认C盘存储路径,释放C盘空间 雨游钟山——雨天带着索尼A7C2去钟山拍照 带上A7C2第一次扫街,分享今天拍的一些片子 再次为尼,买了人生第二台相机——索尼A7C2和FE 35mm F1.8 定焦镜头 更新 link-cleaner v1.1.0 适配linux桌面环境 使用自定义JavaScript脚本功能禁止memos最新版默认打开的链接预览功能 debian 11升级 docker ce 版本和 docker-compose 版本 机械革命无界14 Pro 安装 debian testing/trixie/sid 驱动扬声器,外部耳机,外接显示器过程分享 不借助 mirror 仓库,为docker engine daemon添加 proxy 访问 docker hub,解决国内公开的docker mirror 仓库不再可用了的问题 徒步江苏镇江句容九连尖 macOS 安装 proxychains-ng 并借助局域网 socks5 代理使用 Google Earth Pro 修复一块 18 年 12 月买的二手 4TB 机械硬盘 iCloud 在 Windows 下很流氓,用 taskkill 干掉它 2023 年 12 月 Spotify 彻底被墙,我在比亚迪车机上安装 surfboard 挂代理听歌 利用 proxychains 让 Windows10/11 上的 Google Earth Pro 通过代理正常访问 湖州安吉天荒坪盘山公路和杭州临安浙西天路之旅 Redmi K70 首发开箱和拍照体验 Review Android 13+ 通过 Shizuku + Language Selector 给特定应用设置独立语言 我的 2023 Spotify Wrapped 听歌总结 压缩剪贴板内图片并立即写入剪贴板,减轻服务器存储压力 【Allen Hua 翻唱】山阴路的夏天和一个人的北京 初涉录音设备,记录我购买声卡和麦克风的曲折经历以及第一首翻唱陶喆——流沙 soul power 版本(low quality) 特种兵旅行之马鞍山一日游 给我的 .com 域名续期以及转移域名(GoDaddy 到 Cloudflare) 看《下辈子我再好好过》第三季 使用油猴脚本干掉B站web首页的浏览器插件警告信息 闯进我平静生活的三只猫 在远离中短视频几天之后 [可能是]最好的压缩图片程序,使用 squoosh-cli 批量压缩图片 再次出发,自驾徽州天路和黄山之行 nginx设置referer配置个人图床的防盗链功能 微博注销记 第一次4+2旅行,骑行皖南川藏线 让 rime 输入法用上颜文字 使用 nginx 获取自己的公网 IP 地址 2023 年 618 买了一台机械革命笔记本,但很不愉快 聊聊我晚睡的习惯和早点洗澡悟出来的原因 配置 ShadowsocksR Plus+ 的服务端,在外访问家中服务 部署一个 memos 作为个人微博站点和备忘录 我的听歌软件 Spotify 和网易云的故事 | 导出网易云的歌单再导入到 Spotify 我问 ChatGPT 为何印度人痔疮发病率低 使用 immich 来管理家庭照片 | 升级 immich 1.52.0 添加 typesense 容器 在 OpenWrt 上搭建 nfs server 利用 cron 和 curl 自动模拟登录馒头,防止账号被 ban 更新 Mattermost 服务端版本,由 7.4.0 更新到 7.8.0 获取 Seafile 分享的文件直链 你是科技产品偏执狂吗?一张不同种类互联网用户日常使用产品的分级图片 记录我的 V2EX 账号被封 不通过插件给 Typecho 博客添加图片灯箱功能(fancybox js 实现) 为 Typecho 博客添加 favicon.ico(网页标签小图标) OpenWrt 修改登录页面默认展示的 root 用户名信息,保护隐私 米家智能插座 3 上手初体验 互联网上为了保护隐私我们能做些什么?分享我的想法和我写的 link-cleaner tplink 10280, wan 无法访问 lan 下的 dhcp 主机,换上 padavan 解决两台路由器 lan-wan 级联,两台路由器下面的电脑互访 机械革命自带键盘总是自动乱按,拆机拔掉排线,完美解决烦恼 做了一个 squoosh docker 镜像,写博客贴图直接在本地压缩文件,安全且高效 nginx 常规端口和非常规端口的 http redirect to https 记一次 OpenWrt luci 显示正在“收集数据”,使用公网 IP nginx 反向代理遇到的 Uncaught TypeError: Cannot read properties of null (reading 'wan') 问题 OpenWrt 安装并配置腾讯云动态 dns dnspod tencent ddns 浅谈文件传输/共享协议|内网共享文件协议选择|自建公网文件管理同步和共享方案推荐 解决 webdav 连接 seafile 无法重命名文件等操作造成的 SeafDAV: MOVE returns 502 Bad Gateway 错误 Linux 删除当前目录下的隐藏文件 OpenWrt 安装 4.4.2 版本的 qbittorrent-nox Docker 构建多架构镜像实战 构建 amd64 和 arm64 架构的兰空图床镜像 构建 arm64 架构和 amd64 架构的兰空图床 docker 镜像
openwrt dnsmasq dns 配置,运行机制初探
Allen Hua · 2021-05-30 · via Allen Hua 的网络博客

warning: 这篇文章距离上次修改已过1818天,其中的内容可能已经有所变动。

首先指路一下官方的文档,dnsmasq (简体中文) 这是一份简体中文文档,阅读十分友好。

本文有一定内容基于以前这篇文章: 使用 DNSmasq 部署家庭网络的公共 dns 和个性化的局域网内的 dns 域名服务

然后抛出我今天遇到的问题。

iOS 微博官方客户端,我在升级到最新版(微博 11.5.3)之后使用家里的联通宽带收发消息都极其缓慢,一条消息需要转圈30多秒才能发送出去。iOS的推送机制不影响,拿运行在ipad上的小号测试,推送立刻过来了,但是点进微博客户端需要加载很长时间最新消息才会出现。当我切换到联通4G网络时这个现象就消失了,收发消息都非常快。

我使用ipad测试,由于ipad安装的微博客户端还是很久以前的一个版本,私信都还没有引用功能(就是针对性回复),我拿ipad给iphone发消息,倒是秒发,接收消息也很快。初步怀疑是dns问题。但是经过最后的排查,还是很难将问题产生的原因归因于dns。iPhone尝试了重启、忘记当前wifi重新连接、重置/还原网络设置重新连接,均没有解决使用联通宽带发微博私信消息极其慢的问题。

这个问题目前还是没有解决,后续在iPhone上抓包看看。

2021-05-30 15:15:16 update

上面这个问题,刚刚换了一个 114 dns 好了 ?️

需要重启 dnsmasq 和 network:

/etc/init.d/dnsmasq restart

/etc/init.d/network restart

换成微博国际版之后发现压根没有推送,于是安装回微博官方版,并且将nameserver的第一个设置成 114.114.114.114

后面惊奇的发现好了!

前几天使用联通宽带打开qq和tim(手机连接联通宽带 wifi),总是转圈,消息要过很久才会出现的问题也修复好了!!!(换成联通4G网络也是立马加载)

终于好了,舒服了


前排提示,dnsmasq开启dns日志方式:在/etc/dnsmasq.conf 配置文件中增加下面三行重启就好了。

log-dhcp
log-queries
log-facility=/tmp/dnsmasq.log

本文讨论一下 openwrt 上 dnsmasq 配置问题。dnsmasq 运行时配置文件是 /var/etc/dnsmasq.conf.cfg01411c

文件中 conf-file=/etc/dnsmasq.conf 指定了使用额外的配置文件: /etc/dnsmasq.conf

而这个额外配置文件中 resolv-file=/etc/resolv.dnsmasq.conf 又指定了很多 nameserver 来作为本地局域网的 dns 服务器,但是查看 /tmp/dnsmasq.log 为什么看到的日志是 reading /tmp/resolv.conf.auto 呢

由于 dnsmasq 运行时配置文件是基于 /etc/config/dhcp 生成的,观察其中配置项 resolvfile 发现默认是 /tmp/resolv.conf.auto

内容是

# Interface lan
nameserver 223.5.5.5
nameserver 8.8.8.8
nameserver 10.10.10.1
nameserver 1.1.1.1
# Interface wan
nameserver 58.240.57.33
nameserver 221.6.4.66

但是这不是我们想要的结果。更改这个配置项的内容,将解析文件指向 /etc/resolv.dnsmasq.conf 重启查看日志

config dnsmasq
    option resolvfile '/etc/resolv.dnsmasq.conf'

这个在luci页面中也可以更改,位置如下图
20210530134446.png

然后使用 /etc/init.d/dnsmasq restart 重启 dnsmasq 服务,再次查看日志 /tmp/dnsmasq.log,重启会记录 exiting on receipt of SIGTERM 语句

May 30 13:11:13 dnsmasq[9354]: reading /etc/resolv.dnsmasq.conf
May 30 13:11:13 dnsmasq[9354]: using local addresses only for domain test
May 30 13:11:13 dnsmasq[9354]: using local addresses only for domain onion
May 30 13:11:13 dnsmasq[9354]: using local addresses only for domain localhost
May 30 13:11:13 dnsmasq[9354]: using local addresses only for domain local
May 30 13:11:13 dnsmasq[9354]: using local addresses only for domain invalid
May 30 13:11:13 dnsmasq[9354]: using local addresses only for domain bind
May 30 13:11:13 dnsmasq[9354]: using local addresses only for domain lan
May 30 13:11:13 dnsmasq[9354]: using nameserver 180.76.76.76#53
May 30 13:11:13 dnsmasq[9354]: using nameserver 1.1.1.1#53
May 30 13:11:13 dnsmasq[9354]: using nameserver 223.5.5.5#53
May 30 13:11:13 dnsmasq[9354]: using nameserver 8.8.8.8#53
May 30 13:11:13 dnsmasq[9354]: using nameserver 119.29.29.29#53
May 30 13:11:13 dnsmasq[9354]: using nameserver 223.6.6.6#53
May 30 13:11:13 dnsmasq[9354]: using nameserver 8.8.4.4#53

ok 成功了,成功读取我们指定的解析文件 /etc/resolv.dnsmasq.conf ,但是为什么 /etc/dnsmasq.conf 这个文件中定义的 resolv-file 没有生效呢……

看 dhcp 配置文件 (/etc/config/dhcp) 中的解析文件的选项名是 resolvfile/etc/dnsmasq.conf 中是 resolv-file 会不会是前者多了个减号?

于是删掉了减号重启,发现并不行~~~ 于是又改回来 哈哈哈

测试一下配置文件语法(删掉减号之后测试)

# dnsmasq --test

dnsmasq: bad option at line 1 of /etc/dnsmasq.conf

果然第一行的格式不对(少了个减号是不对的),再看看本文一开始推荐的官方文档,解析文件的键的确是需要减号的,又改了回来再次测试…… 这次语法没问题了

# dnsmasq --test
dnsmasq: syntax check OK.

再次观察日志,reading /etc/resolv.dnsmasq.conf 成功了,生效了!再看看 /etc/config/dhcp 中指定的解析文件 option resolvfile '/tmp/resolv.conf.auto 嗯,事先改回成这个文件,没错,要的就是这个效果。因为 resolv-file=/etc/resolv.dnsmasq.conf 指定的配置将会覆盖 /etc/config/dhcp 中指定的解析文件地址。

下面是一次dns请求 dnsmasq 的日志,多次查询在一定时间间隔内还会存在缓存,加速局域网内网络访问。

May 30 10:24:50 dnsmasq[10989]: query[AAAA] hellodk.com from 127.0.0.1
May 30 10:24:50 dnsmasq[10989]: config hellodk.com is NODATA-IPv6
May 30 10:24:50 dnsmasq[10989]: query[A] hellodk.com from 127.0.0.1
May 30 10:24:50 dnsmasq[10989]: cached hellodk.com is 91.206.93.38
May 30 10:24:52 dnsmasq[10989]: query[A] on.springsunday.net from 127.0.0.1
May 30 10:24:52 dnsmasq[10989]: forwarded on.springsunday.net to 58.240.57.33
May 30 10:24:52 dnsmasq[10989]: query[AAAA] on.springsunday.net from 127.0.0.1
May 30 10:24:52 dnsmasq[10989]: config on.springsunday.net is NODATA-IPv6
May 30 10:24:52 dnsmasq[10989]: reply on.springsunday.net is 139.162.171.72
May 30 10:24:52 dnsmasq[10989]: reply on.springsunday.net is 192.155.86.107
May 30 10:24:52 dnsmasq[10989]: query[AAAA] hellodk.com from 10.10.10.3
May 30 10:24:52 dnsmasq[10989]: config hellodk.com is NODATA-IPv6
May 30 10:24:52 dnsmasq[10989]: query[A] hellodk.com from 10.10.10.3
May 30 10:24:52 dnsmasq[10989]: cached hellodk.com is 91.206.93.38
May 30 10:24:52 dnsmasq[10989]: query[A] tracker.m-team.cc from 127.0.0.1
May 30 10:24:52 dnsmasq[10989]: forwarded tracker.m-team.cc to 58.240.57.33
May 30 10:24:52 dnsmasq[10989]: query[AAAA] tracker.m-team.cc from 127.0.0.1
May 30 10:24:52 dnsmasq[10989]: config tracker.m-team.cc is NODATA-IPv6
May 30 10:24:52 dnsmasq[10989]: reply tracker.m-team.cc is 104.26.12.50
May 30 10:24:52 dnsmasq[10989]: reply tracker.m-team.cc is 104.26.13.50
May 30 10:24:52 dnsmasq[10989]: reply tracker.m-team.cc is 172.67.73.8

所以你说这问题出在哪呢,为什么之前配置是没有问题的但是没有“激活” resolv-file 中定义的解析文件呢,不太清楚,但更改了下这块配置,后面重启就好了。真是神奇。

目前定义的公共dns如下

# cat /etc/resolv.dnsmasq.conf 
nameserver 114.114.114.114
nameserver 180.76.76.76
nameserver 1.1.1.1
nameserver 223.5.5.5
nameserver 8.8.8.8
nameserver 119.29.29.29
nameserver 223.6.6.6
nameserver 8.8.4.4

目前完整版的 dnsmasq 额外配置文件如下

resolv-file=/etc/resolv.dnsmasq.conf 
strict-order
listen-address=127.0.0.1,10.10.10.1,172.10.10.1,192.168.20.1
addn-hosts=/etc/dnsmasq.hosts
#log-dhcp
#log-queries
#log-facility=/tmp/dnsmasq.log

日志记录看情况开启。

目前完整的 /etc/config/dhcp 文件如下

config dnsmasq
    option domainneeded '1'
    option localise_queries '1'
    option rebind_protection '1'
    option rebind_localhost '1'
    option local '/lan/'
    option domain 'lan'
    option expandhosts '1'
    option authoritative '1'
    option readethers '1'
    option leasefile '/tmp/dhcp.leases'
    option nonwildcard '1'
    option localservice '1'
    option filter_aaaa '1'
    option port '53'
    list server '127.0.0.1#53'
    option resolvfile '/tmp/resolv.conf.auto'

config dhcp 'lan'
    option interface 'lan'
    option start '100'
    option limit '150'
    option leasetime '12h'
    option ra_slaac '1'
    list ra_flags 'managed-config'
    list ra_flags 'other-config'

config dhcp 'wan'
    option interface 'wan'
    option ignore '1'

config odhcpd 'odhcpd'
    option maindhcp '0'
    option leasefile '/tmp/hosts/odhcpd'
    option leasetrigger '/usr/sbin/odhcpd-update'
    option loglevel '4'

config srvhost
    option srv '_vlmcs._tcp'
    option target 'dkRouter'
    option port '1688'
    option class '0'
    option weight '100'

config host
    option name 't400'
    option dns '1'
    option mac '00:1c:25:a2:54:c6'
    option ip '10.10.10.3'
    option leasetime 'infinite'

其中 config dnsmasq 部分是 dnsmasq 主配置。

参考

end.