以PureVPN为例子
OPENAI的ChatGPT太强了!
解决了大部分问题
大致可分为三步
1.修改PureVPN下发的conf文件(修改路由)
2.安装配置OPENVPN
3.修改Xray(R)的outbound路由
1.去pure下载配置文件(选择openvpn TCP类型,UDP貌似也可以,只要是openvpn配置文件就行)
2.修改conf文件,重点是修改他的路由route
注意修改为 route-nopull 意味着路由需要手动配置,原来的意思是接管全局.

3.上传配置文件到VPS,这里我命名为 test.conf
官方给的二进制文件虽然方便,但是默认他的接管路由是全局,包括SSH22端口,使得我们的机器失联,因此需要手动配置.
1.使用
sudo apt-get install openvpn2.写一个 login.conf 文件(教程来自OPENAI)
login.conf 是一个文本文件,用于存储您的 PureVPN 帐户的用户名和密码。可以按照以下步骤编写 login.conf:
创建一个新文件并将其命名为 login.conf。
打开 login.conf 并在第一行输入您的 PureVPN 用户名,然后在第二行输入您的 PureVPN 密码。例如:
xxxxxxxxxxmyusernamemypassword
请注意,您应该将实际的用户名和密码替换为 myusername 和 mypassword。
login.conf 文件的权限设置为仅限当前用户可读写,使用以下命令更改其权限:xxxxxxxxxxchmod 600 login.conf这将确保只有您自己可以读取和写入文件。
请注意,login.conf 中的用户名和密码应与您在 PureVPN 网站上注册的凭据相同。如果您不确定自己的用户名和密码,可以登录 PureVPN 网站并在账户资料中查找它们。
补充 PureVPN授权账号页面

3.
连接OPENVPN
xxxxxxxxxxsudo openvpn --config test.conf --data-ciphers-fallback AES-256-CBC注意:
该警告消息指出,在未来的OpenVPN版本中,选项--cipher将被忽略,因此建议使用--data-ciphers选项进行加密算法的协商。
更改--cipher选项:你也可以通过更改OpenVPN命令中的--cipher选项来消除警告消息
出现Init...说明连接成功了,此时会创建一个tun0的虚拟网卡

可以使用screen或者nohup挂着后台
这里我用screen为例子
(1)新建一个screen窗口
screen -R pure //新建一个名为pure的screen窗口
(2)执行命令
xxxxxxxxxxsudo openvpn --config test.conf --data-ciphers-fallback AES-256-CBC(3)使用Ctrl+A+D退出Screen
模板配置
xxxxxxxxxx{ "api": { "services": [ "HandlerService", "LoggerService", "StatsService" ], "tag": "api" }, "inbounds": [ { "listen": "127.0.0.1", "port": 62789, "protocol": "dokodemo-door", "settings": { "address": "127.0.0.1" }, "tag": "api" } ], "outbounds": [ { "protocol": "freedom", "settings": { "domainStrategy": "UseIPv4" }, "streamSettings": { "sockopt": { "tcpFastOpen": true, "interface": "tun0" } }, "mux": { "enabled": false, "concurrency": 8 } }, { "protocol": "blackhole", "settings": {}, "tag": "blocked" } ], "policy": { "system": { "statsInboundDownlink": true, "statsInboundUplink": true } }, "routing": { "rules": [ { "inboundTag": [ "api" ], "outboundTag": "api", "type": "field" }, { "ip": [ "geoip:private" ], "outboundTag": "blocked", "type": "field" }, { "outboundTag": "blocked", "protocol": [ "bittorrent" ], "type": "field" } ] }, "stats": {} }
重点是outbounds那一块,大体可以解释为流经Xray的流量都会移交到TUN0这个虚拟网卡处理
首先你先要确保你的XrayR的主配置文件使用自定义的配置
要修改的配置有两个
一个是 custom_outbound.json 主管流量出口
另一个是 route.json 主管路由
我们使用OPENVPN创建了一个名称为"tun0"的虚拟网卡
需要在流量传入后进行处理使得被处理的流量由"tun0"流出,而流出则需要指向即修改路由。
因此我们需要修改出口文件与路由文件(注意各TAG要对应)
custom_outbound.json 配置
xxxxxxxxxx[{ "tag": "pure", "protocol": "freedom", "settings": { "domainStrategy": "UseIPv4" }, "streamSettings": { "sockopt": { "tcpFastOpen": true, "interface": "tun0" } }, "mux": { "enabled": false, "concurrency": 8 } }, { "protocol": "blackhole", "tag": "block" }]
route.json 配置
xxxxxxxxxx{ "domainStrategy": "IPOnDemand", "rules": [ { "type": "field", "outboundTag": "block", "ip": [ "geoip:private" ] }, { "type": "field", "outboundTag": "block", "protocol": [ "bittorrent" ] }, { "type": "field", "outboundTag": "pure", "network": "udp,tcp" } ]}