OpenWrt配置sing

您所在的位置:网站首页 湖人历代阵容介绍视频完整版 OpenWrt配置sing

OpenWrt配置sing

2024-07-03 13:03| 来源: 网络整理| 查看: 265

OpenWrt配置sing-box透明代理 #

Sing-Box是一个是一个免费的开源代理平台,它是Clash的完美替代品,可以在 Windows、macOS、Linux、Android和iOS 等平台上使用。除了支持Shadowsocks、Trojan、Vless、Socks协议外,还支持ShadowTLSv3、Hysteria2、Tuic和NaiveProxy等新协议。

安装 sing-box #

OpenWrt 版本 23.05.2

更新包列表:

opkg update

接下来安装工作所需的单机内核模块和与 iptables 的兼容包:

opkg install kmod-inet-diag kmod-netlink-diag kmod-tun iptables-nft luci-i18n-base-zh-cn

等待安装完成,该软件包占用了大约1MB的内存。

接下来进入安装 sing-box

opkg install sing-box

该软件包大约需要 10MB,因此如果没有额外的操作,它无法安装在 16MB ROM 的设备上。如果软件包安装成功,我们将继续配置连接。

设置sing-box 服务启动 #

配置文件自行准备 配置文件的路径为 /etc/sing-box/config.json

接下来检查配置性能:

sing-box check -c /etc/sing-box/config.json

配置正确不会返回任何错误

接下手动运行一下,看是否有报错:

sing-box run -c /etc/sing-box/config.json

手动启动没有问题,可以为sing-box创建一个启动服务。 创建文件/etc/init.d/sing-box如下:

#!/bin/sh /etc/rc.common # # Copyright (C) 2022 by nekohasekai # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # START=99 USE_PROCD=1 ##### ONLY CHANGE THIS BLOCK ###### PROG=/usr/bin/sing-box RES_DIR=/etc/sing-box/ # resource dir / working dir / the dir where you store ip/domain lists CONF=./config.json # where is the config file, it can be a relative path to $RES_DIR ##### ONLY CHANGE THIS BLOCK ###### start_service() { sleep 10 procd_open_instance procd_set_param command $PROG run -D $RES_DIR -c $CONF procd_set_param user root procd_set_param limits core="unlimited" procd_set_param limits nofile="1000000 1000000" procd_set_param stdout 1 procd_set_param stderr 1 procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}" procd_close_instance iptables -I FORWARD -o tun+ -j ACCEPT echo "sing-box is started!" } stop_service() { service_stop $PROG iptables -D FORWARD -o tun+ -j ACCEPT echo "sing-box is stopped!" } reload_service() { stop sleep 5s echo "sing-box is restarted!" start }

在/etc/config/firewall中添加规则

config zone #添加防火墙规则 option name 'proxy' option forward 'REJECT' option output 'ACCEPT' option input 'ACCEPT' option mtu_fix '1' option device 'tun0' list network 'proxy' config forwarding option name 'lan-proxy' option dest 'proxy' option src 'lan' config interface 'proxy' #添加网络接口 option proto 'none' option device 'tun0'

如果一切正常,可以启动服务:

/etc/init.d/sing-box enable /etc/init.d/sing-box start


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3