VPS套WARP以MARK的方式分流

说明

为什么不用官方socks5? 因为这socks5还是要转换成tun才可以用.
为什么使用使用mark的方式? 以mark的方式适合配合proxy分流使用.不需要转换通过ip rule/ip route就能实现.

安装

省略

Wireguard

配置

Wireguard 配置

vim /etc/wireguard/wgcf.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[Interface]
PrivateKey = +F6Ed8Sr59ySYTn+J4gj
Address = 172.16.0.2/32
Address = fd01:5ca1:ab1e:8235:xxxx:xxxx:xxxx:xxxx/128
#DNS = 8.8.8.8,2001:4860:4860::8888 # 注释使用系统DNS配置
MTU = 1280

# 关闭默认添加的配置,修改成添加通过mark来判断路由
Table = off
PostUp = ip rule add fwmark 22 table 100 ; ip route add 0.0.0.0/0 dev wgcf table 100 ; ip -6 rule add fwmark 22 table 100 ; ip -6 route add ::/0 dev wgcf table 100
PostDown = ip rule del fwmark 22 table 100 ; ip route del 0.0.0.0/0 dev wgcf table 100 ; ip -6 rule del fwmark 22 table 100 ; ip -6 route del ::/0 dev wgcf table 100

[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
AllowedIPs = 0.0.0.0/0
AllowedIPs = ::/0
#Endpoint = engage.cloudflareclient.com:2408
Endpoint = 162.159.192.3:2408

Proxy 配置

1
2
3
4
5
6
7
8
9
10
11
12
{
"protocol": "freedom",
"settings": {
//"domainStrategy": "UseIPv4"
},
"streamSettings": {
"sockopt": {
"mark": 22 // 跟上边相同的
}
},
"tag": "wgcf"
}