Skip to content

Mini-Router v0.5.0

Latest

Choose a tag to compare

@Cd1s Cd1s released this 31 Oct 06:15
· 3 commits to main since this release
1c5a027

Mini-Router

新内容 / What's new(v0.4.1 → v0.5.0)

内置 NAT46 与受管 DNS64 / Built-in NAT46 and managed DNS64 (#169, #172)

  • 新选项 proxy.nat46(默认关闭):内置的 SOCKS5 NAT46 转换器 mr-nat46,只监听回环,支持 TCP CONNECT 和 UDP ASSOCIATE。proxy.extra_config 里"每端口一个源 IPv6"的 SOCKS 出站访问 IPv4 字面量(如 https://124.222.230.137/)时,由它按源地址(后缀或完整 IPv6 用户名)转成 NAT64 地址;源表热加载,不安全的目标地址会被拒绝。sing-box 1.14 不会为 IPv4 字面量合成 NAT64 地址,这一项用来替掉外部手工的 nat46-socks。
  • proxy.nat46.dns64(默认关闭):独立的 unbound 实例(默认 127.0.0.1:1153,服务 mr-dns64),不碰系统的 unbound,proxy.extra_config 里原有的 dns64 接线可以原样保留。需要 /usr/sbin/unbound;固件镜像只带 unbound-libs,要用的话先 apk add unbound(缺少时校验会提示)。
  • DNS64 的上游始终跟随 WAN 的 DNS(#172),与 LAN 的 dns.upstream 模式无关(manual / DoT / ISP 都一样):当前 WAN resolver 文件 → WAN 租约里的 DNS → dns.fallback → dns.servers,忽略回环和未指定地址。NAT46 的默认值只在使用时补上、不写进配置,所以老配置升级后不会出现 config.unapplied。
  • New proxy.nat46 (off by default): a built-in loopback-only SOCKS5 NAT46 converter (TCP CONNECT, UDP ASSOCIATE) that maps IPv4 literals to NAT64 addresses per source IPv6 (suffix or full address), with hot-reloaded source tables; it replaces the hand-run nat46-socks. proxy.nat46.dns64 (off by default) runs a private unbound instance and leaves the system unbound alone; it needs /usr/sbin/unbound (the firmware image only ships unbound-libs: apk add unbound). DNS64 upstreams always follow the WAN DNS regardless of the LAN dns.upstream mode; NAT46 defaults are applied at use time and never written into the config.

运营商 DNS 屏蔽绕过 / ISP DNS unblock (#171, #173)

  • 新选项 dns.unblock(默认关闭):sing-box 1.14+ 的 helper mr-dns-unblock(127.0.0.2:53)检查运营商(或手动指定)DNS 的应答;遇到屏蔽页地址、私网黑洞、A / AAAA / HTTPS 空应答时,改用 Cloudflare、Google、Quad9 或自定义的可信解析器重试,正常应答保持运营商的结果。dnsmasq 读 /run/mini-router/resolv-lan.conf:helper 健康时指向 helper,不健康时回落到运营商解析器。mr-mon 约每 5 秒探测一次、连续两次结果一致才切换,helper 停止、挂死或重启后约 10 秒恢复,不需要重启 dnsmasq。
  • 需要 sing-box ≥ 1.14.0:固件镜像自带;Alpine 官方仓库目前仍是 1.13.x,需要自己装 1.14+ 到 /usr/bin/sing-box。版本不够时校验和服务启动检查会明确报错,不会让旧版本接管 DNS。
  • 新命令 mr dns unblock detect [--json] [域名 …](#173):只读检测。把当前每个运营商解析器同可信解析器和 1.1.1.1:53 对比,找出重复出现的屏蔽页地址、私网黑洞、空应答以及 UDP/53 劫持,给出延迟和建议。面板 DNS 页有「检测」按钮和「按检测结果填表」,只填表单,应用仍走 plan / apply / confirm;API 为 dns.unblock.detect(token 作用域 operate)。
  • New dns.unblock (off by default): a supervised sing-box 1.14+ helper retries block-page / private-sinkhole / empty answers through a trusted resolver and falls back to the ISP resolvers automatically when it is unhealthy (recovery in about 10 s, dnsmasq is not restarted). mr dns unblock detect is a read-only diagnosis (block-page addresses, sinkholes, empty answers, UDP/53 interception) with a panel button that only fills the form.

PPPoE:公网地址保护 / require_public_ip (#175)

  • wan[].require_public_ip 不再放弃:前四次按 require_public_ip_gap(默认 180 秒)间隔重拨,之后间隔翻倍、上限 15 分钟(配置的间隔大于 15 分钟则保持),直到拿到公网地址或关闭该选项。只重拨拿到私网地址的那条线,已有公网地址的线不会被碰;状态记在 /run/mini-router/require-public-ip.json(重启后重新计,拿到公网地址后清除)。原来的"重拨已停止"风险状态没有了。
  • 拿到私网 / CGNAT 地址(RFC1918、100.64/10、169.254/16)的 require_public_ip PPPoE 线会被摘出路由,按 down 处理(不需要开 multiwan):它的 WAN 表去掉默认路由、main 表 metric 抬高,负载均衡和 DNS 排序跳过它。policy_routes 里 fallback: main(默认)的规则立即回落到主路由(ppp-up 钩子马上处理,每分钟一次的 mr wan public-check --cron 兜底,最坏一分钟),拿到公网地址后自动回到原 WAN;fallback: drop 不变,仍然断开。
  • mr doctor 和 WAN 页:原来的 RISK 变成 WARN,例如 has 100.64.x.y (cgnat); waiting for the ISP to release a session slot (…): redial 5 done, next in 6 min;快速重拨阶段结束时记一条警告事件。
  • wan[].require_public_ip now redials forever with backoff (180 s × 4, then doubling up to 15 min) instead of giving up; only the line holding a private/CGNAT address is redialed. While it holds one, that line is treated as down: its default route is removed, balance and DNS ordering skip it, and policy_routes with fallback: main use the main route until a public address arrives (fallback: drop is unchanged). mr doctor shows a WARN with the redial countdown instead of the old "stopped" RISK.

PPPoE:停止时必发 PADT / PPPoE always sends its PADT (#177)

  • 停止 PPPoE 服务(包括 reboot)时,pppd 以 lcp-max-terminate 1 启动:收到 SIGTERM 后发一次 LCP Terminate-Request,运营商一应答就发 PADT,不应答则 3 秒后(lcp-restart)发出;mr-pppoe 加上 retry="SIGTERM/10",supervise-daemon 会等 pppd 退出,不再 5 秒后就宣布服务已停。运营商应答慢或不应答时,以前重启会丢掉 PADT,运营商继续把旧会话算进并发上限。
  • Stopping PPPoE (including a reboot) now always gets the PADT out: one LCP Terminate-Request, PADT as soon as the ISP answers or after 3 s, and the service waits for pppd instead of giving up after 5 s.

dnsmasq 只监听 LAN 网桥和回环 / dnsmasq listen scope (#179)

  • 主 dnsmasq、mr-proxy-dns、mr-parental-dns 现在只监听 LAN 网桥、127.0.0.1 和 ::1(渲染出 except-interface=lo、bind-dynamic、listen-address=127.0.0.1、listen-address=::1),不再监听 lo 上的每一个地址。原因:附加组件在 lo 上挂了几百个 /128 源地址时,三个实例都会撞到 1024 个文件描述符的上限,DNS 全断。DHCP、RDNSS、dns.redirect、代理 / 家长控制的 nft 重定向、/etc/resolv.conf(127.0.0.1)都不变。
  • The main dnsmasq, mr-proxy-dns and mr-parental-dns now listen on the LAN bridges plus 127.0.0.1 / ::1 only, not on every address of lo (hundreds of /128 on lo could exhaust the 1024-descriptor limit and take DNS down). Nothing else changes.

文档 / Docs (#180)

  • 说明 LAN 下游路由器 / 虚拟化网段如何用标准 NDP / RA 中继(odhcpd relay 模式)共享上游委派的单个 /64、拿到公网 IPv6,以及路由器端需要和不需要做什么;注意点:被中继的流量都带中继的 MAC(按 MAC 的功能会把它们当成一台设备)、非 PD 线路上的 nat6 策略会对被中继的主机做 NPT、下游网桥上其它路由器接受 RA 时需要 RA guard。无代码改动。
  • How hosts behind a downstream NDP/RA relay share the delegated /64 (net.md); docs only.

升级说明 / Upgrade notes

  • 新功能默认全部关闭:proxy.nat46、proxy.nat46.dns64、dns.unblock 不打开时不会多出任何服务、文件或进程;require_public_ip 没打开的线路行为不变。
    All new features are off by default: with them off there are no new services, files or processes.

  • mr plan 会有一处差异(不是空):dnsmasq 的监听行。升级后 mr plan 只会显示 /etc/dnsmasq.conf 多了 except-interface=lo 和 listen-address=::1(listen-address=127.0.0.1 已存在则不重复);开了代理 DNS / 家长控制的配置,还会看到 gen/proxy-dns.conf、gen/parental-dns.conf 同样的改动。其余生成文件与 v0.4.1 逐字节相同。mr apply 时 dnsmasq(以及这两个 DNS 服务)会重启一次,LAN 的 DNS 会短暂中断;建议在可以接受的时间 mr apply --confirm 120。
    mr plan is not empty after the upgrade: it shows the new dnsmasq listen lines (and the same lines in proxy-dns.conf / parental-dns.conf when those are enabled). Applying restarts dnsmasq once, so LAN DNS blips briefly; every other generated file is byte-identical to v0.4.1.

  • require_public_ip 的 mr doctor 文案变了:原来的 RISK automatic public-IP redial stopped after repeated private addresses 不再出现;拿到私网 / CGNAT 地址时现在是 WARN waiting for the ISP to release a session slot … redial N done, next in M min,并且那条线会被摘出路由。如果你的监控或脚本在匹配旧的文案或 RISK 等级,请改一下。
    The mr doctor wording for require_public_ip changed (RISK "stopped" → WARN "waiting for the ISP …, next in M min"); adjust any monitoring that matches the old text. A line holding a private address is now also held out of routing.

  • 固件镜像的软件包:基础包是更新的 Alpine 3.24.3 快照(v0.4.1 是 3.24.2:curl 8.23、musl 1.2.6-r3 等),内核、sing-box、tailscaled、dstatus-agent 不变。
    The firmware image is rebuilt on a newer Alpine 3.24.3 package snapshot; kernel, sing-box, tailscaled and dstatus-agent are unchanged.

  • Redmi AX6000:

    /usr/libexec/mr/sysupgrade -T --sha256 <SHA256SUMS 里的值> /tmp/mini-router-ax6000-v0.5.0-sysupgrade.tar
    setsid /usr/libexec/mr/sysupgrade -y --sha256 <同上> /tmp/mini-router-ax6000-v0.5.0-sysupgrade.tar > /tmp/su.log 2>&1 &

    约 2 分钟后回来,设置保留。Back in about 2 minutes with settings kept.

  • Alpine:把 mr-linux-<架构> 装成 /usr/sbin/mr、mini-router-rootfs.tar.gz 解到 /(不要重跑整个 install.sh),然后 mr plan、mr apply --confirm 120;见 docs/install-alpine.md。
    Alpine: replace /usr/sbin/mr, unpack the rootfs tarball over / (do not re-run the installer), then mr plan and mr apply --confirm 120.

安装 / Install

  • 任意架构的 Alpine Linux(x86_64 / arm64 / armv7 / armv6 / x86 / riscv64 / ppc64le):
    wget -O install.sh https://github.com/Cd1s/mini-router/releases/download/v0.5.0/install.sh && MR_VERSION=v0.5.0 sh install.sh
    (预发布期间要写 MR_VERSION=v0.5.0,否则 install.sh 下载的是 latest 那一版 / while this is a pre-release, MR_VERSION=v0.5.0 is required)。
    见 docs/install-alpine.md。
  • Redmi AX6000(hanwckf 110M U-Boot 布局):mini-router-ax6000-v0.5.0-sysupgrade.tar(刷机 / 升级)、-initramfs.cpio.xz、-kexec.tar.gz(从 OpenWrt 里先在内存试运行:Image、dtb、devmem、kexec-test.sh、initramfs)。见 docs/flash.md。镜像带 tailscaled 和 dstatus-agent(同 v0.4.0)。

文件 / Assets

SHA256SUMS 列出每个文件的校验值。