锦方的个人网页 · 如果有一天你突然想起了我


vmess配置

目录

安装

bash <(curl -L -s https://install.direct/go.sh)

####脚本会自动安装以下文件:

/usr/bin/v2ray/v2ray:V2Ray 程序;
/etc/v2ray/config.json:配置文件;

此脚本会配置自动运行脚本。自动运行脚本会在系统重启之后,自动运行 V2Ray。目前自动运行脚本只支持带有 Systemd 的系统,以及 Debian / Ubuntu 全系列。

运行脚本位于系统的以下位置:

/lib/systemd/system/v2ray.service  : Systemd
/etc/init.d/v2ray : SysV

脚本运行完成后,你需要:

编辑 /etc/v2ray/config.json 文件来配置你需要的代理方式; 运行 service v2ray start 来启动 V2Ray 进程; 之后可以使用 service v2ray start|stop|status|reload|restart|force-reload 控制 V2Ray 的运行。

配置

VMess 服务器端

{
  "log" : {
    "access": "/var/log/v2ray/access.log", // 访问日志文件
    "error": "/var/log/v2ray/error.log",   // 错误日志文件
    "loglevel": "warning"                  // 错误日志等级,可选 debug / info / warning / error
  },
  "inbound": {
    "port": 37192, // 主端口
    "protocol": "vmess",    // 主传入协议,参见协议列表
    "settings": {
      "clients": [
        {
          "id": "3b129dec-72a3-4d28-aeee-028a0fe86e22",  // 用户 ID,客户端须使用相同的 ID 才可以中转流量
          "level": 1  // 用户等级,自用 VPS 可设为 1;共享 VPS 请设为 0。
        }
      ]
    }
  },
  "outbound": {
    "protocol": "freedom",  // 主传出协议,参见协议列表
    "settings": {}
  },
  "inboundDetour": [
    {
      "protocol": "vmess",   // 可选,开启多个 VMess 端口
      "port": "30001-30010", // 开放 30001 到 30010 这 10 个端口
      "settings": {
        "clients": [  // VMess 配置,和主传入协议类似
          {
            "id": "3b129dec-72a3-4d28-aeee-028a0fe86e22",
            "level": 1
          }
        ]
      }
    }
  ],
  "outboundDetour": [
    {
      "protocol": "blackhole",  // 额外的传出协议,参见[协议列表](../chapter_02/02_protocols.md)。
      "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"
        }
      ]
    }
  }
}

vmess客户端

{
  "inbound": {
    "port": 1080, // 监听端口
    "protocol": "socks", // 入口协议为 SOCKS 5
    "settings": {
      "auth": "noauth",  // 不认证
      "udp": false       // 不开启 UDP 转发
    }
  },
  "outbound": {
    "protocol": "vmess", // 出口协议
    "settings": {
      "vnext": [
        {
          "address": "8.8.8.8", // 服务器 IP 地址
          "port": 17173,  // 服务器端口
          "users": [
            {"id": "d17a1af7-efa5-42ca-b7e9-6a35282d737f"} // 用户 ID,须与服务器端配置相同
          ]
        }
      ]
    }
  },
  "outboundDetour": [
    {
      "protocol": "freedom", // 额外的出口协议。Freedom 协议为直连模式,不经过服务器中转。
      "settings": {},
      "tag": "direct"  // 标签,在路由中用到
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [
        {
          "type": "field",
          "ip": [            // 以下 IP 段将被转到 Freedom
            "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": "direct" // Freedom 的标签
        }
      ]
    }
  }
}

点击去官网查看详细文档

点击去github查看详细代码