部署sing-box代理服务器绕过付费校园网上网

解决的问题

学校一般会有2个网络,一个是教学区的免费校园网,一个是寝室楼的付费校园网.如何不交钱也能在寝室楼上网是一个问题.

以及,如果校园网在12点之后断网,如果解决断网问题

sing-box

Github 地址:https://github.com/233boy/sing-box

install

docker部署

参考sing-box官方文档关于docker部署的方式

docker镜像托管在<ghcr.io/sagernet/sing-box>,你可以在github仓库的内容中检查

shell 复制代码
docker pull ghcr.io/sagernet/sing-box

使用上述指令拉取镜像

shell 复制代码
docker run -d \
  --network host \
  -v /etc/sing-box:/etc/sing-box/ \
  --name=sing-box \
  --restart=always \
  ghcr.io/sagernet/sing-box \
  -D /var/lib/sing-box \
  -C /etc/sing-box/ run

运行容器

该指令与官方文档不同在于我使用--network host放行了网络端口

脚本安装

需要实现和v3ray一键安装的脚本一样快速安装服务,参考233Boy-最好用的 sing-box 一键安装脚本

config

程序需要配合sing-box.json配置文件使用,缺少配置文件的时候启动容器会出现报错unmarshal merged json,文件位置位于/etc/sing-box/sing-box.json

并且容器会一直重启(因为设置了--restart=always)

配置文件模板可以在官方文档-proxy protocol中获取

我自己的配置文件类似于

json 复制代码
 {
  "inbounds": [
    {
      "type": "<protocol-type>",
      "listen": "::",
      "listen_port": 2025,
      "network": "tcp",
      "method": "2022-blake3-aes-128-gcm",
      "password": "<password>",
      "multiplex": {
        "enabled": true
      }
    }
  ]
}
  • 更新配置之后需要重新启动程序

test

shell 复制代码
sudo apt install net-tools

安装必要的工具,方便展示情况

展示

shell 复制代码
netstat -pan|grep 2025

展示2025端口的使用情况

可以看到正在被监听

相关推荐
小白同学_C5 小时前
Lab4-Lab: traps && MIT6.1810操作系统工程【持续更新】 _
linux·c/c++·操作系统os
今天只学一颗糖5 小时前
1、《深入理解计算机系统》--计算机系统介绍
linux·笔记·学习·系统架构
不做无法实现的梦~7 小时前
ros2实现路径规划---nav2部分
linux·stm32·嵌入式硬件·机器人·自动驾驶
默|笙9 小时前
【Linux】fd_重定向本质
linux·运维·服务器
陈苏同学9 小时前
[已解决] Solving environment: failed with repodata from current_repodata.json (python其实已经被AutoDL装好了!)
linux·python·conda
“αβ”9 小时前
网络层协议 -- ICMP协议
linux·服务器·网络·网络协议·icmp·traceroute·ping
不爱学习的老登10 小时前
Windows客户端与Linux服务器配置ssh无密码登录
linux·服务器·windows
小王C语言11 小时前
进程状态和进程优先级
linux·运维·服务器
xlp666hub11 小时前
【字符设备驱动】:从基础到实战(下)
linux·面试
弹幕教练宇宙起源12 小时前
cmake文件介绍及用法
android·linux·c++