Linu服务器上配置V2ray客户端

安装v2ray

参考网上博客:
Linux下使用v2ray - Jun’s Blog

下载v2ray core

https://github.com/v2ray/v2ray-core/releases/

我服务器上:

wget https://./u/v2ray-linux-64.zip
unzip v2ray-linux-64.zip -d v2ray-linux-64 && cd v2ray-linux-64

移动:

v2ray -> /usr/local/bin/v2ray
v2ctl -> /usr/local/bin/v2ctl
geoip.dat -> /usr/local/share/v2ray/geoip.dat
geosite.dat -> /usr/local/share/v2ray/geosite.dat
config.json -> /usr/local/etc/v2ray/config.json
access.log -> /var/log/v2ray/access.log
error.log -> /var/log/v2ray/error.log
v2ray.service -> /etc/systemd/system/v2ray.service
v2ray@.service -> /etc/systemd/system/v2ray@.service

可以使用我的脚本:

在v2ray-linux-64目录下:

vim run.sh
#!/bin/bash

# 创建必要的目录
mkdir -p /usr/local/bin
mkdir -p /usr/local/share/v2ray
mkdir -p /usr/local/etc/v2ray
mkdir -p /var/log/v2ray
mkdir -p /etc/systemd/system

# 移动文件到对应的目录
mv v2ray /usr/local/bin/v2ray
mv v2ctl /usr/local/bin/v2ctl
mv geoip.dat /usr/local/share/v2ray/geoip.dat
mv geosite.dat /usr/local/share/v2ray/geosite.dat
mv config.json /usr/local/etc/v2ray/config.json
# mv access.log /var/log/v2ray/access.log
# mv error.log /var/log/v2ray/error.log
mv ./systemd/system/v2ray.service /etc/systemd/system/v2ray.service
mv ./systemd/system/v2ray@.service /etc/systemd/system/v2ray@.service

# # 设置日志文件权限
# chmod 666 /var/log/v2ray/access.log
# chmod 666 /var/log/v2ray/error.log

mkdir -p /var/log/v2ray
touch /var/log/v2ray/access.log
chmod 666 /var/log/v2ray/access.log

mkdir -p /var/log/v2ray
touch /var/log/v2ray/error.log
chmod 666 /var/log/v2ray/access.log

# 提示用户确认
echo "文件已成功移动并设置权限。"
chmod +x run.sh

配置文件

cd /usr/local/etc/v2ray/ && ls && mv config.json config_backup.json
wget https://share.plumbum.one/upload/kitti_v2ray_no3.json -O config.json

运行

使用systemctl的话就是:

# 启动V2ray
sudo systemctl start v2ray
# 检查V2ray状态
sudo systemctl status v2ray
# 设置V2ray开机自启动
sudo systemctl enable v2ray
# 检验代理是否成功生效
curl -x socks5://127.0.0.1:10808 https://www.google.com -v

直接运行:

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

系统环境

我暂时感觉配置这个就行:

vim /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
http_proxy=http://127.0.0.1:10809
https_proxy=http://127.0.0.1:10809
http_proxy=http://127.0.0.1:10809
https_proxy=http://127.0.0.1:10809
http_proxy=http://127.0.0.1:10809
https_proxy=http://127.0.0.1:10809

(要是clash的7890同理,10809是我的v2ray配置文件中使用的)

关闭的话

unset http_proxy
unset https_proxy

服务器搭建服务端

别人的博客:

如何使用 x-ui 和 xray 自建节点科学上网 | 言外之音

我自己熟悉的快速方法:

最好直接vmess(快,好像autol不行,没事换vless就可以)

mkdir v2ray_pb && cd v2ray_pb
wget https://raw.githubusercontent.com/FranzKafkaYu/x-ui/master/install.sh -O pbv2ray.sh
chmod +x pbv2ray.sh
./pbv2ray.sh

原来的

wget https://raw.githubusercontent.com/FranzKafkaYu/x-ui/master/install.sh -O pbv2ray.sh

然后开bbr加速

记得开服务器端口

其他说明

https://i007it.com/2022/06/14/Linux%E4%BD%BF%E7%94%A8v2ray/
上面写的很好

安装v2ray

下载v2ray core

https://github.com/v2ray/v2ray-core/releases/

or我的(用我的吧,新版的不一样)

wget https://share.plumbum.one/upload/v2ray-linux-64.zip
cd v2ray-linux-64

chmod 755 v2ray
chmod 755 v2ctl
chmod 755 systemd/system/v2ray.service
chmod 755 systemd/system/v2ray@.service
sudo su
cp v2ray /usr/local/bin/
cp v2ctl /usr/local/bin/

cp systemd/system/v2ray.service /etc/systemd/system/
cp systemd/system/v2ray@.service /etc/systemd/system/

mkdir /usr/local/share/v2ray/
cp geoip.dat /usr/local/share/v2ray/
cp geosite.dat /usr/local/share/v2ray/

mkdir /var/log/v2ray/
cp access.log /var/log/v2ray/
cp error.log /var/log/v2ray/

可能出现问题解决

cp: 对 'access.log' 调用 stat 失败: 没有那个文件或目录
cp: 对 'error.log' 调用 stat 失败: 没有那个文件或目录
root@plumbum-virtual-machine:/home/plumbum/v2ray-linux-64# ^C
root@plumbum-virtual-machine:/home/plumbum/v2ray-linux-64# cd /var/log/v2ray/
root@plumbum-virtual-machine:/var/log/v2ray# ls
access.log  error.log

config.json配置文件

mkdir /usr/local/etc/v2ray/
cp config.json /usr/local/etc/v2ray/config.json

启动状态暂停

# 启动V2ray
sudo systemctl start v2ray

# 检查V2ray状态
sudo systemctl status v2ray

# 设置V2ray开机自启动
sudo systemctl enable v2ray

检测

curl -x socks5://127.0.0.1:10808 https://www.google.com -v
curl -x socks5://127.0.0.1:1080 https://www.google.com -v
export http_proxy="socks5://127.0.0.1:10808"
export https_proxy="socks5://127.0.0.1:10808"

上面放到环境变量

source ~/.bashrc

我的

{
  "log": {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "tag": "socks",
      "port": 10808,
      "listen": "0.0.0.0",
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ],
        "routeOnly": false
      },
      "settings": {
        "auth": "noauth",
        "udp": true,
        "allowTransparent": false
      }
    },
    {
      "tag": "http",
      "port": 10809,
      "listen": "0.0.0.0",
      "protocol": "http",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ],
        "routeOnly": false
      },
      "settings": {
        "auth": "noauth",
        "udp": true,
        "allowTransparent": false
      }
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vless",
      "settings": {
        "vnext": [
          {
            "address": "vless.xui.plumbum.one",
            "port": 42980,
            "users": [
              {
                "id": "d7c79790-5673-4798-a099-606e82afdd60",
                "alterId": 0,
                "email": "t@t.tt",
                "security": "auto",
                "encryption": "none"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "security": "tls",
        "tlsSettings": {
          "allowInsecure": true,
          "serverName": "vless.xui.plumbum.one",
          "fingerprint": "chrome",
          "show": false
        },
        "tcpSettings": {
          "header": {
            "type": "http",
            "request": {
              "version": "1.1",
              "method": "GET",
              "path": [
                "/"
              ],
              "headers": {
                "Host": [
                  "plumbum.one"
                ],
                "User-Agent": [
                  ""
                ],
                "Accept-Encoding": [
                  "gzip, deflate"
                ],
                "Connection": [
                  "keep-alive"
                ],
                "Pragma": "no-cache"
              }
            }
          }
        }
      },
      "mux": {
        "enabled": false,
        "concurrency": -1
      }
    },
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {}
    },
    {
      "tag": "block",
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      }
    }
  ],
  "dns": {
    "servers": [
      "1.1.1.1",
      "8.8.8.8"
    ]
  },
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api"
      },
      {
        "type": "field",
        "port": "0-65535",
        "outboundTag": "proxy"
      }
    ]
  }
}

网上的例子

{
  "log": {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "tag": "socks",
      "port": 1080,
      "listen": "127.0.0.1",
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      },
      "settings": {
        "auth": "noauth",
        "udp": true,
        "allowTransparent": false
      }
    },
    {
      "tag": "http",
      "port": 1081,
      "listen": "127.0.0.1",
      "protocol": "http",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      },
      "settings": {
        "udp": false,
        "allowTransparent": false
      }
    }
  ],
  "outbounds": [
    {
      "tag": "proxy",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "abc.abc.net",
            "port": 30000,
            "users": [
              {
                "id": "effffff6-fffffb-4aaa-8888-aaaaaaaaaa",
                "alterId": 1,
                "email": "t@t.tt",
                "security": "chacha20-poly1305"
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "tcp"
      },
      "mux": {
        "enabled": true,
        "concurrency": 8
      }
    },
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {}
    },
    {
      "tag": "block",
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      }
    }
  ],
  "routing": {
    "domainStrategy": "AsIs",
    "domainMatcher": "linear",
    "rules": [
      {
        "type": "field",
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "enabled": true
      },
      {
        "type": "field",
        "outboundTag": "proxy",
        "domain": [
          "geosite:google"
        ],
        "enabled": true
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "domain": [
          "domain:example-example.com",
          "domain:example-example2.com"
        ],
        "enabled": true
      },
      {
        "type": "field",
        "outboundTag": "block",
        "domain": [
          "geosite:category-ads-all"
        ],
        "enabled": true
      }
    ]
  }
}

   转载规则


《Linu服务器上配置V2ray客户端》 plumbum 采用 知识共享署名 4.0 国际许可协议 进行许可。
 上一篇
Java简易生成bin和打包jar方法 Java简易生成bin和打包jar方法
VScode创建jar包,jar包转成.exe文件,.exe文件转成安装包_vscode jar-CSDN博客 上面的网站讲的挺不错的 (base) plumbum@DESKTOP-17THH87:/mnt/d/学习资料/study_cod
2024-03-01
下一篇 
Linu服务器上配置clash Linu服务器上配置clash
linux服务器使用clash关于这件事已经操作N遍了,每次都不记得还要搜一下,这次记录一下方便复盘 下载由于 Clash Premium 的主库已被删除,我们将使用备份库来获取吧 或者(废话,无需多言…) wget ttps://gith
2024-01-31