V2ray¶
安裝和更新 V2Ray¶
// 安裝執行檔和 .dat 資料檔
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
安裝最新發行的 geoip.dat 和 geosite.dat¶
// 只更新 .dat 資料檔
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh)****
移除 V2Ray¶
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove
文件路径¶
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
installed: /var/log/v2ray/
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/v2ray@.service
安全优化¶
# 建立 v2ray 使用者和使用者群組
useradd -r -M -s /usr/sbin/nologin v2ray
# 修改 v2ray 服務檔案
[Service]
User=v2ray
Group=v2ray
# 修改檔案擁有者
chown -R v2ray:v2ray /usr/local/etc/v2ray
chown -R v2ray:v2ray /var/log/v2ray
chmod -R 777 /var/log/v2ray/
# 重新載入 systemd 並重新啟動 v2ray 服務:
systemctl daemon-reload
systemctl restart v2ray
配置參考¶
{
"log": {
"loglevel": "warning",
"access": "/var/log/v2ray/access.log", // 这是 Linux 的路径
"error": "/var/log/v2ray/error.log"
},
"routing": {
"rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{
"outboundTag": "blocked",
"protocol": [
"bittorrent"
],
"type": "field"
}
]
},
"dns": null,
"inbounds": [
{
"listen": null,
"port": 11100,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "2ab05ef8-b653-c692-6f75-06455a63a062", // 可通过v2ray uuid生成
"email": "",
"alterId": 0
}
],
"disableInsecureEncryption": true
},
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"path": "/lyricn", //ws的path路径,自定义
"headers": {},
"acceptProxyProtocol": false
}
},
"tag": "inbound-v2ray",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
},
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
],
"transport": null,
"policy": {
"levels": {
"0": {
"handshake": 10,
"connIdle": 100,
"uplinkOnly": 2,
"downlinkOnly": 3,
"statsUserUplink": true,
"statsUserDownlink": true,
"bufferSize": 10240
}
},
"system": {
"statsInboundDownlink": true,
"statsInboundUplink": true
}
},
"api": {
"services": [
"HandlerService",
"LoggerService",
"StatsService"
],
"tag": "api"
},
"stats": {},
"reverse": null,
"fakeDns": null
}
遇到的問題¶
連接不上V2ray
- 檢查防火墻對應端口是否開啓
- 配置文件是否正確(可通過v2ray test config.json)
- v2ray服務是否正常運行
- 檢查服務器時間是否和客戶端時間一致(使用ntp校準)