12VPX
v2RayのLinux上での使用方法

v2Ray Linuxでの設定

セットアップスクリプトは、/etc/v2ray/config.jsonにデフォルトの設定を作成します。

このデフォルト設定により、コンピューターをv2rayサーバーに変換できます。v2rayをクライアントとして使用する場合は、デフォルトの設定を削除し、以下のテンプレートで置き換えてください。

{
  // Run a local SOCKS proxy for apps to connect to.
  "inbounds": [{
    "port": 1080,
    "listen": "127.0.0.1",
    "protocol": "socks",
    "sniffing": {
      "enabled": true,
      "destOverride": ["http", "tls"]
    },
    "settings": {
      "udp": true
    }
  }],
  "outbounds": [{
    // Add our v2Ray server as an outbound destination. 
    "protocol": "vmess",
    "settings": {
      "vnext": [{
        "address": "123.123.123.123", 
        "port": 443,
        "users": [{
	  "id": "88888888-4444-4444-4444-123456789123",
	  "alterId": 0
	}]
      }]
    },
      "streamSettings": {
        "network": "ws",
        "security": "tls",
        "tlssettings": {
          "allowInsecure": false,
          "serverName": "static.cldcdn.net"
        },
        "wssettings": {
	  "connectionReuse": true,
          "path": "/ray",
	  "headers": {
            "Host": "static.cldcdn.net"
          }
        }
    }
  },{
    // Add a destination for traffic that should NOT go to the VPN.
    "protocol": "freedom",
    "tag": "direct",
    "settings": {}
  }],
  "routing": {
    "domainStrategy": "IPOnDemand",
    "rules": [
    {
      // Don't send LAN traffic to the VPN.
      "ip": ["geoip:private"],
      "outboundTag": "direct",
      "type": "field"
    },
    {
      // Don't send Chinese IP's to the VPN.
      "ip": ["geoip:cn"],
      "outboundTag": "direct",
      "type": "field"
    },
    {
      // Don't send .cn domains to the VPN.
      "domain": ["geosite:cn"],
      "outboundTag": "direct",
      "type": "field"
    }
    // Everything else goes to VPN server.
    ]
  }
}

このテンプレートで置き換える必要がある2つの値があります:

  • outbounds > settings > vnext > address
  • outbounds > settings > vnext > users > id

addressおよびidの適切な値は、v2Rayのページで見つけることができます。

他に変更する必要はありません。

このコマンドを使用して、新しい設定をテストすることができます。

/usr/bin/v2ray/v2ray -test -config /etc/v2ray/config.json

期待される出力は:

~/Downloads
❯ /usr/bin/v2ray/v2ray -test -config /etc/v2ray/config.json
V2Ray 4.23.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.13 linux/amd64)
A unified platform for anti-censorship.
2020/04/17 11:31:21 [Info] v2ray.com/core/common/platform/ctlcmd: <v2ctl message> 
v2ctl> Read config:  /etc/v2ray/config.json
Configuration OK.

なお、これは構文エラーのみをテストします。入力した情報が正しいかどうかはテストしません。