CentOS 7部署V2Ray服务(更新V2fly)

@20201012 由于V2Ray开发团队内部问题,V2Ray目前由V2fly维护,安装方法有所更新,现将文章更新如下:

1、安装V2Ray服务端

bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

执行完后得到以下内容

info: bsdtar is installed.
info: Extract the V2Ray package to /tmp/tmp.fnu3ajK2Bz 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.
# /etc/systemd/system/v2ray.service
[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

# /etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf
# 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
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.fnu3ajK2Bz
info: V2Ray v4.31.0 is installed.
You may need to execute a command to remove dependent software: dnf remove curl unzip
Please execute the command: systemctl enable v2ray; systemctl start v2ray

新的安装方式相比之前少做了两件事:1、没有配置config文件,2、没有添加系统服务。下面补上

配置文件路径为/usr/local/etc/v2ray/config.json,配置文件参考如下:

{
    "log": {
        "loglevel": "warning"
    },
    "routing": {
        "domainStrategy": "AsIs",
        "rules": [
            {
                "ip": [
                    "geoip:private"
                ],
                "outboundTag": "blocked",
                "type": "field"
            }
        ]
    },
    "inbounds": [
        {
            "port": 1234,  //此处填写自定义端口
            "protocol": "vmess",
            "settings": {
                "clients": [
                    {
                        "id": "", //此处填写UUID
                        "alterId": 4
                    }
                ]
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom"
        },
        {
            "protocol": "blackhole",
            "tag": "blocked"
        }
    ]
}

在安装的时候,提示信息里给了添加系统服务的模板,直接复制即可。创建/etc/systemd/system/v2ray.service文件,内容如下:

# /etc/systemd/system/v2ray.service
[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

启动服务

systemctl start v2ray

 

 

 

以下为原文(20190929):

———————-

由于Shadowsocks在国内被大范围识别封锁,所以转向V2Ray。虽然V2Ray作为一个平台,比起Shadowsocks复杂许多,但是安装部署其实已经集成的非常好。以下是部署步骤:

1、安装V2Ray服务端

bash <(curl -L -s https://install.direct/go.sh)

执行完后得到以下内容

Installing V2Ray v4.20.0 on x86_64
Downloading V2Ray: https://github.com/v2ray/v2ray-core/releases/download/v4.20.0/v2ray-linux-64.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   608    0   608    0     0   1647      0 --:--:-- --:--:-- --:--:--  1652
100 11.3M  100 11.3M    0     0  7368k      0  0:00:01  0:00:01 --:--:-- 11.5M
Updating software repo
Installing unzip
warning: /var/cache/yum/x86_64/7/base/packages/unzip-6.0-20.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for unzip-6.0-20.el7.x86_64.rpm is not installed
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Extracting V2Ray package to /tmp/v2ray.
Archive:  /tmp/v2ray/v2ray.zip
  inflating: /tmp/v2ray/config.json  
   creating: /tmp/v2ray/doc/
  inflating: /tmp/v2ray/doc/readme.md  
  inflating: /tmp/v2ray/geoip.dat    
  inflating: /tmp/v2ray/geosite.dat  
   creating: /tmp/v2ray/systemd/
  inflating: /tmp/v2ray/systemd/v2ray.service  
   creating: /tmp/v2ray/systemv/
  inflating: /tmp/v2ray/systemv/v2ray  
  inflating: /tmp/v2ray/v2ctl        
 extracting: /tmp/v2ray/v2ctl.sig    
  inflating: /tmp/v2ray/v2ray        
 extracting: /tmp/v2ray/v2ray.sig    
  inflating: /tmp/v2ray/vpoint_socks_vmess.json  
  inflating: /tmp/v2ray/vpoint_vmess_freedom.json  
PORT:38731
UUID:c877a768-946e-4bea-93ff-d44a5a5b3915
Created symlink from /etc/systemd/system/multi-user.target.wants/v2ray.service to /etc/systemd/system/v2ray.service.
V2Ray v4.20.0 is installed.

以上信息中,有两项需要记下:UUIDPORT

启动V2Ray服务

systemctl start v2ray
systemctl enable v2ray

由于需要端口通讯,建议将端口加入防火墙白名单。这里只是示范,所以关闭防火墙

iptables -F
systemctl stop firewalld

2、安装Windows客户端

Windows系统客户端可以使用V2RayN,首先去Github上下载最新的release:

将压缩包解压,执行v2rayN.exe即可启动客户端。

启动之后,选择服务器->添加[VMess]服务器,按之前在服务器上得到的UUIDPORT填写

参考:

Project V Official Site: V2Ray

CentOS 7部署V2Ray服务(更新V2fly)》上有5条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注