返回首页 - Notes - 2019

部署 V2Ray


安装服务端

  1. bash <(curl -L -s https://install.direct/go.sh)
  2. sudo bash go.sh
  3. sudo vim /etc/v2ray/config.json
    {
      "inbounds": [{
        "port": 安装时自己会生成端口号,
        "protocol": "vmess",
        "settings": {
          "clients": [
            {
              "id": "安装时自己会生成一串唯一标识码",
              "level": 1,
              "alterId": 64
            }
          ]
        }
      }],
      "outbounds": [{
        "protocol": "freedom",
        "settings": {}
      },{
        "protocol": "blackhole",
        "settings": {},
        "tag": "blocked"
      }],
      "routing": {
        "rules": [
          {
            "type": "field",
            "ip": ["geoip:private"],
            "outboundTag": "blocked"
          }
        ]
      }
    }
    
  4. sudo systemctl start v2ray(启动服务)
  5. sudo ufw allow 安装时自己生成的端口号(防火墙端口放行)

命令行客户端

  1. 访问 https://github.com/v2ray/v2ray-core/releases 下载 v2ray-macos.zip,解压缩
  2. vim config.json
    {
      "log": {
        "loglevel": "warning",
        "access": "your_path_to_access.log",
        "error": "your_path_to_error.log"
      },
      "inbounds": [
        {
          "port": 1081(本地访问端口,可自定义,注意别和 Shadowsocks 客户端用的端口冲突了),
          "protocol": "socks",
          "sniffing": {
            "enabled": true,
            "destOverride": ["http", "tls"]
          },
          "settings": {
            "auth": "noauth"
          }
        }
      ],
      "outbounds": [
        {
          "protocol": "vmess",
          "settings": {
            "vnext": [
              {
                "address": "服务器IP",
                "port": 服务器安装时自己生成的端口号,
                "users": [
                  {
                    "id": "服务器安装时自己生成的一串唯一标识码",
                    "alterId": 服务器alterId
                  }
                ]
              }
            ]
          }
        }
      ]
    }
    
  3. ./v2ray(启动客户端)
  4. 可通过 FireFox 自带代理,设置 socks v5 来访问

图形客户端

  1. 访问 https://github.com/Cenmrev/V2RayX/releases 下载图形客户端,解压安装
  2. Shadowsocks 客户端的设置大同小异,关键是要把服务器的 addressportuser-idalterIdlevel 设置对

注意事项

  1. V2Ray 安装时基本不需要改动服务器配置,它会自己生成好,你只需启动服务、放行端口即可
  2. 如果使用 polipo 来做终端代理的话,要注意端口号匹配,建议 Shadowsocks1080V2Ray1081

更新pac文件

  1. pip3 install genpac
  2. genpac --format=pac -o pac.js --pac-proxy="SOCKS5 127.0.0.1:1081; SOCKS 127.0.0.1:1081; DIRECT;"
  3. cp pac.js ~/Library/Application\ Support/V2RayX/pac/pac.js

date:2019-09-20