DEV Community

thirdblood
thirdblood

Posted on

17

openwrt运行sing-box

在前文中启动好了openwrt虚拟机,接下来我们继续配置sing-box,实现旁路由科学上网功能。

打开虚拟机设置窗口,修改网络的连接方式,从网络地址转换(NAT)改成桥接网卡,而后点击确定
修改虚拟机网络连接方式

现在我们更改openwrt虚拟机的lan端IP,以便通过自己的主机浏览器访问到openwrt虚拟机的后台管理页面。我们先到自己的路由器后台,看一下局域网中可用的IP,选一个,记下来。

在openwrt虚拟机中执行



# 备份network文件,以免后期恢复
cp /etc/config/network /etc/config/network.bak
# 修改lan端的IP地址
vi /etc/config/network
# 重新加载网络
service network restart


Enter fullscreen mode Exit fullscreen mode

修改/etc/config/network

现在我们就可以在本机的浏览器打开我们openwrt管理后台了

openwrt管理后台

因为我们还没有为root设置密码,这里直接点击Log in就可以登录进去。登录后,先关闭br-lan接口的dhcp功能。鼠标移到上面的Network,点击弹出菜单中的Interfaces

Openwrt管理页面

在打开的页面中,点击Edit
Openwrt br-lan

在弹出的页面,点击上面选项卡中的DHCP Server

Openwrt br-lan interface

在这个General Setup选项卡中,勾上Ignore interface,点击Save

Openwrt br-lan DHCP setup

这里回到Interfaces页面,再打开Network选项卡中的Firewall,将InputForward的规则都改成accept

Openwrt br-lan interface
Openwrt firewall

点击下面的Save & Apply
Openwrt firewall

回到虚拟机的终端,我们现在安装sing-box(根据需要提前设置mirrors)



opkg update
opkg install sing-box


Enter fullscreen mode Exit fullscreen mode

Install Sing-box

接下来我们运行sing-box



# 将singbox_config_url替换为机场提供的singbox订阅链接
wget singbox_config_url -O /etc/sing-box/config.json
sing-box run -c /etc/sing-box/config.json


Enter fullscreen mode Exit fullscreen mode

好了,路由上的工作已经结束,在需要使用旁路由的设备上,将网关指向openwrt虚拟机,应该就可以科学上网了

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more