免流服务的搭建和使用相关

 

介绍及客户端地址

1
2
3
4
5
6
7
8
9
# 最近0元购了联通的【联通云盘定向流量500G 0元/月】,想试试通过云端代理来让【所有流量】走【联通云盘定向流量】来免流,本文配置在新加坡VPS和家庭宽带IPv6上均测试通过

# 相关客户端的项目地址:
Linux https://github.com/v2fly/v2ray-core https://github.com/XTLS/Xray-core
OpenWRT https://github.com/kuoruan/openwrt-v2ray
Android https://github.com/2dust/v2rayNG
Windows https://github.com/2dust/v2rayN
WebUI https://github.com/MHSanaei/3x-ui

极简搭建运行环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 新手小白建议一键安装x-ui面板来搭建代理,安装时仅需手动设置面板的访问端口,至于面板的登录名和密码及访问路径均在完成后显示
# 安装完成后的面板访问路径类似:http://[IP]:[PORT]/[WebBasePath] ,在其中完成添加入站的条目后即可生效使用
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)

# 安装完成后x-ui程序默认是开机自启状态,以下是x-ui程序的相关命令:
┌───────────────────────────────────────────────────────┐
│ x-ui control menu usages (subcommands): │
│ │
│ x-ui - Admin Management Script │
│ x-ui start - Start │
│ x-ui stop - Stop │
│ x-ui restart - Restart │
│ x-ui status - Current Status │
│ x-ui settings - Current Settings │
│ x-ui enable - Enable Autostart on OS Startup │
│ x-ui disable - Disable Autostart on OS Startup │
│ x-ui log - Check logs │
│ x-ui banlog - Check Fail2ban ban logs │
│ x-ui update - Update │
│ x-ui legacy - legacy version │
│ x-ui install - Install │
│ x-ui uninstall - Uninstall │
└───────────────────────────────────────────────────────┘

# 一键安装完成后的相关文件路径:
- /usr/local/x-ui/bin/xray-linux-amd64 # 代理用的核心文件,可单独运行:/usr/local/x-ui/bin/xray-linux-amd64 -c /usr/local/x-ui/bin/config.json
- /usr/local/x-ui/bin/config.json # 配置通过面板生成,更多可参考:https://github.com/XTLS/Xray-examples
- /usr/local/x-ui/bin/geoip.dat # IP地理位置数据库
- /usr/local/x-ui/bin/geosite.dat # 域名分类规则文件
- /etc/systemd/system/x-ui.service # 开机自启脚本文件

# 若想为面板配置指定域名的HTTPS证书,可先获取相关域名的SSL证书,然后上传公私钥并在面板中配置
/usr/local/x-ui/ml.test.com_bundle.crt # 面板证书公钥
/usr/local/x-ui/ml.test.com.key # 面板证书私钥

# 若不想安装面板,Xray核心也可手动安装使用,相关.dat文件需与xray文件在同一路径
wget https://github.com/XTLS/Xray-core/releases/download/v25.8.3/Xray-linux-64.zip
unzip Xray-linux-64.zip && cd Xray-linux-64
xray -c /etc/xray/config.json

服务端的进阶搭建

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 上面的【极简搭建】和这里的【进阶搭建】只需要选择其中的一种就好了,写这么多种方式是为了更详细的了解它的安装使用

# 既可在Debian系中安装自带的v2ray程序,版本为 4.34 较老且很久没有更新过了
apt install v2ray
wget -O /usr/bin/geoip.dat https://github.com/v2fly/geoip/releases/latest/download/geoip.dat
/usr/bin/v2ray -config /etc/v2ray/config.json # 运行旧版v2ray程序使用指定的配置文件


# 也可手动下载官方包安装使用
wget https://github.com/v2fly/v2ray-core/releases/download/v5.38.0/v2ray-linux-64.zip
unzip v2ray-linux-64.zip && cd v2ray-linux-64
cp v2ray /usr/local/bin/v2ray
cp geoip.dat /usr/local/share/v2ray/geoip.dat
cp geosite.dat /usr/local/share/v2ray/geosite.dat
cp systemd/system/v2ray.service /etc/systemd/system/
/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json # 运行新版v2ray程序使用指定的配置文件


# 更可通过v2ray官方的脚本安装最新的v2ray程序和.dat文件
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

# 一键安装完成后的相关文件路径:
installed: /usr/local/bin/v2ray
installed: /usr/local/bin/v2ctl
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/config.json # 配置示例参考:https://github.com/v2fly/v2ray-examples
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/v2ray@.service

免流代理用的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 电信和联通的定向流量是可以免流的,移动基本不能免流。有些地区是全端口免流,而有的地区只有80/443/8080端口免
# 免流节点协议一般都是VMess的,而该协议的认证基于时间,要求服务器和客户端时间差绝对值不能超过90秒,但并不要求时区一致
# 免流传输协议用 tcp + http 或 ws 均可,头部伪装混淆域名即为运营商会免流的域名,路径path一般默认或:/

# 服务端通过 VMess + TCP + HTTP 组合来混淆免流的配置文件参考内容,request请求头和response响应头是免流的关键
{
"log": {
"loglevel": "warning"
},
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"ip": [ "geoip:private" ],
"outboundTag": "block"
}
]
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 80,
"protocol": "vmess",
"settings": {
"clients": [
{
"email": "admin",
"id": "ab638e0f-bcda-cd9a-debd-ef9693a837ad"
}
]
},
"streamSettings": {
"network": "tcp",
"security": "none",
"tcpSettings": {
"header": {
"type": "http",
"request": {
"headers": {},
"method": "GET",
"path": [ "/" ],
"version": "1.1"
},
"response": {
"headers": {},
"reason": "OK",
"status": "200",
"version": "1.1"
}
}
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "blackhole",
"tag": "block"
}
]
}


# Android v2rayNG客户端配置:
别名(remarks) ML
服务器地址(ip) ml.test.com 或者 [240e:47c:890:5052::1]
服务器端口(port) 80
用户ID(id) ab638e0f-bcda-cd9a-debd-ef9693a837ad
加密方式(security) none
底层传输方式(transport):
传输协议(network) tcp
伪装类型(type) http
伪装域名(http host) tjdownload.pan.wo.cn
伪装路径(path) /
传输层安全(TLS)

# 联通云盘混淆,可任选一个填到客户端中的【伪装域名(host)】中即可:
tjtn.pan.wo.cn
tjupload.pan.wo.cn
tjdownload.pan.wo.cn

其他使用优化相关

  1. 开启BBR1算法加速
1
2
3
4
# 开启BBR算法加速需要内核版本4.9或更高,需要先加载 /lib/modules/6.1/kernel/net/ipv4/tcp_bbr.ko 模块
# 编辑 vi /etc/sysctl.conf 文件添加或修改如下内容后执行 sysctl -p 使其生效:
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
  1. 可以使用 curl -v http://[ipv4/ipv6]:80 来查看80端口是否被运营商封禁,如果长时间没回应则被封了,直接回应连接失败的则未被封,已知家庭宽带 80 443 8080 均已被封

  2. 配置文件中的UUID可以手动通过命令行 cat /proc/sys/kernel/random/uuid 来生成

  3. 安卓手机无ROOT通过热点免流共享给电脑,原生一点的系统在设置热点的页面里有共享VPN之类的选项的,没有的话可按如下操作

  • 安卓端需在v2rayNG中设置【允许来自局域网的连接】和记得它的【本地代理端口】
  • 电脑端去到【网络和 Internet】>【代理】>【手动设置代理】里,【代理IP地址】填写安卓手机共享热点的本机IP,【端口】填写上面v2rayNG的【本地代理端口】即可
  • 共享热点就相当于在手机和电脑在另一个局域网中了,安卓手机共享热点的本机IP一般为电脑设置中该热点WiFi属性里的【IPv4 DNS 服务器】的地址,更多请自测