sing-box direct端口转发教程
因前不久在论坛抽奖中了个Alice Free V6鸡,此鸡需要中转并搭配其提供的5个socks家宽出口。同时ns论坛上已有很我类似的教程教大家怎样去搭建,唯独好像还没有sing-box的教程,此文正好对ns上所发的内版教程贴做一个备份。
一、Alice Free V6 操作
1. 安装sing-box
- 直接使用官方一键脚本:(已Debian为例)
bash <(curl -fsSL https://sing-box.app/deb-install.sh)
注:因V6鸡没有V4出口,可以先改dns64后再执行安装脚本,修改dns64命令如下:
echo -e "nameserver 2a00:1098:2b::1\nnameserver 2a01:4f9:c010:3f02::1\nnameserver 2a01:4f8:c2c:123f::1\nnameserver 2a00:1098:2c::1" > /etc/resolv.conf
- 修改服务端配置(默认配置路径:/etc/sing-box/config.json)
在配置文件中,outbounds增加alice的5个socks出口,inbounds对应复制5个ss协议作为入站,修改tag和端口。
{
"log": {
"disabled": false,
"level": "info",
"output": "/var/log/sing-box.log",
"timestamp": true
},
"route": {
"rules": [
{
"inbound": [
"ss-in1"
],
"outbound": "socks1"
},
{
"inbound": [
"ss-in2"
],
"outbound": "socks2"
},
{
"inbound": [
"ss-in3"
],
"outbound": "socks3"
},
{
"inbound": [
"ss-in4"
],
"outbound": "socks4"
},
{
"inbound": [
"ss-in5"
],
"outbound": "socks5"
}
]
},
"inbounds": [
{
"type": "shadowsocks",
"tag": "ss-in1",
"listen": "::",
"listen_port": 50001,
"method": "2022-blake3-aes-128-gcm",
"password": "H3vCBgE6nSUlHQcV0D8qYA=="
},
{
"type": "shadowsocks",
"tag": "ss-in2",
"listen": "::",
"listen_port": 50002,
"method": "2022-blake3-aes-128-gcm",
"password": "H3vCBgE6nSUlHQcV0D8qYA=="
},
{
"type": "shadowsocks",
"tag": "ss-in3",
"listen": "::",
"listen_port": 50003,
"method": "2022-blake3-aes-128-gcm",
"password": "H3vCBgE6nSUlHQcV0D8qYA=="
},
{
"type": "shadowsocks",
"tag": "ss-in4",
"listen": "::",
"listen_port": 50004,
"method": "2022-blake3-aes-128-gcm",
"password": "H3vCBgE6nSUlHQcV0D8qYA=="
},
{
"type": "shadowsocks",
"tag": "ss-in5",
"listen": "::",
"listen_port": 50005,
"method": "2022-blake3-aes-128-gcm",
"password": "H3vCBgE6nSUlHQcV0D8qYA=="
}
],
"outbounds": [
{
"type": "socks",
"tag": "socks1",
"server": "2a14:67c0:116::1",
"server_port": 30000,
"version": "5",
"username": "alice",
"password": "alicefofo123..OVO"
},
{
"type": "socks",
"tag": "socks2",
"server": "2a14:67c0:116::1",
"server_port": 20000,
"version": "5",
"username": "alice",
"password": "alicefofo123..OVO"
},
{
"type": "socks",
"tag": "socks3",
"server": "2a14:67c0:116::1",
"server_port": 40000,
"version": "5",
"username": "alice",
"password": "alicefofo123..OVO"
},
{
"type": "socks",
"tag": "socks4",
"server": "2a14:67c0:116::1",
"server_port": 50000,
"version": "5",
"username": "alice",
"password": "alicefofo123..OVO"
},
{
"type": "socks",
"tag": "socks5",
"server": "2a14:67c0:116::1",
"server_port": 10001,
"version": "5",
"username": "alice",
"password": "alicefofo123..OVO"
}
]
}
2. 启动 sing-box
systemctl start sing-box
二、中转机操作
此处也以大家常用的白嫖双栈机gcphk为例
1. 安装sing-box
内容同上,只是无需修改dns64。
- 修改服务端配置
在中转机配置文件中,使用direct端口转发功能,同样在inbounds复制5个direct协议对端口进行转发,注意修改tag和端口。
{
"log": {
"disabled": false,
"level": "info",
"output": "/var/log/sing-box.log",
"timestamp": true
},
"route": {
"rules": [
{
"inbound": [
"direct-in1"
],
"outbound": "direct"
},
{
"inbound": [
"direct-in2"
],
"outbound": "direct"
},
{
"inbound": [
"direct-in3"
],
"outbound": "direct"
},
{
"inbound": [
"direct-in4"
],
"outbound": "direct"
},
{
"inbound": [
"direct-in5"
],
"outbound": "direct"
}
]
},
"inbounds": [
{
"type": "direct",
"tag": "direct-in1",
"listen": "::",
"listen_port": 60001,
"override_address": "此处填Alice V6鸡的ip或域名",
"override_port": 50001
},
{
"type": "direct",
"tag": "direct-in2",
"listen": "::",
"listen_port": 60002,
"override_address": "此处填Alice V6鸡的ip或域名",
"override_port": 50002
},
{
"type": "direct",
"tag": "direct-in3",
"listen": "::",
"listen_port": 60003,
"override_address": "此处填Alice V6鸡的ip或域名",
"override_port": 50003
},
{
"type": "direct",
"tag": "direct-in4",
"listen": "::",
"listen_port": 60004,
"override_address": "此处填Alice V6鸡的ip或域名",
"override_port": 50004
},
{
"type": "direct",
"tag": "direct-in5",
"listen": "::",
"listen_port": 60005,
"override_address": "此处填Alice V6鸡的ip或域名",
"override_port": 50005
}
],
"outbounds": [
{
"type": "direct",
"tag": "direct"
}
]
}
2. 启动 sing-box
systemctl start sing-box
三、客户端操作
客户端种类太多,根据自己喜欢选择,在此还是以sing-box为例,仅对节点部分示意:
最终得到的中转节点,是在落地Alice鸡上设置的ss协议,将ip和端口改为中转鸡的即可。
{
"type": "shadowsocks",
"tag": "gcphk-aliceTW",
"server": "此处填gcp中转鸡的ip或域名",
"server_port": 60001,
"method": "2022-blake3-aes-128-gcm",
"password": "H3vCBgE6nSUlHQcV0D8qYA=="
},
{
"type": "shadowsocks",
"tag": "gcphk-aliceHK",
"server": "此处填gcp中转鸡的ip或域名",
"server_port": 60002,
"method": "2022-blake3-aes-128-gcm",
"password": "H3vCBgE6nSUlHQcV0D8qYA=="
},
{
"type": "shadowsocks",
"tag": "gcphk-aliceVN",
"server": "此处填gcp中转鸡的ip或域名",
"server_port": 60003,
"method": "2022-blake3-aes-128-gcm",
"password": "H3vCBgE6nSUlHQcV0D8qYA=="
},
{
"type": "shadowsocks",
"tag": "gcphk-aliceJP",
"server": "此处填gcp中转鸡的ip或域名",
"server_port": 60004,
"method": "2022-blake3-aes-128-gcm",
"password": "H3vCBgE6nSUlHQcV0D8qYA=="
},
{
"type": "shadowsocks",
"tag": "gcphk-aliceSG",
"server": "此处填gcp中转鸡的ip或域名",
"server_port": 60005,
"method": "2022-blake3-aes-128-gcm",
"password": "H3vCBgE6nSUlHQcV0D8qYA=="
}
完~~~ have fun!!!