返回博客首页

v2ray用法

XiaoNiu · 2026/5/4 15:49:29
v2ray

来自https://www.itwordsweb.com/linux_doc/v2ray_1.html

依次执行命令:

[root@test ~]# cd /usr/local/src/
[root@test src]# curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh
[root@test src]# curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh
[root@test src]# bash install-release.sh
[root@test src]# bash install-dat-release.sh
[root@test src]# echo '' > /usr/local/etc/v2ray/config.json
[root@test src]# mkdir -p /var/log/v2ray/
[root@test src]# vi /usr/local/etc/v2ray/config.json
{
    "log": {
        "access": "/var/log/v2ray/access.log",
        "error": "/var/log/v2ray/error.log",
        "loglevel": "warning"
    },
    "inbound": {
        "port": 12345,
        "protocol": "vmess",
        "settings": {
            "clients": [
                {
                    "id": "bc1fedff-67b7-186e-0487-e3f510859ce4",
                    "level": 1,
                    "alterId": 100
                }
            ]
        }
    },
    "outbound": {
        "protocol": "freedom",
        "settings": {}
    },
    "inboundDetour": [],
    "outboundDetour": [
        {
            "protocol": "blackhole",
            "settings": {},
            "tag": "blocked"
        }
    ],
    "routing": {
        "strategy": "rules",
        "settings": {
            "rules": [
                {
                    "type": "field",
                    "ip": [
                        "0.0.0.0/8",
                        "10.0.0.0/8",
                        "100.64.0.0/10",
                        "127.0.0.0/8",
                        "169.254.0.0/16",
                        "172.16.0.0/12",
                        "192.0.0.0/24",
                        "192.0.2.0/24",
                        "192.168.0.0/16",
                        "198.18.0.0/15",
                        "198.51.100.0/24",
                        "203.0.113.0/24",
                        "::1/128",
                        "fc00::/7",
                        "fe80::/10"
                    ],
                    "outboundTag": "blocked"
                }
            ]
        }
    }
}
# 先按a,然后把服务端的配置信息粘贴进去,最后按:wq退出编辑并保存
[root@test src]# systemctl start v2ray

其中配置里面的clients标签中的uuid可以替换成自己在v2ray客户端里面生成的。

开启BBR:来自https://zhuanlan.zhihu.com/p/29295440 依次执行命令:

modprobe tcp_bbr
echo "tcp_bbr" >> /etc/modules-load.d/modules.conf
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
sysctl net.ipv4.tcp_available_congestion_control
sysctl net.ipv4.tcp_congestion_control