Timetombs

泛义的工具是文明的基础,而确指的工具却是愚人的器物

66h / 117a
,更新于 2024-10-29T22:15:39Z+08:00 by   c73aa5b

[工具] v2ray

版权声明 - CC BY-NC-SA 4.0

1 服务器安装

# wget https://linianhui.github.io/tool/v2ray/install.sh
# sudo bash install.sh 127.0.0.1

set -eux
V2RAY_VERSION=5.14.1
export V2RAY_SERVER_IP=$1

apt install -y wget gettext lsof

bash <(wget -q -O - https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --version $V2RAY_VERSION

/usr/local/bin/v2ray version

UUID=$(/usr/local/bin/v2ray uuid)
CRET_NAME=${UUID:0:8}
CRET_ORG=${UUID:9:4}

export TEMPLATE_SERVER_DOMAIN_NAME="${UUID:14:4}.test"
export TEMPLATE_CLIENT_ID=$UUID
export TEMPLATE_CERTIFICATE_JSON=$(/usr/local/bin/v2ray tls cert --ca --json --domain=$TEMPLATE_SERVER_DOMAIN_NAME --expire=720 --name=$CRET_NAME --org=$CRET_ORG)

wget -q -O - https://linianhui.github.io/tool/v2ray/server-config.template.json | envsubst > /usr/local/etc/v2ray/config.json

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

wget -q -O - https://linianhui.github.io/tool/v2ray/client-config.template.json | envsubst > client-config.json

echo "vmess://$(wget -q -O - https://linianhui.github.io/tool/v2ray/client-config.v2rayng.template.json | envsubst | base64 -w 0)" > client-config.v2rayng.json

setcap cap_net_bind_service=+ep /usr/local/bin/v2ray

systemctl daemon-reload
systemctl enable v2ray
systemctl restart v2ray
systemctl status v2ray

lsof -i:443

# https://github.com/v2fly/v2ray-core

# https://github.com/gfwlist/gfwlist
# https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt

2 客户端安装

2.1 Windows

下载客户端https://github.com/v2fly/v2ray-core/releases/download/v5.14.1/v2ray-windows-64.zip

然后用服务器安装中生成的client-config.json替换zip解压后的config.json即可。

2.2 macOS

下载客户端https://github.com/v2fly/v2ray-core/releases/download/v5.14.1/v2ray-macos-64.zip

然后用服务器安装中生成的client-config.json替换zip解压后的config.json即可。

2.3 Andorid

下载APKhttps://github.com/2dust/v2rayNG/releases

然后用服务器安装中生成的client-config.v2rayng.json复制到剪切板或者生成二维码。用v2rayNG这个APP从剪切板导入或者扫描二维码都可以。

3 浏览器扩展

SwitchyOmega : https://chrome.google.com/webstore/detail/proxy-switchyomega/padekgcemlokbadohgkifijomclgjgif

4 参考

4.1 服务器配置模板

{
  "log": {
    "logLevel": "None"
  },
  "inbounds": [
    {
      "listen": "$V2RAY_SERVER_IP",
      "port": 443,
      "protocol": "vless",
      "settings": {
        "decryption": "none",
        "clients": [
          {
            "id": "$TEMPLATE_CLIENT_ID"
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "security": "tls",
        "tlsSettings": {
          "serverName": "$TEMPLATE_SERVER_DOMAIN_NAME",
          "allowInsecure": false,
          "allowInsecureCiphers": false,
          "disableSystemRoot": true,
          "certificates": [
            $TEMPLATE_CERTIFICATE_JSON
          ]
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}

4.2 客户端配置模板(v2ray-core)

{
  "log": {
    "logLevel": "None"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 1080,
      "protocol": "socks",
      "settings": {
        "auth": "noauth",
        "udp": true
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "vless",
      "settings": {
        "vnext": [
          {
            "address": "$V2RAY_SERVER_IP",
            "port": 443,
            "users": [
              {
                "id": "$TEMPLATE_CLIENT_ID",
                "encryption": "none"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "security": "tls",
        "tlsSettings": {
          "serverName": "$TEMPLATE_SERVER_DOMAIN_NAME",
          "allowInsecure": false,
          "allowInsecureCiphers": false,
          "disableSystemRoot": true,
          "certificates": [
            $TEMPLATE_CERTIFICATE_JSON
          ]
        }
      },
      "mux": {
        "enabled": false
      }
    },
    {
      "protocol": "freedom",
      "settings": {},
      "tag": "direct",
      "mux": {
        "enabled": false
      }
    }
  ],
  "routing": {
    "domainStrategy": "IPOnDemand",
    "rules": [
      {
        "type": "field",
        "outboundTag": "direct",
        "domain": [
          "geosite:cn"
        ]
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "ip": [
          "geoip:cn",
          "geoip:private"
        ]
      }
    ]
  }
}

4.3 客户端配置模板(v2rayNG)

{
  "add": "$V2RAY_SERVER_IP",
  "port": "443",
  "host": "$TEMPLATE_SERVER_DOMAIN_NAME",
  "id": "$TEMPLATE_CLIENT_ID",
  "net": "tcp",
  "path": "",
  "ps": "$TEMPLATE_SERVER_DOMAIN_NAME",
  "tls": "tls",
  "type": "none",
  "v": "2"
}

4.4 OpenWrt

openwrt安装文档

#!/bin/sh /etc/rc.common

# openwrt
# /etc/init.d/v2ray
# chmod +x /etc/init.d/v2ray
# /etc/init.d/v2ray enable
# /etc/init.d/v2ray start
# /etc/init.d/v2ray stop
# /etc/init.d/v2ray reload

START=99

SERVICE_WRITE_PID=1
SERVICE_DAEMONIZE=1

start() {
  service_start /usr/bin/v2ray --config=/etc/config/v2ray.json
}

stop() {
  service_stop /usr/bin/v2ray
}

reload() {
  service_reload /usr/bin/v2ray
}

上一篇 : [工具] app
下一篇 : [工具] goproxy