sing-box+hy2绕过校园网认证

前置条件:

首先连接上你的校园网(不要登录认证),然后打开cmd,然后拿最好的测网络的工具:“百度” 进行测试是否可行。

nslookup www.baidu.com

如果返回结果类似如下,则可以利用 DNS 查询来绕过验证。

服务器:UnKnown
Address:10.1.1.1
非权威应答:
名称:www.a.shifen.com
Addresses: 180.101.49.12
180.101.49.11
Aliases: www.baidu.com

你的返回结果不一定和上图一模一样,如果你成功查询到了 www.baidu.com 的服务器 IP<span> </span>,80% 就能成功,本教程将适合你。

教程开始(以下教程在Ubuntu系统下进行):

服务端(服务器操作)

一、确保服务器已安装dockerOpenSSL
二、把自己的一个域名A记录指向服务器IP,记住这个域名
三、使用OpenSSL签发域名自签证书
  1. 创建需要的文件夹
    sudo mkdir -p /opt/docker/sing-box  /opt/docker/sing-box/cert
  2. 生成私钥:使用以下命令生成一个私钥文件
    openssl genpkey -algorithm RSA -out /opt/docker/sing-box/cert/key.pem
  3. 生成证书请求:***.example.com替换为步骤二域名**
    openssl req -new -key /opt/docker/sing-box/cert/key.pem -out /opt/docker/sing-box/cert/csr.pem -subj "/CN=*.example.com"
  4. 自签名证书
    openssl x509 -req -days 5475 -in /opt/docker/sing-box/cert/csr.pem -signkey /opt/docker/sing-box/cert/key.pem -out /opt/docker/sing-box/cert/cert.pem
四、在/opt/docker/sing-box目录下创建config.json文件,内容如下(sing-box配置文件)
注:listen_port 可以是 53, 65, 66, 67, 68 哪个可以用用哪个 优先 53,其余字段自行按照说明自改

Ubuntu系统 53 端口可能被systemd-resolved占用,解决方法如下:

### 打开 systemd-resolved 配置文件:
sudo nano /etc/systemd/resolved.conf

### 修改配置文件中的 DNSStubListener 行为:
DNSStubListener=no

### 取消DNS注释,修改如下
DNS=114.114.114.114

### 保存并关闭编辑器:按下 Ctrl + O 保存更改,然后按下 Enter,最后按下 Ctrl + X 退出编辑器。

### 最后运行下面命令即可。
sudo systemctl restart systemd-resolved
sudo cp /etc/resolv.conf /etc/resolv.conf.backup
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

config.json内容:

{
"log": {
"disabled": false,
"level": "info",
"timestamp": true
},
"inbounds": [
{
"type": "hysteria2",
"tag": "hy2-tun",
"listen": "::",
"listen_port": 53,
"up_mbps": 0,
"down_mbps": 0,
"users": [
{
"name": "tun",
"password": "自行替换 uuid就可"
}
],
"tls": {
"enabled": true,
"server_name": "自行替换 步骤二 域名",
"alpn": [
"h3"
],
"key_path": "/etc/sing-box/cert/key.pem",
"certificate_path": "/etc/sing-box/cert/cert.pem"
}
}
]
}
五、docker启动sing-box
docker run -itd \
-v /opt/docker/sing-box:/etc/sing-box/ \
--name=sing-box \
--network=host \
--restart=always \
ghcr.io/sagernet/sing-box \
-D /var/lib/sing-box \
-C /etc/sing-box/ run

到此,各处防火墙请放行用到的端口(udp),服务端操作全部完成

客户端(windows为例)

六、下载clash客户端 clash-nyanpasuclash-verge-rev,安装,连接上你的校园网(不要登录认证)
七、在软件内新建本地配置,内容见如下链接,根据实际修改,并启用
https://gist.githubusercontent.com/aurorax-neo/f5b961447048182a5051bd727b665c84/raw/44f873977f9054b5ef5ba4db7620f383acc2469f/template.yaml
## 链接内的内容如下

mode: global
allow-lan: true
log-level: info
mixed-port: 7890
external-controller: 0.0.0.0:9090
external-controller-secret: clash
dns:
ipv6: true
enabled: true
listen: 1053
use-hosts: true
default-nameserver:
- 223.5.5.5
- 223.6.6.6
nameserver:
- 114.114.114.114
fallback:
- 1.1.1.1
- 1.0.0.1
proxies:
- name: hy2-tun
type: hysteria2
server: 自行替换 步骤二 域名
port: 根据服务端实际修改
password: 根据服务端实际修改
skip-cert-verify: true
proxy-groups: [ ]
rules: [ ]
八、软件切换到代理
1.开启全局模式并选择hy2-tun节点
九、软件切换到设置
1.安装服务模式并启用
2.开启tun模式

如果不出以意外,你的电脑已经有网络了,享受吧!!!