v2ray-rules-dat README

The project's README from github.com/Loyalsoldier/v2ray-rules-dat. As one markdown file: README.md.

简介 GitHub Downloads (all assets, all releases) GitHub Downloads (all assets, latest release) jsdelivr stats

V2Ray 路由规则文件加强版,可代替 V2Ray 官方 geoip.dat 和 geosite.dat,适用于 V2Ray、Xray-core、mihomo、hysteria、Trojan-Go、leaf 和所有使用上述内核的图形用户界面(GUI)版代理软件。使用 GitHub Actions 北京时间每天早上 6 点自动构建,保证规则最新。

规则文件生成方式

geoip.dat

希望定制 geoip.dat 文件?需要适用于其他代理软件的 GeoIP 格式文件?查看项目 @Loyalsoldier/geoip。

geosite.dat

规则文件下载地址

如果无法访问域名 raw.githubusercontent.com,可以使用第二个地址 cdn.jsdelivr.net。 如果无法访问域名 cdn.jsdelivr.net,可以将其替换为 fastly.jsdelivr.net。

*.sha256sum 为校验文件。

规则文件使用方式

geoip.dat

点击查看在 V2Ray 和 Xray-core 中的使用方法

需要先下载 geoip.dat 格式文件,并放置在程序目录内。

"routing": {
  "rules": [
    {
      "type": "field",
      "outboundTag": "Direct",
      "ip": [
        "geoip:cn",
        "geoip:private",
        "ext:cn.dat:cn",
        "ext:private.dat:private",
        "ext:geoip-only-cn-private.dat:cn",
        "ext:geoip-only-cn-private.dat:private"
      ]
    },
    {
      "type": "field",
      "outboundTag": "Proxy",
      "ip": [
        "geoip:us",
        "geoip:jp",
        "geoip:facebook",
        "geoip:telegram",
        "ext:geoip-asn.dat:facebook",
        "ext:geoip-asn.dat:telegram"
      ]
    }
  ]
}
点击查看在 mihomo 中的使用方法
geodata-mode: true
geox-url:
  geoip: "https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat"
点击查看在 hysteria 中的使用方法

需要先下载 geoip.dat 格式文件,并放置在 hysteria 程序目录内。

direct(geoip:cn)
proxy(geoip:telegram)
proxy(geoip:us)
点击查看在 Trojan-Go 中的使用方法

需要先下载 geoip.dat 格式文件,并放置在 Trojan-Go 程序目录内。

"router": {
  "enabled": true,
  "bypass": ["geoip:cn"],
  "proxy": ["geoip:telegram", "geoip:us"],
  "block": ["geoip:jp"],
  "default_policy": "proxy",
  "geoip": "./geoip.dat"
}

geosite.dat

跟 V2Ray 官方 geosite.dat 配置方式相同。相比官方 geosite.dat 文件,本项目特有的类别:

⚠️ 注意:在 Routing 配置中,类别越靠前(上),优先级越高,所以 geosite:apple-cn 和 geosite:google-cn 要放置在 geosite:geolocation-!cn 前(上)面才能生效。

高级用法

v2fly/domain-list-community 项目 data 目录中某些列表里的规则会被标记诸如 @cn 的 attribute(如下所示),意为该域名在中国大陆有接入点,可直连。

steampowered.com.8686c.com @cn
steamstatic.com.8686c.com @cn

对于玩 Steam 国区游戏,想要直连的用户,可以设置类别 geosite:steam@cn 为直连,意为将 steam 列表内所有被标记了 @cn attribute 的规则(域名)设置为直连。同理,由于 category-games 列表包含了 steam、ea、blizzard、epicgames 和 nintendo 等常见的游戏厂商。设置类别 geosite:category-games@cn 为直连,即可节省大量服务器流量。

⚠️ 注意:在 Routing 配置中,类别越靠前(上),优先级越高,所以 geosite:category-games@cn 等所有带有 @cn attribute 的规则都要放置在 geosite:geolocation-!cn 前(上)面才能生效。

category-games 列表内的规则(域名)可能会有疏漏,请留意规则命中情况。如发现遗漏,欢迎到项目 v2fly/domain-list-community 提 issue 反馈。

配置参考下面 👇👇👇

白名单模式 Routing 配置方式:

"routing": {
  "rules": [
    {
      "type": "field",
      "outboundTag": "Reject",
      "domain": ["geosite:category-ads-all"]
    },
    {
      "type": "field",
      "outboundTag": "Direct",
      "domain": [
        "geosite:private",
        "geosite:apple-cn",
        "geosite:google-cn",
        "geosite:tld-cn",
        "geosite:category-games@cn"
      ]
    },
    {
      "type": "field",
      "outboundTag": "Proxy",
      "domain": ["geosite:geolocation-!cn"]
    },
    {
      "type": "field",
      "outboundTag": "Direct",
      "domain": ["geosite:cn"]
    },
    {
      "type": "field",
      "outboundTag": "Proxy",
      "network": "tcp,udp"
    }
  ]
}

黑名单模式 Routing 配置方式:

"routing": {
  "rules": [
    {
      "type": "field",
      "outboundTag": "Reject",
      "domain": ["geosite:category-ads-all"]
    },
    {
      "type": "field",
      "outboundTag": "Proxy",
      "domain": ["geosite:gfw"]
    },
    {
      "type": "field",
      "outboundTag": "Proxy",
      "ip": ["geoip:telegram"]
    },
    {
      "type": "field",
      "outboundTag": "Direct",
      "network": "tcp,udp"
    }
  ]
}

DNS 配置方式:

"dns": {
  "hosts": {
    "dns.google": "8.8.8.8",
    "dns.pub": "119.29.29.29",
    "dns.alidns.com": "223.5.5.5",
    "geosite:category-ads-all": "127.0.0.1"
  },
  "servers": [
    {
      "address": "https://1.1.1.1/dns-query",
      "domains": ["geosite:geolocation-!cn"],
      "expectIPs": ["geoip:!cn"]
    },
    "8.8.8.8",
    {
      "address": "114.114.114.114",
      "port": 53,
      "domains": ["geosite:cn", "geosite:category-games@cn"],
      "expectIPs": ["geoip:cn"],
      "skipFallback": true
    },
    {
      "address": "localhost",
      "skipFallback": true
    }
  ]
}

自用 V2Ray v4 版本客户端配置(不适用于 V2Ray v5 及更新的版本)

注意事项:

{
  "log": {
    "loglevel": "warning"
  },
  "dns": {
    "hosts": {
      "dns.google": "8.8.8.8",
      "dns.pub": "119.29.29.29",
      "dns.alidns.com": "223.5.5.5",
      "geosite:category-ads-all": "127.0.0.1"
    },
    "servers": [
      {
        "address": "https://1.1.1.1/dns-query",
        "domains": ["geosite:geolocation-!cn", "geosite:google@cn"],
        "expectIPs": ["geoip:!cn"]
      },
      "8.8.8.8",
      {
        "address": "114.114.114.114",
        "port": 53,
        "domains": [
          "geosite:cn",
          "geosite:icloud",
          "geosite:category-games@cn"
        ],
        "expectIPs": ["geoip:cn"],
        "skipFallback": true
      },
      {
        "address": "localhost",
        "skipFallback": true
      }
    ]
  },
  "inbounds": [
    {
      "protocol": "socks",
      "listen": "0.0.0.0",
      "port": 1080,
      "tag": "Socks-In",
      "settings": {
        "ip": "127.0.0.1",
        "udp": true,
        "auth": "noauth"
      },
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      }
    },
    {
      "protocol": "http",
      "listen": "0.0.0.0",
      "port": 2080,
      "tag": "Http-In",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      }
    }
  ],
  "outbounds": [
    {
      //下面这行,协议类别要改为socks、shadowsocks、vmess或vless等(记得删除本行文字说明)
      "protocol": "协议类别",
      "settings": {},
      //下面这行,tag的值对应Routing里的outboundTag,这里为Proxy(记得删除本行文字说明)
      "tag": "Proxy",
      "streamSettings": {},
      "mux": {}
    },
    {
      "protocol": "dns",
      "tag": "Dns-Out"
    },
    {
      "protocol": "freedom",
      "tag": "Direct",
      "settings": {
        "domainStrategy": "UseIPv4"
      }
    },
    {
      "protocol": "blackhole",
      "tag": "Reject",
      "settings": {
        "response": {
          "type": "http"
        }
      }
    }
  ],
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "domainMatcher": "mph",
    "rules": [
      {
        "type": "field",
        "outboundTag": "Direct",
        "protocol": ["bittorrent"]
      },
      {
        "type": "field",
        "outboundTag": "Dns-Out",
        "inboundTag": ["Socks-In", "Http-In"],
        "network": "udp",
        "port": 53
      },
      {
        "type": "field",
        "outboundTag": "Reject",
        "domain": ["geosite:category-ads-all"]
      },
      {
        "type": "field",
        "outboundTag": "Proxy",
        "domain": [
          "full:www.icloud.com",
          "domain:icloud-content.com",
          "geosite:google"
        ]
      },
      {
        "type": "field",
        "outboundTag": "Direct",
        "domain": [
          "geosite:tld-cn",
          "geosite:icloud",
          "geosite:category-games@cn"
        ]
      },
      {
        "type": "field",
        "outboundTag": "Proxy",
        "domain": ["geosite:geolocation-!cn"]
      },
      {
        "type": "field",
        "outboundTag": "Direct",
        "domain": ["geosite:cn", "geosite:private"]
      },
      {
        "type": "field",
        "outboundTag": "Direct",
        "ip": ["geoip:cn", "geoip:private"]
      },
      {
        "type": "field",
        "outboundTag": "Proxy",
        "network": "tcp,udp"
      }
    ]
  }
}

致谢

v2ray-rules-dat (Loyalsoldier/v2ray-rules-dat)

adguard
Searching Database…

What is this?Enhanced drop-in replacements for the official V2Ray geoip.dat and geosite.dat routing rule files, used by V2Ray, Xray-core, mihomo (Clash-Meta), hysteria, Trojan-Go, leaf and GUI clients on those cores to decide which traffic goes direct, through the proxy, or gets blocked.
So it's data I put into my proxy client, not a program I run?Right — geoip.dat holds IP ranges by country and by service (Google, Netflix, Telegram, Tor and more), while geosite.dat holds categorized domain lists; both go into the proxy program's directory. Plain-text versions of the domain lists are published too.
How do I set it up?Download geoip.dat and geosite.dat from the release links and place them in your proxy client's program directory; geosite.dat configures just like the official file. If raw.githubusercontent.com is unreachable, use the cdn.jsdelivr.net or fastly.jsdelivr.net mirrors and verify against the .sha256sum files.
Do I need a specific proxy client for these files?Any client running the V2Ray, Xray-core, mihomo (Clash-Meta), hysteria, Trojan-Go or leaf core, including GUI apps built on them. The files only supply routing rules — they don't proxy anything themselves. The author's ready-made client config requires V2Ray v4.37.2 or newer, not v5+.
Any gotchas when writing the routing config?Category order matters: geosite:apple-cn, geosite:google-cn and every @cn rule only takes effect when placed above geosite:geolocation-!cn. The win-spy, win-update and win-extra categories are marked use-with-caution.
Is this mainly useful for users in mainland China?Yes — the rule set is built around China routing: mainland IPs and China-accessible domains go direct, GFWList-blocked domains go through the proxy, ads get blocked. The ad-block and big-service IP categories still work for users anywhere.
What do these files add over the official ones?Extra geosite categories and merged sources: GFWList domains (geosite:gfw), ad domains from EasyList China, AdGuard DNS Filter, Peter Lowe and Dan Pollock hosts (all in geosite:category-ads-all), extra geoip categories for Google, Netflix, Telegram, Twitter, Cloudflare and Tor, plus Windows telemetry and update domain lists (win-spy, win-update, win-extra).
How fresh are the rules?Very fresh — GitHub Actions rebuilds all files automatically at 6:00 AM Beijing time every day, so published downloads are at most a day old.
Can I add or exclude my own domains?Yes — the hidden branch carries direct.txt, proxy.txt and reject.txt with custom domains merged into geosite:cn, geosite:geolocation-!cn and geosite:category-ads-all, plus matching need-to-remove files for stripping entries from those lists.
Can I route Steam or game traffic direct to save proxy data?Yes — domains with China access points carry an @cn attribute; setting geosite:steam@cn or geosite:category-games@cn (Steam, EA, Blizzard, Epic Games, Nintendo) to direct saves a lot of server traffic. The games list can miss domains, so check what it catches.
Size
18 MB
Stars
20.9K
Age
6y
Commits · 90 Days