服务器
在终端(黑框框)输入如下命令:
1
| bash <(curl -sL https://raw.githubusercontent.com/hijkpw/scripts/master/centos_install_v2ray.sh)
|
成功后输出:
1 2 3 4 5 6 7 8 9 10
| v2ray运行状态:正在运行 v2ray配置文件:/etc/v2ray/config.json
v2ray配置信息: IP(address): 104.156.227.241 端口(port):8888 id(uuid):d71a4507-5d29-452e-81d0-235e89a1868b 额外id(alterid): 60 加密方式(security): auto 传输协议(network): tcp
|
防火墙
1 2 3 4 5
| firewall-cmd --permanent --add-port=8888/tcp firewall-cmd --reload iptables -I INPUT -p tcp --dport 23581 -j ACCEPT
systemctl enable v2ray
|
ss -ntlp | grep v2ray
命令可以查看v2ray是否正在运行。如果输出为空,大概率是被selinux限制了,解决办法如下:
- 禁用selinux:
setenforce 0
;
- 重启v2ray:
systemctl restart v2ray
服务器的 /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 35 36 37 38
| { "log": { "loglevel": "info", "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log" }, "inbounds": [{ "port": 8888, "protocol": "vmess", "settings": { "clients": [ { "id": "d71a4507-5d29-452e-81d0-235e89a1868b", "level": 1, "alterId": 60 } ] } }], "outbounds": [{ "protocol": "freedom", "settings": {} },{ "protocol": "blackhole", "settings": {}, "tag": "blocked" }], "routing": { "rules": [ { "type": "field", "ip": ["geoip:private"], "outboundTag": "blocked" } ] } }
|
\1. 查看v2ray配置/运行状态:bash <(curl -sL https://raw.githubusercontent.com/hijkpw/scripts/master/centos_install_v2ray.sh) info
;
\2. v2ray管理命令:启动:systemctl start v2ray
,停止:systemctl stop v2ray
,重启:systemctl restart v2ray
;
\3. 更改端口、alterid最简单的办法:重新运行一键脚本;
\4. 更新v2ray到最新版:bash <(curl -L -s https://install.direct/go.sh)
\5. 卸载v2ray: bash <(curl -sL https://raw.githubusercontent.com/hijkpw/scripts/master/centos_install_v2ray.sh) uninstall
客户端
下载地址 https://github.com/v2ray/v2ray-core/tags
1 2
| wget https://install.direct/go.sh
|
go.sh 需要配置地址 LOCAL为对应v2ray-linux64.zip
详细配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| PROXY='' HELP='' FORCE='' CHECK='' REMOVE='' VERSION='' VSRC_ROOT='/tmp/v2ray' EXTRACT_ONLY='' LOCAL='v2ray-linux-64.zip' LOCAL_INSTALL='1' DIST_SRC='github' ERROR_IF_UPTODATE=''
CUR_VER="" NEW_VER="" VDIS='' ZIPFILE="/tmp/v2ray/v2ray.zip" V2RAY_RUNNING=0
|
安装
1 2 3
| sudo bash go.sh or sudo ./go.sh
|
其它令名
1 2 3 4 5 6
| systemctl enable v2ray systemctl start v2ray systemctl stop v2ray
service v2ray start service v2ray stop
|
查看v2ray服务运行端口:
1 2 3
| sudo netstat -tunlp | grep v2ray
sudo ss -tunlp | grep v2ray
|
客户端 /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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| { "inbounds": [ { "port": 1080, "listen": "127.0.0.1", "protocol": "socks", "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] } } ], "outbounds": [ { "tag": "proxy", "protocol": "vmess", "settings": { "vnext": [ { "address": "104.156.227.241", "port": 8888, "users": [ { "alterId": 60, "id": "d71a4507-5d29-452e-81d0-235e89a1868b", "level": 0, "security": "auto" } ] } ] }, "streamSettings": { "network": "tcp", "security": "" } }, { "protocol": "freedom", "settings": {} }, { "protocol": "blackhole", "settings": {}, "tag": "blocked" } ], "routing": { "rules": [ { "type": "field", "ip": [ "geoip:private" ], "outboundTag": "blocked" } ] } }
|
本文地址: https://github.com/maxzhao-it/blog/post/6635/