Files
dpl/content/hn/tutorials/router.html
T

101 lines
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<div class="hn-first-use">
<style>
/* Shared source, embedded in each HN article because the document renderer filters external stylesheets. */
.doc-body .hn-first-use {
--guide-accent:var(--theme-color,#a3cc4b);
--guide-muted:var(--text-muted,#a5adb5);
--guide-border:var(--border-color,#394047);
display:flex; flex-direction:column; align-items:stretch; gap:14px;
max-width:900px; margin:0 auto; color:var(--text-color);
font-size:16px; font-weight:400; line-height:1.75;
letter-spacing:normal; word-spacing:normal;
}
.doc-body .hn-first-use > * { flex:none; margin:0; }
.doc-body .hn-first-use p:empty { display:none; }
.doc-body .hn-first-use p { margin:0; line-height:inherit; letter-spacing:normal; }
.doc-body .hn-first-use .intro { font-size:17px; }
.doc-body .hn-first-use .before { color:var(--guide-muted); font-size:14px; }
.doc-body .hn-first-use h2 { margin:18px 0 0; padding:0; border:0; font-size:23px; line-height:1.45; font-weight:600; }
.doc-body .hn-first-use h2:first-of-type { margin-top:10px; }
.doc-body .hn-first-use h3 { margin:0; padding:0; border:0; font-size:15px; line-height:1.6; font-weight:600; }
.doc-body .hn-first-use strong { font-weight:600; }
.doc-body .hn-first-use ol { display:flex; flex-direction:column; gap:6px; margin:0; padding:0 0 0 24px; }
.doc-body .hn-first-use ol > li { position:static; margin:0; padding:0 0 0 3px; line-height:1.75; list-style:decimal; }
.doc-body .hn-first-use figure { width:100%; margin:0; }
.doc-body .hn-first-use figure img { display:block; width:100%; height:auto; margin:0; padding:0; border:1px solid var(--guide-border); border-radius:7px; box-shadow:none; }
.doc-body .hn-first-use figcaption { margin:8px 0 0; font-size:13px; line-height:1.6; color:var(--guide-muted); }
.doc-body .hn-first-use .compact { max-width:760px; }
.doc-body .hn-first-use .download { display:inline-flex; align-items:center; align-self:flex-start; min-height:42px; padding:8px 17px; margin:0; border-radius:6px; background:rgba(var(--theme-color-rgb,163,204,75),.12); border:1px solid rgba(var(--theme-color-rgb,163,204,75),.24); color:var(--guide-accent); text-decoration:none; font-size:15px; line-height:1.6; font-weight:500; cursor:pointer; }
.doc-body .hn-first-use .download:hover { background:rgba(var(--theme-color-rgb,163,204,75),.2); }
.doc-body .hn-first-use .downloads { display:flex; flex-wrap:wrap; gap:8px; margin:0; }
.doc-body .hn-first-use .small { color:var(--guide-muted); font-size:13px; line-height:1.7; }
.doc-body .hn-first-use .alternative { display:block; min-height:40px; margin:0; padding:0 0 0 14px; border-left:2px solid var(--guide-border); font-size:14px; line-height:1.8; }
.doc-body .hn-first-use .alternative > summary { display:block; min-height:40px; margin:0; padding:7px 0; line-height:26px; list-style:none; cursor:pointer; font-size:14px; font-weight:500; color:var(--guide-muted); transition:color .15s ease; }
.doc-body .hn-first-use .alternative > summary::-webkit-details-marker { display:none; }
.doc-body .hn-first-use .alternative > summary::before { content:""; display:inline-block; width:6px; height:6px; margin:0 12px 2px 1px; border-right:1.5px solid currentColor; border-bottom:1.5px solid currentColor; transform:rotate(-45deg); transition:transform .15s ease; }
.doc-body .hn-first-use .alternative[open] > summary::before { transform:rotate(45deg); }
.doc-body .hn-first-use .alternative > summary:hover { color:var(--guide-accent); }
.doc-body .hn-first-use .alternative > :not(summary) { margin:12px 0 0; }
.doc-body .hn-first-use .alternative:not([open]) > :not(summary) { display:none; }
.doc-body .hn-first-use .alternative[open] { padding-bottom:4px; }
.doc-body .hn-first-use .alternative figure { max-width:760px; }
.doc-body .hn-first-use .result { font-size:14px; color:var(--guide-muted); }
.doc-body .hn-first-use .result strong { color:var(--text-color); }
.doc-body .hn-first-use .troubleshooting { display:flex; flex-direction:column; gap:18px; margin-top:14px; padding-top:24px; border-top:1px solid var(--guide-border); }
.doc-body .hn-first-use .troubleshooting h2 { margin:0; font-size:20px; }
.doc-body .hn-first-use .qa { display:flex; flex-direction:column; gap:6px; margin:0; }
.doc-body .hn-first-use .qa p { margin:0; color:var(--guide-muted); font-size:14px; line-height:1.75; }
.doc-body .hn-first-use .back { display:inline-block; align-self:flex-start; padding:6px 0; margin:0; font-size:14px; }
.doc-body .hn-first-use a:focus-visible, .doc-body .hn-first-use summary:focus-visible { outline:2px solid var(--guide-accent); outline-offset:4px; border-radius:3px; }
.doc-body .hn-first-use code { font-size:.9em; overflow-wrap:anywhere; }
.doc-body .hn-first-use pre { margin:0; padding:12px 16px; background:rgba(127,127,127,.08); border:1px solid var(--guide-border); border-radius:6px; overflow:auto; line-height:1.7; }
.doc-body .hn-first-use table { width:100%; border-collapse:collapse; font-size:14px; }
.doc-body .hn-first-use th,.doc-body .hn-first-use td { padding:10px 12px; text-align:left; border-bottom:1px solid var(--guide-border); }
@media(max-width:600px) {
.doc-body .hn-first-use { font-size:15px; gap:12px; }
.doc-body .hn-first-use .intro { font-size:16px; }
.doc-body .hn-first-use h2 { font-size:21px; margin-top:16px; }
.doc-body .hn-first-use h2:first-of-type { margin-top:8px; }
}
</style>
<p class="intro">本教程介绍如何在已能正常上网的 OpenWrt 路由器上配置 <strong>OpenClash</strong>,供连接该路由器的设备使用。</p>
<p class="before">需要路由器后台管理权限,以及支持 OpenClash 的 OpenWrt 固件。开始前,请确认套餐未到期、流量未用完。本文不包含刷机和旁路由网络搭建。</p>
<h2>1. 准备路由器和 OpenClash</h2>
<p>电脑连接路由器网络,登录路由器管理后台,先到<strong>系统 → 备份 / 升级</strong>将当前配置备份到电脑。若 OpenClash 和内核均已安装,可从第 2 步开始。</p>
<a class="download" href="/#/docs/2">查看 OpenClash 安装入口</a><p>在「所有客户端」中找到 <strong>OpenClash</strong>,进入版本选择页。使用 opkg 的固件选 <strong>.ipk</strong>,使用 apk 的固件选 <strong>.apk</strong>;这里的 APK 是 OpenWrt 软件包,不是安卓安装包。</p>
<ol><li>在路由器的<strong>系统 → 软件包</strong>中更新列表,再上传并安装匹配固件的安装包;有内置插件商店时,也可以使用它的 OpenClash 安装入口。</li><li>刷新页面,打开<strong>服务 → OpenClash</strong>,在<strong>版本更新</strong>中下载与路由器架构匹配的 <strong>Meta(Mihomo)内核</strong>。菜单名称可能随固件版本略有不同。</li></ol>
<figure class="compact"><img src="/brand/hn/tutorials/router/install.svg" width="760" height="398" loading="lazy" alt="操作示意:先备份,再安装插件和内核。菜单位置随固件版本而异。"><figcaption>操作示意:先备份,再安装插件和内核。菜单位置随固件版本而异。</figcaption></figure>
<details class="alternative"><summary>安装时提示缺少依赖</summary><p>使用固件的软件包管理器安装缺失的依赖。插件与内核模块需要匹配固件和防火墙版本;具体依赖可在「所有客户端」的 OpenClash 入口查看安装说明。不要强制忽略依赖或覆盖系统库。</p>
</details>
<h2>2. 添加 hardnerd 订阅</h2>
<p>回到 hardnerd <strong>仪表盘 → 导入订阅</strong>,点击<strong>复制订阅地址</strong>。</p>
<p>进入路由器的<strong>服务 → OpenClash → 配置订阅</strong>,添加订阅:</p>
<ol><li>配置名称填写 <strong>hardnerd</strong>,订阅地址粘贴刚才复制的完整地址。</li><li>User-Agent(下载订阅时使用的客户端标识)选择以 <strong>clash.meta</strong> 开头的选项;关闭<strong>在线订阅转换</strong>。</li><li>保存并启用这条订阅,再点击<strong>更新配置</strong>。更新成功后,应能在「配置管理」中看到对应配置文件。</li></ol>
<figure class="compact"><img src="/brand/hn/tutorials/router/subscribe.svg" width="760" height="412" loading="lazy" alt="填写示意:粘贴完整地址,保存后更新配置。"><figcaption>填写示意:粘贴完整地址,保存后更新配置。</figcaption></figure>
<p class="small">请妥善保管订阅地址,不要公开或转发。</p>
<h2>3. 启用配置并选择线路</h2>
<ol><li>在<strong>配置管理</strong>找到刚下载的配置,点击<strong>切换</strong>。</li><li>回到<strong>运行状态</strong>启用 OpenClash,等待插件和内核运行。</li><li>打开 OpenClash 的<strong>控制面板 → 代理</strong>,选择<strong>规则</strong>模式,再选择可用线路或自动选择组。</li></ol>
<figure class="compact"><img src="/brand/hn/tutorials/router/start.svg" width="760" height="351" loading="lazy" alt="操作示意:切换配置 → 启动插件 → 选择线路。"><figcaption>操作示意:切换配置 → 启动插件 → 选择线路。</figcaption></figure>
<h2>4. 检查设备能否正常访问</h2>
<p>若这台路由器是当前上网使用的<strong>主路由</strong>,让手机连接它的 Wi-Fi,或让电脑通过网线连接它的 LAN 口,保持原有的自动获取 IP 和 DNS 设置。</p>
<figure class="compact"><img src="/brand/hn/tutorials/router/network.svg" width="760" height="374" loading="lazy" alt="连接示意:流量必须经过运行 OpenClash 的路由器。"><figcaption>连接示意:流量必须经过运行 OpenClash 的路由器。</figcaption></figure>
<p>先关闭测试设备上其他 VPN 或代理客户端,再用浏览器访问需要通过代理打开的网站。若启用 OpenClash 后无法上网,先停用插件,确认原有网络恢复。</p>
<details class="alternative"><summary>已使用旁路由的网络</summary><p>旁路由需要事先配置好上游网关、转发及设备接入方式。仅连接同一个 Wi-Fi,并不代表流量会经过旁路由。</p>
<p>请先确认测试设备原本就通过这台旁路由上网,再启用 OpenClash 测试。不要仅按示意图直接修改全网的网关或 DNS;尚未配置旁路由时,可先使用手机或电脑客户端。</p>
<p><a href="/#/docs/1">查看手机和电脑教程</a></p>
</details>
<section class="troubleshooting"><h2>遇到问题</h2>
<div class="qa"><h3>后台没有 OpenClash 菜单</h3>
<p>刷新或重新登录后台,检查软件包与依赖是否安装成功。</p>
</div><div class="qa"><h3>内核不存在或无法启动</h3>
<p>到版本更新中确认内核已下载且架构匹配,再查看运行日志中的具体错误。</p>
</div><div class="qa"><h3>订阅更新失败</h3>
<p>确认套餐有效、路由器自身能联网,并重新复制完整订阅地址。核对 User-Agent 为 clash.meta 类型、在线订阅转换已关闭后,再更新配置。</p>
</div><div class="qa"><h3>插件运行了,设备却打不开网页</h3>
<p>先停用 OpenClash,检查原有网络是否恢复。原网络正常时,再核对配置是否已切换、线路是否可用,以及测试设备是否通过这台路由器上网。</p>
</div><div class="qa"><h3>仍然无法使用</h3>
<p>通过「仪表盘 → 工单支持」提交工单,提供路由器型号、固件和 OpenClash 版本、主路由或旁路由用法及报错截图。请遮住截图中的订阅地址。</p>
</div></section>
<a class="back" href="/#/docs/1">← 返回新手指引</a>
</div>