OpenClash README

The project's README from github.com/vernesong/OpenClash. As one markdown file: README.md.

OpenClash

OpenClash

一个可运行在 OpenWrt 上的 Mihomo (Clash Meta) 客户端

License Release Downloads OpenWrt Telegram

简介

OpenClash 是一个面向 OpenWrt 的 LuCI 插件,用于管理 Mihomo(原 Clash Meta)内核,兼容 Shadowsocks、ShadowsocksR、VMess、VLESS、Trojan、Snell、TUIC、Hysteria 等主流协议,通过灵活的规则配置实现按需分流与透明代理。

功能特性

模块 说明
内核 内置 Mihomo(Meta)与 Smart 智能内核,支持在线更新与切换
运行模式 redir-host / fake-ip 与混合模式、TUN 模式,兼容 iptables 与 nftables
订阅管理 多订阅并存,支持 Subconverter 在线转换、自定义 User-Agent 与请求头
配置管理 多配置文件一键切换、在线编辑、备份/恢复、Age 加密
访问控制 黑白名单、自定义防火墙规则
流媒体 Netflix / Disney+ / HBO 等自动选线
覆写设置 模块化覆写 YAML,方便配置文件定制

目录

快速开始

网页安装

  1. 从 Release 页面 下载对应架构的安装包(*.ipk 或 *.apk);
  2. 登录 OpenWrt 的 LuCI 后台,前往 系统 → 软件包 上传并安装;
  3. 刷新或者重新登录页面,在 服务 → OpenClash 中导入订阅或上传配置文件并启动。

命令行安装

安装依赖并下载最新版(iptables 防火墙):

# opkg 系统(ipk)
opkg update
opkg install bash iptables dnsmasq-full curl ca-bundle ipset ip-full iptables-mod-tproxy iptables-mod-extra ruby ruby-yaml kmod-tun kmod-inet-diag unzip luci-compat luci luci-base
curl -L --retry 2 https://api.github.com/repos/vernesong/OpenClash/releases/latest -o /tmp/openclash_version
[ -f "/tmp/openclash_version" ] && download_url=$(cat /tmp/openclash_version | jsonfilter -e '@.assets[*].browser_download_url' | grep '\.ipk$') && curl -L --retry 2 "$download_url" -o /tmp/openclash.ipk || echo "OpenClash last version get failed"
[ -f "/tmp/openclash.ipk" ] && opkg install /tmp/openclash.ipk || echo "OpenClash download failed"

# apk 系统(apk)
apk update
apk add bash iptables dnsmasq-full curl ca-bundle ipset ip-full iptables-mod-tproxy iptables-mod-extra ruby ruby-yaml kmod-tun kmod-inet-diag unzip luci-compat luci luci-base
curl -L --retry 2 https://api.github.com/repos/vernesong/OpenClash/releases/latest -o /tmp/openclash_version
[ -f "/tmp/openclash_version" ] && download_url=$(cat /tmp/openclash_version | jsonfilter -e '@.assets[*].browser_download_url' | grep '\.apk$') && curl -L --retry 2 "$download_url" -o /tmp/openclash.apk || echo "OpenClash last version get failed"
[ -f "/tmp/openclash.apk" ] && apk add -q --force-overwrite --clean-protected --allow-untrusted /tmp/openclash.apk || echo "OpenClash download failed"

安装依赖并下载最新版(nftables 防火墙,Firewall4):

# opkg 系统(ipk)
opkg update
opkg install bash dnsmasq-full curl ca-bundle ip-full ruby ruby-yaml kmod-tun kmod-inet-diag unzip kmod-nft-tproxy luci-compat luci luci-base
curl -L --retry 2 https://api.github.com/repos/vernesong/OpenClash/releases/latest -o /tmp/openclash_version
[ -f "/tmp/openclash_version" ] && download_url=$(cat /tmp/openclash_version | jsonfilter -e '@.assets[*].browser_download_url' | grep '\.ipk$') && curl -L --retry 2 "$download_url" -o /tmp/openclash.ipk || echo "OpenClash last version get failed"
[ -f "/tmp/openclash.ipk" ] && opkg install /tmp/openclash.ipk || echo "OpenClash download failed"

# apk 系统(apk)
apk update
apk add bash dnsmasq-full curl ca-bundle ip-full ruby ruby-yaml kmod-tun kmod-inet-diag unzip kmod-nft-tproxy luci-compat luci luci-base
curl -L --retry 2 https://api.github.com/repos/vernesong/OpenClash/releases/latest -o /tmp/openclash_version
[ -f "/tmp/openclash_version" ] && download_url=$(cat /tmp/openclash_version | jsonfilter -e '@.assets[*].browser_download_url' | grep '\.apk$') && curl -L --retry 2 "$download_url" -o /tmp/openclash.apk || echo "OpenClash last version get failed"
[ -f "/tmp/openclash.apk" ] && apk add -q --force-overwrite --clean-protected --allow-untrusted /tmp/openclash.apk || echo "OpenClash download failed"

首次使用需要下载内核,请提前确认网络环境

使用手册

下载

最新版本请前往 Releases 页面,按需选择对应的安装包:

安装包 说明
luci-app-openclash_*.ipk opkg 安装包
luci-app-openclash-*.apk apk 安装包

历史版本请前往 全部 Releases 查看。

依赖

类别 依赖
基础 luci、luci-base、luci-compat(Luci ≥ 19.07)
运行时 bash、curl、ca-bundle、ruby、ruby-yaml
网络 dnsmasq-full、ipset、ip-full、unzip
防火墙(iptables) iptables、kmod-ipt-nat、iptables-mod-tproxy、iptables-mod-extra
防火墙(nftables) kmod-nft-tproxy(Firewall4)
可选 kmod-tun(TUN 模式)、ip6tables-mod-nat(IPv6)、kmod-inet-diag(PROCESS-NAME)

源码编译

从 OpenWrt 的 SDK 编译:

# 解压下载好的 SDK
curl -SLk --connect-timeout 30 --retry 2 "https://archive.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/OpenWrt-SDK-15.05.1-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2" -o "/tmp/SDK.tar.bz2"
cd /tmp
tar xjf SDK.tar.bz2
cd OpenWrt-SDK-15.05.1-*

# Clone 项目
mkdir package/luci-app-openclash
cd package/luci-app-openclash
git init
git remote add -f origin https://github.com/vernesong/OpenClash.git
git config core.sparsecheckout true
echo "luci-app-openclash" >> .git/info/sparse-checkout
git pull --depth 1 origin master
git branch --set-upstream-to=origin/master master

# 编译 po2lmo (如果有 po2lmo 可跳过)
pushd luci-app-openclash/tools/po2lmo
make && sudo make install
popd

# 编译最新 CodeMirror 6 (插件内置,可跳过)
pushd luci-app-openclash/tools/codemirror
npm install
npx esbuild entry.js --bundle --format=iife --global-name=CM6 --minify --target=es2019 --outfile=../../root/www/luci-static/resources/openclash/js/cm6.min.js --legal-comments=none --loader:.css=text
npx esbuild entry-md-render.js --bundle --format=iife --global-name=OCMarkdown --minify --target=es2019 --outfile=../../root/www/luci-static/resources/openclash/js/md-render.min.js --legal-comments=none --loader:.css=text
npx esbuild entry-lint-worker.js --bundle --format=iife --minify --target=es2019 --outfile=../../root/www/luci-static/resources/openclash/js/lint-worker.min.js --legal-comments=none
rm -rf node_modules
popd

# 开始编译

# 先回退到 SDK 主目录
cd ../..
make package/luci-app-openclash/luci-app-openclash/compile V=99

# IPK 文件位置
./bin/ar71xx/packages/base/luci-app-openclash_*-beta_all.ipk
# 同步源码
cd package/luci-app-openclash/luci-app-openclash
git pull

# 您也可以直接拷贝 `luci-app-openclash` 文件夹至其他 `OpenWrt` 项目的 `Package` 目录下随固件编译

make menuconfig
# 选择要编译的包 LuCI -> Applications -> luci-app-openclash

致谢

OpenClash 的构建离不开以下开源项目与数据服务:

类别 项目 作者 / 组织 说明
内核 Mihomo MetaCubeX 代理内核(Clash Meta)
代码基础 Luci For Clash frainzy1477 本项目代码基于此
控制面板 metacubexd MetaCubeX 默认内置面板
控制面板 zashboard Zephyruso 内置面板
控制面板 Yacd-meta MetaCubeX 内置面板,基于 yacd
控制面板 Razord-meta MetaCubeX 内置面板(Dashboard)
订阅转换 subconverter tindy2013 在线订阅转换
GEO / IP 数据 v2ray-rules-dat Loyalsoldier GeoIP / GeoSite 数据
GEO / IP 数据 meta-rules-dat MetaCubeX GeoSite 规则数据
GEO / IP 数据 mmdb_china_ip_list alecthw 中国 IP 列表 MMDB
GEO / IP 数据 china-operator-ip gaoyifan 运营商 IP 列表
规则模板 ACL4SSR ACL4SSR 订阅转换规则模板
规则模板 Custom_OpenClash_Rules Aethersailor 订阅转换规则模板
流媒体检测 RegionRestrictionCheck lmc999 流媒体解锁检测
IP 检查 ip.skk.moe SukkaW 公网 IP 检测
编辑器 CodeMirror Marijn Haverbeke 内置编辑器

请作者喝杯咖啡

Buy Me a Coffee at ko-fi.com

许可证

本项目基于 MIT License 开源。

OpenClash (vernesong/OpenClash)

Searching Database…

What is this?OpenClash is a Mihomo (Clash) client plugin for OpenWrt routers: it runs a policy-based proxy on the router, routing traffic through flexible rule configurations.
Is this a desktop app, or does it live on my router?It lives on the router — OpenClash installs on OpenWrt as an IPK/APK package and plugs into LuCI, the router's web admin interface.
How do I get it onto my router?Download the IPK or APK package from the project's download page and install it on OpenWrt; the full usage manual is in the Wiki.
What does the router need to have installed first?Quite a few OpenWrt packages: luci, dnsmasq-full, bash, curl, ipset, ip-full, ruby with ruby-yaml, unzip, plus a set of iptables/nftables kernel modules.
Any install gotchas I should know about?Yes — several features need extra modules: TUN mode requires kmod-tun, PROCESS-NAME rules need kmod-inet-diag, firewall4 devices need kmod-nft-tproxy, and Luci >= 19.07 needs luci-compat.
Will it run on any Linux box, or strictly on OpenWrt?Strictly OpenWrt — it is a LuCI plugin built from the OpenWrt SDK, so it targets OpenWrt routers rather than desktop Linux or other systems.
Which proxy protocols does it support?Shadowsocks, ShadowsocksR, VMess, Trojan and Snell, among others — the bundled Mihomo core handles the protocols while OpenClash supplies the rules and routing policy.
What proxy core does it run under the hood?Mihomo by MetaCubeX is the core engine; OpenClash itself is a LuCI plugin whose code is based on frainzy1477's Luci For Clash.
Can I watch what the proxy is doing in real time?Yes — the project uses the zashboard and yacd control panels, and also credits SukkaW's IP check and lmc999's streaming-unlock detection as companion tools.
Creator
vernesong
Size
47 GB
Stars
28.3K
Age
7y
Commits · 90 Days