安装(服务端和客户端都适用)
1.下载安装脚本
wget https://install.direct/go.sh
https://install.direct/go.sh
2.1 在线安装脚本
需要连接
github
, 网络较慢着可参考下一步2.2
bash go.sh
2.2 离线安装脚本
- 下载 v2ray
wget https://cdn.jansora.com/files/v2ray/v4.26.0/v2ray-linux-64.zip
https://cdn.jansora.com/files/v2ray/v4.26.0/v2ray-linux-64.zip - 安装
sudo bash go.sh --local ./v2ray-linux-64.zip --version v4.26.0
服务器端配置
服务器端不需要配置, 但需要铭记端口号 $port
, ID $id
, 配置客户端的时候要用, 以下是服务器端参考配置文件(/etc/v2ray/config.json
)
{
"inbounds": [{
"port": $port,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "$id",
"level": 1,
"alterId": 64
}
]
}
}],
"outbounds": [{
"protocol": "freedom",
"settings": {}
},{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}],
"routing": {
"rules": [
{
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "blocked"
}
]
}
}
客户端配置
将服务器端配置的 $port
, $ip
拷贝到客户端的配置文件下(/etc/v2ray/config.json
)
$host
填写上述服务器的域名或IP
{
"inbounds": [{
"port": 1080, // SOCKS 代理端口,在浏览器中需配置代理并指向这个端口
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"udp": true
}
}],
"outbounds": [{
"protocol": "vmess",
"settings": {
"vnext": [{
"address": "$host", // 服务器地址,请修改为你自己的服务器 ip 或域名
"port": $port, // 服务器端口
"users": [{ "id": "$id" }]
}]
}
},{
"protocol": "freedom",
"tag": "direct",
"settings": {}
}],
"routing": {
"domainStrategy": "IPOnDemand",
"rules": [{
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "direct"
}]
}
}
启动 or 关闭 v2ray
启动 sudo systemctl start v2ray.service
关闭 sudo systemctl stop v2ray.service
配置开机自启动 v2ray
开机自启动: sudo systemctl enable v2ray.service
关闭开机自启动 sudo systemctl disable v2ray.service