12VPX
v2Ray on Linux

v2Ray on Linux - Configure

The setup script creates a default configuration in /etc/v2ray/config.json.

This default configuration turns your computer into a v2ray server. To use v2ray as a client, please delete the default configuration and replace it with our template:

{
  // 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.
    ]
  }
}

There are two values you need to replace in this template:

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

Suitable values for address and id can be found on our v2Ray page.

Nothing else needs to be changed.

You can test your new configuration using this command:

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

The expected output is:

~/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.

Note that this only tests for syntax errors. It does not test whether the information you entered is correct.