V2Ray 使用教程 2022
上一篇的V2Ray是2017年写的,至今已经5年了,V2Ray有很多不一样的地方,决定重新写一篇文章
V2Ray是什么
V2Ray经过这几年发展,已经成为安全的代名词了,接下来介绍下最新版本的v2ray如何安装。
V2Ray官方网站
V2Ray-Github
服务端搭建过程
- 国外的免费vps路子已经不行了,
- 国内付费也得靠运气了
- 阿里云的轻量应用服务器ip大部分不能用,可以优先选择ecs,1核0.5G,流量按照使用付费,一个月大概40左右
- 腾讯云目的
轻量应用服务器
,在大量封禁账号,我的因为特征明显,账号都被腾讯云封禁了,如果不做伪装,不要选择腾讯。,
登录 vps 自动执行安装脚本
运行以上命令需要root权限,所以需要切换到root账户下,也可以使用sudo
命令
1
| bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
|
该脚本会自动安装以下两个文件:
1 2
| /usr/bin/v2ray/v2ray:V2Ray 程序; /usr/local/etc/v2ray/config.json:配置文件;
|
官方说明:此脚本会配置开机自动运行脚本,仅适用于 SysV 模式,不支持 Debian 7 的 systemd。
V2Ray配置
编辑 /usr/local/etc/v2ray/config.json 文件来配置代理方式,这里给出新的配置,是最近3年来我绝得最稳定的配置
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 63 64 65 66
| { "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", "loglevel": "info" }, "inbounds": [ { "protocol": "vmess", "port": 443, "settings": { "clients": [ { "id": "uuid", "level": 1, "alterId": 16, "security": "auto" } ] } }, { "protocol": "shadowsocks", "port": 3389, "settings": { "method": "aes-256-gcm", "password": "password", "udp": true } } ], "outbounds": [ { "protocol": "freedom", "settings": {} } ], "routing": { "strategy": "rules", "settings": { "rules": [ { "type": "field", "ip": [ "0.0.0.0/8", "10.0.0.0/8", "100.64.0.0/10", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.2.0/24", "192.168.0.0/16", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "::1/128", "fc00::/7", "fe80::/10" ], "outboundTag": "blocked" } ] } } }
|
ss端口我试过很多,什么3001-3033、10086这些非系统流量端口总是被封tcp流量,换成3389之后就没有这个问题了。
国内服务器转发
安装最新发行的 geoip.dat 和 geosite.dat
1
| bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh)
|
转发配置
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| { "log" : { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", "loglevel": "info" }, "inbounds": [ { "protocol": "vmess", "port": 4443, "settings": { "clients": [ { "id": "25f8fa73-9468-4b6a-...", "level": 1, "alterId": 16, "security": "auto" } ] } }, { "protocol": "shadowsocks", "port": 80, "settings": { "method": "aes-256-cfb", "password": "123456", "udp": true } } ], "outbounds": [ { "protocol": "freedom", "settings": {} }, { "protocol": "shadowsocks", "settings": { "servers": [ { "address": "国外VPS IP", "port": 3389, "method": "aes-256-cfb", "password": "123456", "level": 0 } ] }, "tag": "test" } ], "routing": { "domainStrategy": "IPIfNonMatch", "rules": [ { "type": "field", "ip": [ "geoip:private", "geoip:cn" ], "outboundTag": "blocked" }, { "type": "field", "domain": [ "ext:gfw.dat:gfw", "geosite:google", "geosite:geolocation-!cn" ], "network": "tcp,udp", "user": [ "[email protected]" ], "outboundTag": "test" } ] } }
|
V2Ray启动说明
运行 service v2ray start
来启动 V2Ray 进程
service v2ray 方法 |
功能描述 |
start |
启动 V2Ray |
stop |
停止 V2Ray |
status |
查看 V2Ray 启动信息 |
reload |
重新加载 V2Ray 配置信息 |
restart |
重新启动 V2Ray |
force-reload |
强制重新加载 V2Ray 配置信息 |
客户端
官方网站上有丰富的 GUI 客户端:
V2Ray 客户端列表
Clash配置
我自己选择的是Clash
,主要是看中它支持的格式多,管理方便,并且开源免费。
缺点也是有多,就是配置复杂,所以Clash的配置大家可以参考下:
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
|
mixed-port: 7890
allow-lan: true
# authentication: null
mode: Rule
log-level: info
external-controller: 127.0.0.1:9090
dns: enable: false listen: 0.0.0.0:53 default-nameserver: - 119.29.29.29 - 223.5.5.5 - 1.1.1.1 enhanced-mode: fake-ip fake-ip-range: 198.18.0.1/16 fake-ip-filter: - '*.lan' - 'swscan.apple.com' - 'mesu.apple.com' - '*.msftconnecttest.com' - '*.msftncsi.com' - '+.music.163.com' - '*.126.net' - 'musicapi.taihe.com' - 'music.taihe.com' - 'songsearch.kugou.com' - 'trackercdn.kugou.com' - '*.kuwo.cn' - 'api-jooxtt.sanook.com' - 'api.joox.com' - 'joox.com' - '+.y.qq.com' - '+.music.tc.qq.com' - 'aqqmusic.tc.qq.com' - '+.stream.qqmusic.qq.com' - '*.xiami.com' - '+.music.migu.cn' - '+.srv.nintendo.net' - '+.stun.playstation.net' - 'xbox.*.microsoft.com' - '+.xboxlive.com' - 'localhost.ptlogin2.qq.com' - 'proxy.golang.org' - 'stun.*.*' - 'stun.*.*.*'
nameserver: - 119.29.29.29 - 223.5.5.5 fallback: - 1.1.1.1 - 8.8.8.8
fallback-filter: geoip: true geoip-code: CN ipcidr: - 240.0.0.0/4 - 0.0.0.0/32
proxies: - name: v2ray规则 server: 你的服务器ip地址 type: vmess port: 443(你配置的端口) uuid: uuid(你配置的uuid) alterId: 0 cipher: auto - name: shadowsocks规则 server: 你的服务器ip地址 type: ss port: 3389(你配置的端口) cipher: aes-256-gcm password: password(你配置的密码) udp: true - name: trojan规则(可以自定义) server: example.com(你配置的域名) type: trojan port: 443 (你配置的端口) password: password(你配置的密码)
proxy-groups: - name: Proxy type: select proxies: - v2ray规则 - shadowsocks规则 - trojan规则
rule-providers: reject: type: http behavior: domain url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/reject.txt' path: ./ruleset/reject.yaml interval: 86400
icloud: type: http behavior: domain url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/icloud.txt' path: ./ruleset/icloud.yaml interval: 86400
apple: type: http behavior: domain url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/apple.txt' path: ./ruleset/apple.yaml interval: 86400
google: type: http behavior: domain url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/google.txt' path: ./ruleset/google.yaml interval: 86400
proxy: type: http behavior: domain url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/proxy.txt' path: ./ruleset/proxy.yaml interval: 86400
direct: type: http behavior: domain url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/direct.txt' path: ./ruleset/direct.yaml interval: 86400
private: type: http behavior: domain url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/private.txt' path: ./ruleset/private.yaml interval: 86400
gfw: type: http behavior: domain url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/gfw.txt' path: ./ruleset/gfw.yaml interval: 86400
greatfire: type: http behavior: domain url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/greatfire.txt' path: ./ruleset/greatfire.yaml interval: 86400
tld-not-cn: type: http behavior: domain url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/tld-not-cn.txt' path: ./ruleset/tld-not-cn.yaml interval: 86400
telegramcidr: type: http behavior: ipcidr url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/telegramcidr.txt' path: ./ruleset/telegramcidr.yaml interval: 86400
cncidr: type: http behavior: ipcidr url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/cncidr.txt' path: ./ruleset/cncidr.yaml interval: 86400
lancidr: type: http behavior: ipcidr url: 'https://cdn.jsdelivr.net/gh/Loyalsoldier/clash-rules@release/lancidr.txt' path: ./ruleset/lancidr.yaml interval: 86400
youjia: type: http behavior: ipcidr url: 'https://redtom-proxy.oss-cn-beijing.aliyuncs.com/clash_config/youjia.txt' path: ./ruleset/youjia.yaml interval: 86400
rules: - PROCESS-NAME,iTerm2,Proxy - PROCESS-NAME,Code,Proxy - DOMAIN-SUFFIX,gsmarena.com,Proxy - DOMAIN-SUFFIX,tiktok.com,Proxy - DOMAIN-SUFFIX,tiktokcdn.com,Proxy - DOMAIN-SUFFIX,tiktokv.com,Proxy
- RULE-SET,reject,REJECT - RULE-SET,gfw,Proxy - RULE-SET,greatfire,Proxy - RULE-SET,tld-not-cn,Proxy - RULE-SET,google,Proxy - RULE-SET,telegramcidr,Proxy - RULE-SET,cncidr,DIRECT - MATCH,DIRECT
|
使用shadowsocks客户端
服务端配置好shadowsocks,使用shadowsocks客户端连接到上面定义的shadowsocks端口3389进行测试上网是否成功。
参考:
V2Ray 使用教程
V2Ray完全配置指南
第三方客户端