- 在Linux环境中使用Shell脚本一键部署和管理Clash服务
- 项目地址:https://github.com/juewuy/ShellClash
新版本的Redmi AX6000固件 无需刷固件;例如我这里固件版本为:1.0.64
- 登入路由器后台,然后在搜索地址栏复制stok码
- 注意:
stok
码再每次重新登入路由都会改变,所以以下的步骤都需要是最新的stok码的情况下进行操作
- 注意:将下面红色标记的对应的stok改为自己上面获取到的路由器对应的stok码
http://192.168.31.1/cgi-bin/luci/;stok=对应的stok/api/misystem/set_sys_time?timezone=%20%27%20%3B%20zz%3D%24%28dd%20if%3D%2Fdev%2Fzero%20bs%3D1%20count%3D2%202%3E%2Fdev%2Fnull%29%20%3B%20printf%20%27%A5%5A%25c%25c%27%20%24zz%20%24zz%20%7C%20mtd%20write%20-%20crash%20%3B%20
http://192.168.31.1/cgi-bin/luci/;stok=对应的stok/api/misystem/set_sys_time?timezone=%20%27%20%3b%20reboot%20%3b%20
- 等待路由器重启完成,大概2分钟左右时间
- 注意: 上面重启了路由器之后重新连接无线之后,访问路由器后台需要重新登入,这个时候我们需要获取最新的stok码
http://192.168.31.1/cgi-bin/luci/;stok=对应的stok/api/misystem/set_sys_time?timezone=%20%27%20%3B%20bdata%20set%20telnet_en%3D1%20%3B%20bdata%20set%20ssh_en%3D1%20%3B%20bdata%20set%20uart_en%3D1%20%3B%20bdata%20commit%20%3B%20
http://192.168.31.1/cgi-bin/luci/;stok=对应的stok/api/misystem/set_sys_time?timezone=%20%27%20%3b%20reboot%20%3b%20
- 连接到对应的无线WiFi,然后主机输入192.168.31.1,协议选择TELNET 端口默认23
- 提示: 我这里使用的xshell工具
- 连上telnet后运行下列命令
echo -e 'admin\nadmin' | passwd root
- root密码修改为admin
- 固化SSH之后,以后升级路由器固件SSH也会保留不会被恢复
nvram set ssh_en=1
nvram set telnet_en=1
nvram set uart_en=1
nvram set boot_wait=on
nvram commit
- 重启不会关闭
mkdir /data/auto_ssh && cd /data/auto_ssh
curl -O https://cdn.jsdelivr.net/gh/lemoeo/AX6S@main/auto_ssh.sh
chmod +x auto_ssh.sh
uci set firewall.auto_ssh=include
uci set firewall.auto_ssh.type='script'
uci set firewall.auto_ssh.path='/data/auto_ssh/auto_ssh.sh'
uci set firewall.auto_ssh.enabled='1'
uci commit firewall
cd
uci set system.@system[0].timezone='CST-8'
uci set system.@system[0].webtimezone='CST-8'
uci set system.@system[0].timezoneindex='2.84'
uci commit
mtd erase crash
reboot
- 路由器重启之后,确保PC连接成功,然后再使用xshell工具并选择ssh协议连接路由器
- 提示: 这里的root密码就是上面修改的密码 admin
- 上面步骤一解锁了路由SSH连接之后,现在我们就需要配置路由器科学上网了;
- 注意: 需提前准备科学上面的订阅地址或者连接地址
- 主要是检查设备是否安装了iptables以及加载了对应的模块,不然你部署的时候只能使用环境变量在配置clash代理了!
# iptables 模式
command -v iptables
lsmod | grep '^xt_owner'
# nftables 模式
command -v nft
(2) 如果 lsmod | grep '^xt_owner'
为空,说明在内核中没有加载 xt_owner
模块,这可能导致 iptables 的某些功能不可用。首先,确保 iptables 软件包已正确安装。
sudo apt-get update
sudo apt-get install iptables
# 加载 xt_owner 模块: 手动加载 xt_owner 模块,可以使用 modprobe 命令:
sudo modprobe xt_owner
# 再次检查 xt_owner 是否加载
lsmod | grep '^xt_owner'
说明:如果 xt_owner 模块不可用,可能是因为系统内核没有相应的模块。在某些系统中,该模块可能已经被包含在内核中,而在其他系统中,你可能需要重新编译内核或安装额外的内核模块。
sudo apt-get update
sudo apt-get install nftables
#GitHub源(可能需要代理)
export url='https://raw.githubusercontent.com/juewuy/ShellCrash/master' && sh -c "$(curl -kfsSl $url/install.sh)" && source /etc/profile &> /dev/null
或者
#jsDelivrCDN源
export url='https://fastly.jsdelivr.net/gh/juewuy/ShellCrash@master' && sh -c "$(curl -kfsSl $url/install.sh)" && source /etc/profile &> /dev/null
或者
#作者私人源
export url='https://gh.jwsc.eu.org/master' && sh -c "$(curl -kfsSl $url/install.sh)" && source /etc/profile &> /dev/null
#GitHub源(可能需要代理)
export url='https://raw.githubusercontent.com/juewuy/ShellCrash/master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh && sh /tmp/install.sh && source /etc/profile &> /dev/null
或者
#jsDelivrCDN源
export url='https://fastly.jsdelivr.net/gh/juewuy/ShellCrash@master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh && sh /tmp/install.sh && source /etc/profile &> /dev/null
- 通过XShell连接到路由器,执行上面的命令进行安装
export url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master' && sh -c "$(curl -kfsSl $url/install.sh)" && source /etc/profile &> /dev/null
- 浏览器访问地址为:http://192.168.31.1:9999/ui/
- 现在访问Google和YouTube测试
cd /data/clash/yamls/
# 添加自定义规则
vi rules.yaml
如 chatgpt(注意前面有空格)
- DOMAIN-SUFFIX,openai.com,🚀 节点选择
- DOMAIN-SUFFIX,chatgpt.com,🚀 节点选择
- DOMAIN-SUFFIX,statsig.com,🚀 节点选择
- DOMAIN-SUFFIX,ingest.com,🚀 节点选择
- DOMAIN-SUFFIX,revenuecat.com,🚀 节点选择
以上就是所有的操作步骤