V2Ray on Debian/Ubuntu

V2Ray安装以及配置

如何在Debian/Ubuntu上安装配置v2ray

安装V2Ray

1
2
3
4
5
curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh
sudo bash install-release.sh
sudo systemctl restart v2ray
sudo systemctl status v2ray
sudo systemctl enable v2ray

设置 NTP 时间同步

1
timedatectl set-timezone Asia/Shanghai

基本配置

打开防火墙

1
ufw allow 443/tcp

配置V2Ray

  • 改配置 vi /usr/local/etc/v2ray/config.json
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "inbounds": [
    {
      "port": 443, 
      "protocol": "vmess",    
      "settings": {
        "clients": [
          {
            "id": "b831381d-6324-4d53-ad4f-8cda48b30811", //https://www.uuidgenerator.net/
            "alterId": 0
          }
        ]
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",  
      "settings": {}
    }
  ]
}
  • 测试配置 v2ray test -config /usr/local/etc/v2ray/config.json
  • 重启服务 sudo systemctl restart v2ray
  • 检查监听端口 sudo ss -lnpt | grep v2ray

客户端配置V2Ray

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
  "inbounds": [
    {
      "port": 1080, 
      "protocol": "socks", 
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      },
      "settings": {
        "auth": "noauth" 
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess", 
      "settings": {
        "vnext": [
          {
            "address": "mydomain.me", 
            "port": 16823,  
            "users": [
              {
                "id": "b831381d-6324-4d53-ad4f-8cda48b30811",  
                "alterId": 0 
              }
            ]
          }
        ]
      }
    }
  ]
}

v2rayN

高级配置-启用TLS

打开防火墙

1
2
ufw allow 80/tcp
ufw allow 443/tcp

生成证书

1
2
3
4
5
6
7
curl  https://get.acme.sh | sh
source ~/.bashrc
apt-get install openssl cron socat curl
~/.acme.sh/acme.sh --register-account -m admin@example.com
~/.acme.sh/acme.sh --issue -d mydomain.me --standalone --keylength ec-256 --force
~/.acme.sh/acme.sh --installcert -d mydomain.me --ecc --fullchain-file /etc/v2ray/v2ray.crt --key-file /etc/v2ray/v2ray.key
chmod 644 /etc/v2ray/v2ray.*

配置V2Ray

  • 改配置 vi /usr/local/etc/v2ray/config.json
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
  "inbounds": [
    {
      "port": 443,
      "protocol": "vmess",    
      "settings": {
        "clients": [
          {
            "id": "23ad6b10-8d1a-40f7-8ad0-e3e35cd38297",  
            "alterId": 64
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "security": "tls",
        "tlsSettings": {
          "certificates": [
            {
              "certificateFile": "/etc/v2ray/v2ray.crt",
              "keyFile": "/etc/v2ray/v2ray.key"
            }
          ]
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}
  • 测试配置 v2ray test -config /usr/local/etc/v2ray/config.json
  • 重启服务 sudo systemctl restart v2ray
  • 检查监听端口 sudo ss -lnpt | grep v2ray

客户端配置V2Ray

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  "inbounds": [
    {
      "port": 1080,
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      },
      "settings": {
        "auth": "noauth"
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "mydomain.me",
            "port": 443,
            "users": [
              {
                "id": "23ad6b10-8d1a-40f7-8ad0-e3e35cd38297",
                "alterId": 64
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "security": "tls"
      }
    }
  ]
}

v2rayN

参考

使用 Hugo 构建
主题 StackJimmy 设计