Skip to content

Instantly share code, notes, and snippets.

@imbyc
Last active January 18, 2023 09:47
Show Gist options
  • Save imbyc/2cbae071f580e71ff055cde19efc39c4 to your computer and use it in GitHub Desktop.
Save imbyc/2cbae071f580e71ff055cde19efc39c4 to your computer and use it in GitHub Desktop.
[Qv2ray 配置文件]

Qv2ray-default-route-config.json 为默认路由规则,可以在首选项-高级路由设置 中导入

Qv2ray.conf 为 Qv2ray 配置文件

我们一直在使用的客户端v2rayN从3.29之后(不包括),抛弃原有的PAC规则,如果你一不小心升级到4.x版本,发现代理不正常了,是很正常的情况

PAC大概的规则是:默认不走代理,如果在pac.txt列表里的域名就会走代理。

而在v2ray中有3个东西:Inbounds、Outbounds、Routing

分别为入站,出站,路由,一个请求经过入站-> 路由-> 出站 的过程

这3个东西都可以定义多个,然后组合起来就可以达到更高级的效果,如屏蔽广告,负载均衡,不同的域名走不同代理(如github.com走香港,而访问google.com走日本),某些端口走代理而某些不走代理,甚至是TCP协议走代理而UDP协议不走代理,等等

图片来源:v2ray.com官网

虽然更灵活,但也许你用不到,或者说门槛更高了,

v2ray最开始的仓库是:https://github.com/v2ray/v2ray-core

而现在大部分下载使用的是: https://github.com/v2fly/v2ray-core

一个是v2ray一个是v2fly,是因为V2Ray 项目创始人Victoria Raymond消失了,开源社区创建了新的组织v2fly,原仓库v2ray/v2ray-core还会同步更新,但新仓库更快,所以现在基本都使用v2fly/v2ray-core,可以看到v2ray/v2ray-core仓库star数量更高,且介绍一样就是这个原因,并不是盗版哦。

不同的官网:https://www.v2ray.com/

https://www.v2fly.org/

v2ray是命令行工具,有自己的配置文件,配置文档

而我们使用的客户端实际上基本都是在配置v2ray的配置文件。

客户端为了更方便使用,默认情况下都不需要你设置什么Inbounds、Outbounds,只要设置Routing就可以了,并且默认就是三种:直连,代理,阻止(拦截),一般使用英文:Direct ,Proxy,Reject(或者Block)

如V2rayN中你打开设置 -> 路由设置,不启用路由高级功能,就只有3个框框

代理,直连和阻止,然后分别按域名和ip设置。

你可以看到诸如: geosite:googlegeosite:cngeoip:privategeoip:cngeosite:category-ads-all

这些是预先整理好的一些域名和地址规则。

我们通常走代理有个基本规则,大陆域名不走,国外域名走,或者说被屏蔽的域名走,如果全靠整理域名那太多了,所以换一个思路,域名最终要被解析为IP,根据IP地址库是可以判断出IP是属于哪个区域,而这个地址库就是geoip,开源仓库:v2fly/geoip

另外对于很多网站并不止包含一个域名,如github包含很多域名

github.com

github.io

githubusercontent.com 从release中下载文件下载不动就应该吧这个添加进去

这些域名也整理了,做成了geosite,开源仓库:v2fly/domain-list-community 其中data目录就是社区贡献的域名整理

v2ray-core会使用这两个仓库自动生成geoip.datgepsite.dat并包含在发行版中,构建脚本

而现在国内使用较多的是增强版本 Loyalsoldier/v2ray-rules-dat

包含了两个仓库: Loyalsoldier/geoipLoyalsoldier/domain-list-custom

推荐的用法是使用增强版Loyalsoldier/v2ray-rules-dat下载这2个文件,去覆盖v2ray-core自带的geoip.datgepsite.dat

v2rayN在程序的根目录有这2个文件,并勾选上更新Core时忽略Geo文件,防止更新v2fly-core时将geoip.datgepsite.dat又覆盖了。

所以V2rayN简单配置可以在这样设置(不启用高级路由特性):

解析策略为IPIfNonMatch

代理:

域名:

geosite:geolocation-!cn, geosite:category-dev

直连:

域名:

geosite:private, geosite:apple-cn, geosite:google-cn, geosite:tld-cn, geosite:category-games@cn, geosite:cn

IP:

geoip:cn, geoip:private

阻止:

域名:

geosite:category-ads-all

记得勾选系统代理-> 自动配置系统代理 ,图标变成红色

未完。。。

更高级的效果:

新 V2Ray 白话文指南

{
"dns": {
"servers": [
]
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 10809,
"protocol": "http",
"settings": {
"allowTransparent": true,
"timeout": 300
},
"sniffing": {
"destOverride": [
"http",
"tls"
],
"enabled": true
},
"tag": "GlobalConfig-HTTP"
},
{
"listen": "127.0.0.1",
"port": 10808,
"protocol": "socks",
"settings": {
"auth": "noauth",
"ip": "127.0.0.1",
"udp": true
},
"sniffing": {
"destOverride": [
"http",
"tls"
],
"enabled": true
},
"tag": "GlobalConfig-Socks"
}
],
"outbounds": [
{
"QV2RAY_OUTBOUND_METADATA": {
"displayName": "Freedom_65103250"
},
"mux": {
},
"protocol": "freedom",
"sendThrough": "0.0.0.0",
"settings": {
"domainStrategy": "AsIs",
"redirect": ""
},
"streamSettings": {
},
"tag": "DIRECT"
},
{
"QV2RAY_OUTBOUND_METADATA": {
"displayName": "BlackHole-65099597"
},
"mux": {
},
"protocol": "blackhole",
"sendThrough": "0.0.0.0",
"settings": {
"response": {
"type": "none"
}
},
"streamSettings": {
},
"tag": "REJECT"
},
{
"QV2RAY_OUTBOUND_METADATA": {
"displayName": "🇭🇰 香港 | 06 | T3"
},
"mux": {
},
"protocol": "vmess",
"sendThrough": "0.0.0.0",
"settings": {
"vnext": [
{
"address": "t3.b2cloud.xyz",
"port": 11105,
"users": [
{
"alterId": 2,
"id": "298294bf-ad5f-34b5-a8f4-3a945be2c7ec"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"tlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
},
"wsSettings": {
"headers": {
"Host": "hkt4.b2cloud.xyz"
},
"path": "/v2ray"
},
"xtlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
}
},
"tag": "🇭🇰 香港 | 06 | T3"
},
{
"QV2RAY_OUTBOUND_METADATA": {
"displayName": "🇭🇰 香港 | 07 | U4"
},
"mux": {
},
"protocol": "vmess",
"sendThrough": "0.0.0.0",
"settings": {
"vnext": [
{
"address": "u4.b2cloud.xyz",
"port": 3106,
"users": [
{
"alterId": 2,
"id": "298294bf-ad5f-34b5-a8f4-3a945be2c7ec"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"tlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
},
"wsSettings": {
"headers": {
"Host": "hk07.b2cloud.xyz"
},
"path": "/v2ray"
},
"xtlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
}
},
"tag": "🇭🇰 香港 | 07 | U4"
},
{
"QV2RAY_OUTBOUND_METADATA": {
"displayName": "🇭🇰 香港 | 08 | T2"
},
"mux": {
},
"protocol": "vmess",
"sendThrough": "0.0.0.0",
"settings": {
"vnext": [
{
"address": "t2.b2cloud.xyz",
"port": 11104,
"users": [
{
"alterId": 2,
"id": "298294bf-ad5f-34b5-a8f4-3a945be2c7ec"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"tlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
},
"wsSettings": {
"headers": {
"Host": "hk08.b2cloud.xyz"
},
"path": "/v2ray"
},
"xtlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
}
},
"tag": "🇭🇰 香港 | 08 | T2"
},
{
"QV2RAY_OUTBOUND_METADATA": {
"displayName": "🇯🇵 日本 | 04 | U4"
},
"mux": {
},
"protocol": "vmess",
"sendThrough": "0.0.0.0",
"settings": {
"vnext": [
{
"address": "u4.b2cloud.xyz",
"port": 1031,
"users": [
{
"alterId": 2,
"id": "298294bf-ad5f-34b5-a8f4-3a945be2c7ec"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"tlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
},
"wsSettings": {
"headers": {
"Host": "jp4.b2cloud.xyz"
},
"path": "/v2ray"
},
"xtlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
}
},
"tag": "🇯🇵 日本 | 04 | U4"
},
{
"QV2RAY_OUTBOUND_METADATA": {
"displayName": "🇯🇵 日本 | 05 | U2"
},
"mux": {
},
"protocol": "vmess",
"sendThrough": "0.0.0.0",
"settings": {
"vnext": [
{
"address": "u2.b2cloud.xyz",
"port": 1032,
"users": [
{
"alterId": 2,
"id": "298294bf-ad5f-34b5-a8f4-3a945be2c7ec"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"tlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
},
"wsSettings": {
"headers": {
"Host": "jp51.b2cloud.xyz"
},
"path": "/v2ray"
},
"xtlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
}
},
"tag": "🇯🇵 日本 | 05 | U2"
},
{
"QV2RAY_OUTBOUND_METADATA": {
"displayName": "🇯🇵 日本 | 06 | U3"
},
"mux": {
},
"protocol": "vmess",
"sendThrough": "0.0.0.0",
"settings": {
"vnext": [
{
"address": "u3.b2cloud.xyz",
"port": 1033,
"users": [
{
"alterId": 2,
"id": "298294bf-ad5f-34b5-a8f4-3a945be2c7ec"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"tlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
},
"wsSettings": {
"headers": {
"Host": "jp6.b2cloud.xyz"
},
"path": "/v2ray"
},
"xtlsSettings": {
"allowInsecure": false,
"disableSessionResumption": true,
"disableSystemRoot": false
}
},
"tag": "🇯🇵 日本 | 06 | U3"
}
],
"routing": {
"balancers": [
{
"selector": [
"🇭🇰 香港 | 06 | T3",
"🇭🇰 香港 | 07 | U4",
"🇭🇰 香港 | 08 | T2"
],
"tag": "HK"
},
{
"selector": [
"🇯🇵 日本 | 04 | U4",
"🇯🇵 日本 | 05 | U2",
"🇯🇵 日本 | 06 | U3"
],
"tag": "JP"
}
],
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"QV2RAY_RULE_ENABLED": true,
"QV2RAY_RULE_TAG": "BT下载走直连",
"outboundTag": "DIRECT",
"protocol": [
"bittorrent"
],
"type": "field"
},
{
"QV2RAY_RULE_ENABLED": true,
"QV2RAY_RULE_TAG": "屏蔽广告",
"domain": [
"geosite:category-ads-all"
],
"outboundTag": "REJECT",
"type": "field"
},
{
"QV2RAY_RULE_ENABLED": true,
"QV2RAY_RULE_TAG": "域名走代理",
"balancerTag": "HK",
"domain": [
"domain:icloud-content.com",
"full:www.icloud.com",
"geosite:category-dev",
"geosite:geolocation-!cn"
],
"type": "field"
},
{
"QV2RAY_RULE_ENABLED": true,
"QV2RAY_RULE_TAG": "域名直连",
"domain": [
"geosite:category-games@cn",
"geosite:cn",
"geosite:icloud",
"geosite:private",
"geosite:tld-cn"
],
"outboundTag": "DIRECT",
"type": "field"
},
{
"QV2RAY_RULE_ENABLED": true,
"QV2RAY_RULE_TAG": "IP直连",
"ip": [
"geoip:cn",
"geoip:private"
],
"outboundTag": "DIRECT",
"type": "field"
},
{
"QV2RAY_RULE_ENABLED": true,
"QV2RAY_RULE_TAG": "默认全部走代理",
"balancerTag": "JP",
"network": "udp,tcp",
"protocol": [
"tls",
"http"
],
"type": "field"
}
]
}
}
{
"author": "byc <[email protected]>",
"description": "Qv2ray默认路由设置",
"domainStrategy": "IPIfNonMatch",
"domains": {
"block": [
"geosite:category-ads-all"
],
"direct": [
"geosite:tld-cn",
"geosite:icloud",
"geosite:category-games@cn",
"geosite:cn",
"geosite:private"
],
"proxy": [
"full:www.icloud.com",
"domain:icloud-content.com",
"geosite:geolocation-!cn",
"geosite:category-dev"
]
},
"ips": {
"direct": [
"geoip:cn",
"geoip:private"
]
},
"name": "Qv2ray默认路由设置"
}
{
"advancedConfig": {
},
"autoStartBehavior": 2,
"autoStartId": {
"groupId": "000000000000"
},
"config_version": 14,
"defaultRouteConfig": {
"connectionConfig": {
"bypassBT": true
},
"dnsConfig": {
"servers": [
{
"address": "1.1.1.1"
},
{
"address": "8.8.8.8"
},
{
"address": "8.8.4.4"
}
]
},
"forwardProxyConfig": {
"port": 0
},
"routeConfig": {
"domainStrategy": "IPIfNonMatch",
"domains": {
"block": [
"geosite:category-ads-all"
],
"direct": [
"geosite:tld-cn",
"geosite:icloud",
"geosite:category-games@cn",
"geosite:cn",
"geosite:private"
],
"proxy": [
"full:www.icloud.com",
"domain:icloud-content.com",
"geosite:geolocation-!cn",
"geosite:category-dev"
]
},
"ips": {
"direct": [
"geoip:cn",
"geoip:private"
]
}
}
},
"inboundConfig": {
"httpSettings": {
"port": 10809,
"sniffing": true
},
"socksSettings": {
"port": 10808,
"sniffing": true
}
},
"kernelConfig": {
"enableAPI": false,
"v2AssetsPath_win": "D:/proxy/Qv2ray/config/v2fly-core",
"v2CorePath_win": "D:/proxy/Qv2ray/config/v2fly-core/v2ray.exe"
},
"lastConnectedId": {
"connectionId": "fbivycknlezm",
"groupId": "000000000000"
},
"logLevel": 3,
"networkConfig": {
"latencyTestingMethod": 1,
"userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0"
},
"outboundConfig": {
},
"pluginConfig": {
"pluginStates": {
"builtin_subscription_support": true,
"qvplugin_builtin_protocol": true
}
},
"uiConfig": {
"graphConfig": {
"colorConfig": {
"$0": {
"value1": {
"B": 63,
"G": 196,
"R": 134
},
"value2": {
"B": 255,
"G": 153,
"R": 50
}
},
"$1": {
"value1": {
"B": 63,
"G": 196,
"R": 134
},
"value2": {
"B": 255,
"G": 153,
"R": 50
}
},
"$2": {
"value1": {
"B": 240,
"G": 210,
"R": 0,
"style": 3
},
"value2": {
"B": 42,
"G": 220,
"R": 235,
"style": 3
}
}
},
"hasDirectStats": false
},
"language": "zh_CN",
"quietMode": true,
"recentConnections": [
{
"connectionId": "fbivycknlezm",
"groupId": "000000000000"
},
{
"connectionId": "nkyugjjbqxtj",
"groupId": "000000000000"
},
{
"connectionId": "sleztmoxvouz",
"groupId": "000000000000"
},
{
"connectionId": "chrjpbiqcdbo",
"groupId": "000000000000"
}
],
"theme": "Built-in Darkmode",
"useDarkTheme": true,
"useDarkTrayIcon": true
},
"updateConfig": {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment