安装脚本将在**/etc/v2ray/config.json**中创建一个默认配置。
此默认配置将您的计算机转变为一个v2ray服务器。要将v2ray用作客户端,请删除默认配置并用我们的模板替换它:
{
// Run a local SOCKS proxy for apps to connect to.
"inbounds": [{
"port": 1080,
"listen": "127.0.0.1",
"protocol": "socks",
"sniffing": {
"enabled": true,
"destOverride": ["http", "tls"]
},
"settings": {
"udp": true
}
}],
"outbounds": [{
// Add our v2Ray server as an outbound destination.
"protocol": "vmess",
"settings": {
"vnext": [{
"address": "123.123.123.123",
"port": 443,
"users": [{
"id": "88888888-4444-4444-4444-123456789123",
"alterId": 0
}]
}]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"tlssettings": {
"allowInsecure": false,
"serverName": "static.cldcdn.net"
},
"wssettings": {
"connectionReuse": true,
"path": "/ray",
"headers": {
"Host": "static.cldcdn.net"
}
}
}
},{
// Add a destination for traffic that should NOT go to the VPN.
"protocol": "freedom",
"tag": "direct",
"settings": {}
}],
"routing": {
"domainStrategy": "IPOnDemand",
"rules": [
{
// Don't send LAN traffic to the VPN.
"ip": ["geoip:private"],
"outboundTag": "direct",
"type": "field"
},
{
// Don't send Chinese IP's to the VPN.
"ip": ["geoip:cn"],
"outboundTag": "direct",
"type": "field"
},
{
// Don't send .cn domains to the VPN.
"domain": ["geosite:cn"],
"outboundTag": "direct",
"type": "field"
}
// Everything else goes to VPN server.
]
}
}
在此模板中,有两个值需要替换:
- outbounds > settings > vnext > address
- outbounds > settings > vnext > users > id
可以在我们的v2Ray页面上找到address和id的适当值。
其他内容不需要更改。
您可以使用以下命令测试您的新配置:
/usr/bin/v2ray/v2ray -test -config /etc/v2ray/config.json
期望的输出是:
~/Downloads
❯ /usr/bin/v2ray/v2ray -test -config /etc/v2ray/config.json
V2Ray 4.23.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.13 linux/amd64)
A unified platform for anti-censorship.
2020/04/17 11:31:21 [Info] v2ray.com/core/common/platform/ctlcmd: <v2ctl message>
v2ctl> Read config: /etc/v2ray/config.json
Configuration OK.
请注意,这仅测试语法错误。它不测试您输入的信息是否正确。