Update the package list to ensure you have the latest available versions.
opkg updateInstall the necessary kernel module for nftables.
opkg install kmod-nft-tproxyFor iptables (if you have OpenWrt version < 22.03.x) – iptables-mod-tproxy.
Download the SSClash package and install it.
curl -L https://github.com/zerolabnet/ssclash/releases/download/v1.8.1/luci-app-ssclash_1.8.1-1_all.ipk -o /tmp/luci-app-ssclash_1.8.1-1_all.ipk
opkg install /tmp/luci-app-ssclash_1.8.1-1_all.ipk
rm /tmp/*.ipkStop the service until you edit the configuration.
/etc/init.d/clash stopNavigate to the bin directory and download the Clash.Meta Kernel. Choose the appropriate architecture.
cd /opt/clash/binFor amd64 architecture:
curl -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.9/mihomo-linux-amd64-compatible-v1.18.9.gz -o clash.gzFor arm64 architecture:
curl -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.9/mihomo-linux-arm64-v1.18.9.gz -o clash.gzFor mipsel_24kc architecture:
curl -L https://github.com/MetaCubeX/mihomo/releases/download/v1.18.9/mihomo-linux-mipsle-softfloat-v1.18.9.gz -o clash.gzNeed a different architecture? Visit the MetaCubeX Release Page and choose the one that matches your device.
Decompress the downloaded file and make it executable.
gunzip clash.gz
chmod +x clashI've written a simple interface for managing Clash from LuCI interface luci-app-ssclash. Edit Clash config and Apply.
You can access the Dashboard at:
http://ROUTER_IP:9090/ui/
To remove Clash, delete the related files, luci-app-ssclash package and kernel module kmod-nft-tproxy or iptables-mod-tproxy.
opkg remove luci-app-ssclash kmod-nft-tproxy
rm -rf /opt/clashExtra info (optional): Automating Clash Rules Update in OpenWrt whenever the Internet interface is brought up
To automatically update the rules for Clash whenever the Internet interface is brought up in OpenWrt, follow these step:
- Open a terminal and create a new shell script named
40-clash_rulesin the/etc/hotplug.d/iface/directory:
vi /etc/hotplug.d/iface/40-clash_rules- Insert the following script content (change
api_base_urlif needed):
#!/bin/sh
# Add delay
sleep 10
# API IP address and port
api_base_url="http://192.168.1.1:9090"
# API URL
base_url="$api_base_url/providers/rules"
# Get JSON response with provider names
response=$(curl -s "$base_url")
# Extract provider names using standard utilities
providers=$(echo "$response" | grep -o '"name":"[^"]*"' | sed 's/"name":"\([^"]*\)"/\1/')
# Check if data retrieval was successful
if [ -z "$providers" ]; then
echo "Failed to retrieve providers or no providers found."
exit 1
fi
# Loop through each provider name and send PUT request to update
for provider in $providers; do
echo "Updating provider: $provider"
curl -X PUT "$base_url/$provider"
# Check success and output the result
if [ $? -eq 0 ]; then
echo "Successfully updated $provider"
else
echo "Failed to update $provider"
fi
done
# Service restart
/etc/init.d/clash reload- Save and exit the editor.
The script will now automatically run whenever the Internet interface is brought up. This ensures that the rules for Clash are updated as soon as the router is rebooted and connected to the Internet.


