{"id":1150,"date":"2026-09-04T20:07:38","date_gmt":"2026-09-04T12:07:38","guid":{"rendered":"http:\/\/www.tantan.ink\/index.php\/2026\/09\/04\/openwrt-24-mini-mwan-dual-wan\/"},"modified":"2026-09-04T20:07:39","modified_gmt":"2026-09-04T12:07:39","slug":"openwrt-24-mini-mwan-dual-wan","status":"publish","type":"post","link":"https:\/\/www.tantan.ink\/index.php\/2026\/09\/04\/openwrt-24-mini-mwan-dual-wan\/","title":{"rendered":"OpenWrt 24 \u4e4b\u540e\uff0c\u53cc WAN \u8fd8\u80fd\u9760 500 \u884c Lua \u6491\u7740"},"content":{"rendered":"<p>\u5bb6\u91cc\u4e00\u76f4\u6302\u7740\u8054\u901a\u548c\u79fb\u52a8\u4e24\u6761\u5bbd\u5e26\uff0c\u4e3b\u8def\u7531\u505a\u53cc WAN \u8d1f\u8f7d\u5747\u8861\uff0c\u65c1\u8def\u7531\u8dd1 OpenWrt 24.10 \u7ba1\u4ee3\u7406\u5206\u6d41\u3002\u524d\u9635\u5b50\u60f3\u7ed9\u65c1\u8def\u7531\u4e5f\u52a0\u4e00\u6761\u5907\u4efd\u94fe\u8def\uff0c\u7ed3\u679c\u53d1\u73b0 mwan3 \u5728 OpenWrt 24 \u4e0a\u76f4\u63a5\u6d88\u5931\u4e86\u3002<\/p>\n<p>\u67e5\u4e86\u4e00\u5708\uff0c\u4e0d\u662f\u56e0\u4e3a\u6ca1\u4eba\u7ef4\u62a4\uff0c\u800c\u662f fw4 \u5207\u5230 nftables \u4e4b\u540e\uff0cmwan3 \u90a3\u5957 iptables \u89c4\u5219\u94fe\u6839\u672c\u8dd1\u4e0d\u8d77\u6765\u3002\u793e\u533a\u6709\u4eba\u505a\u4e86 nftables \u79fb\u690d\uff0c\u4f46\u8981\u7b49\u7a33\u5b9a\u7248\u8fdb feed\uff0c\u65f6\u95f4\u8bf4\u4e0d\u51c6\u3002<\/p>\n<p>\u8fd9\u65f6\u5019\u770b\u5230 mini-mwan\uff0c\u7b2c\u4e00\u611f\u89c9\u662f\uff1a\u8fd9\u4e5f\u592a\u8f7b\u4e86\u3002<\/p>\n<p><strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.tantan.ink\/wp-content\/uploads\/2026\/09\/00-github.png\" alt=\"\" \/><\/p>\n<p><\/strong><\/p>\n<h3>500 \u884c Lua \u4ee3\u66ff\u4e00\u4e07\u884c shell<\/h3>\n<p>mini-mwan \u662f\u4e2a\u7eaf Lua \u5199\u7684\u5b88\u62a4\u8fdb\u7a0b\uff0c\u4ee3\u7801\u91cf\u5927\u6982 500 \u884c\uff0c\u5bf9\u6bd4 mwan3 \u7684\u4e00\u4e07\u884c\u4ee5\u4e0a\uff0c\u6587\u4ef6\u5927\u5c0f\u5dee\u4e86\u5c06\u8fd1\u4e24\u4e2a\u6570\u91cf\u7ea7\u3002\u4f5c\u8005 Alex Schwartzman \u7684\u5b9a\u4f4d\u5f88\u660e\u786e\uff1aOpenWrt 24+ \u4e0a\u9700\u8981\u4e00\u4e2a<strong>\u80fd\u8dd1\u8d77\u6765\u7684<\/strong>\u57fa\u7840\u591a WAN \u5de5\u5177\uff0c\u4e0d\u6c42\u529f\u80fd\u6700\u5168\uff0c\u4f46\u6c42\u4e0d\u6298\u817e\u3002<\/p>\n<p>\u5b83\u7684\u6838\u5fc3\u601d\u8def\u8ddf mwan3 \u5b8c\u5168\u4e0d\u540c\u3002mwan3 \u9760 iptables\/nftables \u6253\u6807\u8bb0\u3001\u5efa\u89c4\u5219\u94fe\u3001\u914d ipset\uff0c\u6545\u969c\u6392\u67e5\u65f6\u8981\u7ffb\u4e09\u5c42\u9632\u706b\u5899\u903b\u8f91\uff1bmini-mwan \u76f4\u63a5\u8d70\u6807\u51c6 Linux \u5185\u6838\u8def\u7531\u2014\u2014\u63a5\u53e3\u901a\u4e86\uff0c\u5c31\u5f80\u4e0a\u52a0\u4e00\u6761\u5e26 metric \u7684\u9ed8\u8ba4\u8def\u7531\uff1b\u63a5\u53e3\u65ad\u4e86\uff0c\u5c31\u628a\u8fd9\u6761\u8def\u7531\u64a4\u6389\u3002\u6392\u67e5\u65f6\u4e00\u4e2a <code>ip route show<\/code> \u5c31\u80fd\u770b\u660e\u767d\uff0c\u4e0d\u9700\u8981\u61c2 nftables\u3002<\/p>\n<p>\u8fd9\u79cd\u6a21\u5f0f\u7684\u597d\u5904\u662f\u9632\u706b\u5899\u65e0\u5173\u3002fw3\u3001fw4\u3001\u751a\u81f3\u4e0d\u8bbe\u9632\u706b\u5899\u90fd\u80fd\u7528\uff0c\u4e0d\u4f1a\u56e0\u4e3a\u5e95\u5c42\u9632\u706b\u5899\u540e\u7aef\u6362\u4e86\u4e00\u5957\u5c31\u6302\u6389\u3002<\/p>\n<p><strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.tantan.ink\/wp-content\/uploads\/2026\/09\/01-compare.png\" alt=\"\" \/><\/p>\n<p><\/strong><\/p>\n<h3>IPv4-first \u662f\u4e2a\u52a1\u5b9e\u9009\u62e9<\/h3>\n<p>mini-mwan \u6709\u4e2a\u8bbe\u8ba1\u6211\u633a\u8ba4\u540c\uff1a\u8def\u7531\u51b3\u7b56\u53ea\u770b IPv4 \u8fde\u901a\u6027\u3002\u5982\u679c\u67d0\u4e2a\u63a5\u53e3 IPv4 \u80fd ping \u901a\uff0c\u5b83\u624d\u7ed9\u8fd9\u6761\u63a5\u53e3\u52a0\u8def\u7531\uff1bIPv4 \u4e0d\u901a\uff0c\u54ea\u6015 IPv6 \u96a7\u9053\u8fd8\u6d3b\u7740\uff0c\u4e5f\u4e0d\u4f1a\u628a\u6d41\u91cf\u5bfc\u8fc7\u53bb\u3002<\/p>\n<p>\u8fd9\u542c\u8d77\u6765\u50cf\u662f\u529f\u80fd\u7f3a\u5931\uff0c\u5176\u5b9e\u662f\u9632\u6cc4\u6f0f\u3002\u5bb6\u7528\u73af\u5883\u91cc\u7ecf\u5e38\u6709\u8fd9\u79cd\u573a\u666f\uff1a\u65c1\u8def\u7531\u6302\u4e86\u4ee3\u7406\u96a7\u9053\uff0cIPv6 \u8d70\u7684\u662f\u4ee3\u7406\u51fa\u53e3\uff0cIPv4 \u8d70\u7684\u5374\u662f\u76f4\u8fde\u3002\u5982\u679c DNS \u540c\u65f6\u8fd4\u56de\u4e86 A \u548c AAAA \u8bb0\u5f55\uff0c\u6709\u4e9b\u7cfb\u7edf\u4f1a\u4f18\u5148 IPv6\uff0c\u7ed3\u679c\u6d41\u91cf\u4ece\u4ee3\u7406\u7ed5\u4e86\u4e00\u5708\uff0cIPv4 \u53cd\u800c\u88f8\u5954\u3002mini-mwan \u7684\u505a\u6cd5\u662ffail-closed\u2014\u2014IPv4 \u4e0d\u901a\u5c31\u90fd\u4e0d\u5bfc\uff0c\u5b81\u53ef\u65ad\u7f51\u4e5f\u4e0d\u6f0f\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u5982\u679c\u4f60\u7684\u4e3b\u94fe\u8def\u662f\u7eaf IPv6\uff0c\u8fd9\u4e2a\u5de5\u5177\u76ee\u524d\u4e0d\u652f\u6301\u3002<\/p>\n<h3>\u80fd\u505a\u4ec0\u4e48\u3001\u4e0d\u80fd\u505a\u4ec0\u4e48<\/h3>\n<p>mini-mwan \u652f\u6301\u4e24\u79cd\u6a21\u5f0f\uff1afailover \u548c multi-uplink\u3002\u6545\u969c\u8f6c\u79fb\u6309 metric \u4f18\u5148\u7ea7\u5207\uff0c\u8d1f\u8f7d\u5747\u8861\u6309 weight \u5206\u914d\u3002\u63a5\u53e3\u5065\u5eb7\u68c0\u67e5\u7528 ICMP ping\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\u76ee\u6807\u548c\u95f4\u9694\u3002<\/p>\n<p>\u5b83\u4e5f\u5e26\u4e86\u4e00\u4e2a LuCI \u754c\u9762\uff0c\u88c5\u5b8c luci-app-mini-mwan \u4e4b\u540e\u80fd\u5728 Web \u4e0a\u5f00\u5173\u63a5\u53e3\u3001\u770b\u6d41\u91cf\u7edf\u8ba1\u3002\u4e0d\u8fc7\u754c\u9762\u6bd4\u8f83\u6734\u7d20\uff0c\u57fa\u672c\u5c31\u662f\u72b6\u6001\u9875\u52a0\u914d\u7f6e\u8868\u5355\uff0c\u6ca1\u6709 mwan3 \u90a3\u79cd\u7b56\u7565\u89c4\u5219\u7f16\u8f91\u5668\u3002<\/p>\n<p>\u660e\u786e\u4e0d\u652f\u6301\u7684\u529f\u80fd\uff1a\u6309\u534f\u8bae\/\u7aef\u53e3\u5206\u6d41\u3001\u7c98\u6027\u4f1a\u8bdd\u3001\u590d\u6742\u7b56\u7565\u89c4\u5219\u3002\u5982\u679c\u4f60\u7684\u9700\u6c42\u662f&#8221;\u6e38\u620f\u8d70 WAN1\u3001\u4e0b\u8f7d\u8d70 WAN2&#8243;\uff0cmini-mwan \u505a\u4e0d\u5230\uff0c\u5f97\u7b49\u653f\u7b56\u8def\u7531\u6216\u8005 SQM\u3002<\/p>\n<p><strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.tantan.ink\/wp-content\/uploads\/2026\/09\/02-diagram.png\" alt=\"\" \/><\/p>\n<p><\/strong><\/p>\n<h3>\u5b89\u88c5\u6bd4\u60f3\u8c61\u4e2d\u7b80\u5355<\/h3>\n<p>\u4f5c\u8005\u63d0\u4f9b\u4e86\u9884\u7f16\u8bd1\u7684 .ipk\uff0cOpenWrt 24 \u7528 opkg \u88c5\uff0c25 \u4ee5\u540e\u5207\u4e86 apk \u4e5f\u80fd\u88c5\u3002\u4f9d\u8d56\u53ea\u6709\u56db\u4e2a\u5305\uff1alua\u3001libuci-lua\u3001luci-lib-nixio\u3001lua-cjson\uff0c\u6807\u51c6\u56fa\u4ef6\u4e00\u822c\u90fd\u6709\u3002<\/p>\n<p>UCI \u914d\u7f6e\u7ed3\u6784\u4e5f\u5f88\u76f4\u767d\uff1a<\/p>\n<pre><code>uci set mini-mwan.global.mode='failover'\nuci set mini-mwan.wan1.metric='100'\nuci set mini-mwan.wan2.metric='200'\nuci commit mini-mwan\n\/etc\/init.d\/mini-mwan restart<\/code><\/pre>\n<p>metric \u8d8a\u5c0f\u4f18\u5148\u7ea7\u8d8a\u9ad8\uff0c\u8ddf Linux \u8def\u7531\u8868\u91cc\u7684\u4e00\u81f4\uff0c\u4e0d\u9700\u8981\u5b66\u65b0\u6982\u5ff5\u3002<\/p>\n<h3>\u6211\u7684\u5224\u65ad<\/h3>\n<p>mini-mwan \u9002\u5408\u8c01\uff1fOpenWrt 24\/25 \u7528\u6237\uff0c\u6709\u4e24\u4e09\u6761\u5bbd\u5e26\u60f3\u505a\u6545\u969c\u8f6c\u79fb\u6216\u7b80\u5355\u8d1f\u8f7d\u5747\u8861\uff0c\u4e0d\u60f3\u7814\u7a76 nftables \u89c4\u5219\u94fe\u7684\u4eba\u3002\u6216\u8005\u65c1\u8def\u7531\u4e0a\u9700\u8981\u4e00\u6761\u5907\u4efd\u94fe\u8def\uff0c\u4e3b\u94fe\u8def\u65ad\u4e86\u81ea\u52a8\u5207\u5230\u53e6\u4e00\u6761\uff0c\u8fd9\u79cd\u573a\u666f\u5b83\u5b8c\u5168\u591f\u7528\u3002<\/p>\n<p>\u4e0d\u9002\u5408\u8c01\uff1f\u9700\u8981\u7cbe\u7ec6\u5316\u6d41\u91cf\u8c03\u5ea6\u3001\u6309\u57df\u540d\/\u534f\u8bae\u5206\u6d41\u3001\u6216\u8005\u641e SD-WAN \u90a3\u5957\u7684\u4f01\u4e1a\u7ea7\u9700\u6c42\u3002\u8fd9\u79cd\u573a\u666f\u8fd8\u662f\u7b49 mwan3 \u7684 nftables \u79fb\u690d\u7a33\u5b9a\uff0c\u6216\u8005\u4e0a OPNsense\/VyOS\u3002<\/p>\n<p>\u6211\u76ee\u524d\u7684\u53cc WAN \u8fd8\u5728\u4e3b\u8def\u7531\u4e0a\u8dd1\uff0c\u65c1\u8def\u7531\u6682\u65f6\u7528\u4e0d\u5230 mini-mwan\u3002\u4f46\u5982\u679c\u54ea\u5929\u4e3b\u8def\u7531\u7684\u8d1f\u8f7d\u5747\u8861\u62bd\u98ce\uff0c\u6211\u53ef\u80fd\u4f1a\u8003\u8651\u5728\u65c1\u8def\u7531\u4e0a\u5355\u72ec\u6302\u4e00\u6761\u5907\u7528\u51fa\u53e3\uff0c500 \u884c Lua \u7684\u7ef4\u62a4\u6210\u672c\u786e\u5b9e\u4f4e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenWrt 24+ \u4e0a mwan3 \u6d88\u5931\u540e\uff0cmini-mwan \u7528 500 \u884c Lua \u5b9e\u73b0\u4e86\u65e0\u9632\u706b\u5899\u4f9d\u8d56\u7684\u591a WAN \u6545\u969c\u8f6c\u79fb\u548c\u8d1f\u8f7d\u5747\u8861\uff0c\u6392\u67e5\u53ea\u9700 ip route show\u3002<\/p>\n","protected":false},"author":2,"featured_media":1151,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[176,163],"tags":[],"class_list":["post-1150","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hands-on","category-network"],"_links":{"self":[{"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/posts\/1150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/comments?post=1150"}],"version-history":[{"count":1,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/posts\/1150\/revisions"}],"predecessor-version":[{"id":1154,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/posts\/1150\/revisions\/1154"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/media\/1151"}],"wp:attachment":[{"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/media?parent=1150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/categories?post=1150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/tags?post=1150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}