从多年前自建ss,然后docker装ss,再转v2ray,一路翻山涉水,虽有辛劳,并无险阻。眼看归国之日渐近,这两日重搭梯子,却没少折腾。懒得看长文参数和原理,网上搜个攻略开干均告失败,是自己老家户不灵了,还是道行升高?反正是两不搭了🤣。

反复查linux命令权限和troubleshooting,反复试错后终于成功,与俺的WP主机一同运行,CPU占用率基本没啥变化,维持在5-6%。实施步骤如下。

攻略https://guide.v2fly.org/prep/install.html#安装前的准备

先赋予root权限

usr@WP_server:~$ sudo su

安装 curl

root@server:/home/usr# apt install curl


下载安装脚本

root@server:/home/usr# sudo curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh

执行脚本安装V2ray及其输出结果

root@server:/home/usr# sudo bash install-release.sh

info: Installing V2Ray v4.39.2 for x86_64
Downloading V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v4.39.2/v2ray-linux-64.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 626 100 626 0 0 2484 0 --:--:-- --:--:-- --:--:-- 2474
100 12.3M 100 12.3M 0 0 12.0M 0 0:00:01 0:00:01 --:--:-- 12.0M
Downloading verification file for V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v4.39.2/v2ray-linux-64.zip.dgst
info: Extract the V2Ray package to /tmp/tmp.L2IP5rOk7z and prepare it for installation.
rm: cannot remove '/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf': No such file or directory
rm: cannot remove '/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf': No such file or directory
info: Systemd service files have been installed successfully!
warning: The following are the actual parameters for the v2ray service startup.
warning: Please make sure the configuration file path is correctly set.
[Unit]Description=V2Ray Service
Documentation=https://www.v2fly.org/
After=network.target nss-lookup.target[Service]User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json
Restart=on-failure
RestartPreventExitStatus=23[Install]WantedBy=multi-user.target
# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there.
# Or all changes you made will be lost! # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
[Service]ExecStart=
ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json
warning: The systemd version on the current operating system is too low.
warning: Please consider to upgrade the systemd or the operating system.
installed: /usr/local/bin/v2ray
installed: /usr/local/bin/v2ctl
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/config.json
installed: /var/log/v2ray/
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/v2ray@.service
removed: /tmp/tmp.L2IP5rOk7z
info: V2Ray v4.39.2 is installed.
You may need to execute a command to remove dependent software: apt purge curl unzip
Please execute the command: systemctl enable v2ray; systemctl start v2ray

错误warning一堆蛮吓人的哈,不管继续搞,设置config.json,enable,start,status一气呵成

root@server:/home/usr# sudo nano /usr/local/etc/v2ray/config.json
root@server:/home/usr# systemctl enable v2ray
Created symlink /etc/systemd/system/multi-user.target.wants/v2ray.service → /etc/systemd/system/v2ray.service.
root@server:/home/usr# systemctl start v2ray
root@server:/home/usr# systemctl status v2ray


输出如下,大功告成

● v2ray.service - V2Ray Service
Loaded: loaded (/etc/systemd/system/v2ray.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/v2ray.service.d
└─10-donot_touch_single_conf.conf
Active: active (running) since Fri 2021-06-18 17:58:27 CST; 8s ago
Docs: https://www.v2fly.org/
Main PID: 1531 (v2ray)
Tasks: 5 (limit: 1106)
CGroup: /system.slice/v2ray.service
└─1531 /usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json
Jun 18 17:58:27 server systemd[1]: Started V2Ray Service.
Jun 18 17:58:27 server v2ray[1531]: V2Ray 4.39.2 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.16.4
Jun 18 17:58:27 server v2ray[1531]: A unified platform for anti-censorship.
Jun 18 17:58:27 server v2ray[1531]: 2021/06/18 09:58:27 [Info] main/jsonem: Reading config: /usr/local/etc/v2ra
[1]+ Stopped systemctl status v2ray

最后送一个UUID生成器,用户ID就是一个UUID:https://1024tools.com/uuid?

最后是俺抄的config.json,最直白简单的TCP方式

{
  "log": {
  "loglevel": "warning",
  "access": "/var/log/v2ray/access.log", // 这是 Linux 的路径
  "error": "/var/log/v2ray/error.log"
 },
  "inbounds": [{
    "port": xxxx,           //!!! 此处为安装时生成的端口,可修改随意,但是保证和下面提到的端口号相同
    //"listen":"127.0.0.1",  // !!! uncomment for nginx local forwarding
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "a0100cc1-b1f1-4899-9483-4aa73276343e", //!!! 修改为任一合法UUID
          "level": 1,
          "alterId": 64      //此处为安装时生成的 alterId
        }
      ]
    },
    "streamSettings": {
	    "network": "tcp"
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      }
    ]
  }
}


CC BY-NC-SA 4.0 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.