GeoIP 增强版,自由定制多种格式 GeoIP 文件,包括但不限于 V2Ray dat 格式文件 geoip.dat、MaxMind mmdb 格式文件、sing-box SRS 格式文件、mihomo MRS 格式文件、Clash ruleset、Surge ruleset、Nginx allow
GeoIP 增强版:自由定制多种格式 GeoIP 文件
## 名词解析
**GeoIP**,意为 ***IP geographic location***,即 IP 地址所对应的地理位置信息,例如所属的国家、地区等。GeoIP 数据文件则存储着 IP 地址所对应的地理位置信息。
**GeoIP**, which stands for ***IP geographic location***, refers to the geographic location information associated with an IP address, such as the country or region. And GeoIP data files store the geographic location information corresponding to IP addresses.
## 项目简介
本项目每周四自动生成多种格式 GeoIP 数据文件,同时提供命令行界面(CLI)工具供用户自行定制 GeoIP 数据文件,包括但不限于 V2Ray `dat` 格式文件 `geoip.dat`、MaxMind `mmdb` 格式文件 `Country.mmdb`(GeoIP2-Country.mmdb、GeoLite2-Country.mmdb)、sing-box `SRS` 格式文件、mihomo `MRS` 格式文件、Clash ruleset 规则文件、Surge ruleset 规则文件、Nginx allow list(允许访问列表)和 Nginx deny list(拒绝访问列表)。
This project releases various formats of GeoIP files automatically every Thursday, and provides a command line interface (CLI) tool for users to customize their own GeoIP files, including but not limited to V2Ray `dat` format file `geoip.dat`, MaxMind `mmdb` format file `Country.mmdb`(GeoIP2-Country.mmdb, GeoLite2-Country.mmdb), sing-box `SRS` format file, mihomo `MRS` format file, Clash ruleset file, Surge ruleset file, Nginx allow list and Nginx deny list.
## GeoIP 类别
本项目默认使用 [MaxMind GeoLite2 Country CSV 数据](https://github.com/Loyalsoldier/geoip/blob/release/GeoLite2-Country-CSV.zip)生成各个国家和地区的 GeoIP 文件。类别有:
- `geoip:cn`(`GEOIP,CN`):**中国大陆**(Mainland China)
- `geoip:hk`(`GEOIP,HK`):**香港**(Hong Kong)
- `geoip:mo`(`GEOIP,MO`):**澳门**(Macau)
- `geoip:tw`(`GEOIP,TW`):**台湾**(Taiwan)
- `geoip:us`(`GEOIP,US`):**美国**(America)
- `geoip:jp`(`GEOIP,JP`):**日本**(Japan)
- `geoip:kr`(`GEOIP,KR`):**韩国**(Korea)
- `geoip:sg`(`GEOIP,SG`):**新加坡**(Singapore)
- `geoip:mm`(`GEOIP,MM`):**缅甸**(Myanmar)
- `geoip:ir`(`GEOIP,IR`):**伊朗**(Iran)
- `geoip:ru`(`GEOIP,RU`):**俄罗斯**(Russia)
- `geoip:by`(`GEOIP,BY`):**白俄罗斯**(Belarus)
- `geoip:tm`(`GEOIP,TM`):**土库曼斯坦**(Turkmenistan)
- `geoip:private`(`GEOIP,PRIVATE`):**内网 IP 地址**、**保留 IP 地址**等特殊 IP 地址的集合
- 更多可用的类别(以两位英文字母表示国家或地区),请查看:[https://www.iban.com/country-codes](https://www.iban.com/country-codes)
### 与 MaxMind 官方 GeoIP 数据的区别
本项目对 MaxMind 官方 GeoIP 数据做了如下**修改**和**新增**:
- 中国大陆 IPv4 地址数据使用 [@gaoyifan/china-operator-ip](https://github.com/gaoyifan/china-operator-ip/blob/ip-lists/china.txt)
- 中国大陆 IPv6 地址数据使用 [@gaoyifan/china-operator-ip](https://github.com/gaoyifan/china-operator-ip/blob/ip-lists/china6.txt)
- 新增类别(方便有特殊需求的用户使用):
- `geoip:cloudflare`(`GEOIP,CLOUDFLARE`)
- `geoip:cloudfront`(`GEOIP,CLOUDFRONT`)
- `geoip:facebook`(`GEOIP,FACEBOOK`)
- `geoip:fastly`(`GEOIP,FASTLY`)
- `geoip:google`(`GEOIP,GOOGLE`)
- `geoip:netflix`(`GEOIP,NETFLIX`)
- `geoip:telegram`(`GEOIP,TELEGRAM`)
- `geoip:twitter`(`GEOIP,TWITTER`)
- `geoip:tor`(`GEOIP,TOR`)
## 下载地址与使用方法
> [!NOTE]
> 如果无法访问域名 `raw.githubusercontent.com`,可以使用第二个地址 `cdn.jsdelivr.net`。
> 如果无法访问域名 `cdn.jsdelivr.net`,可以将其替换为 `fastly.jsdelivr.net`。
>
> *.sha256sum 为校验文件。
本项目发布的所有 GeoIP 文件,请查看 [release 分支](https://github.com/Loyalsoldier/geoip/tree/release)。以下是部分格式 GeoIP 文件的下载地址和使用方法:
### V2Ray dat 使用方法
点击查看在
V2Ray 和
Xray-core 中的使用方法
需要先下载 .dat 格式文件,并放置在程序目录内。
```json
"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 中的使用方法
```yaml
geodata-mode: true
geox-url:
geoip: "https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip.dat"
```
点击查看在
hysteria 中的使用方法
需要先下载 .dat 格式文件,并放置在 hysteria 程序目录内。
```
direct(geoip:cn)
proxy(geoip:telegram)
proxy(geoip:us)
```
点击查看在
Trojan-Go 中的使用方法
需要先下载 .dat 格式文件,并放置在 Trojan-Go 程序目录内。
```json
"router": {
"enabled": true,
"bypass": ["geoip:cn"],
"proxy": ["geoip:telegram", "geoip:us"],
"block": ["geoip:jp"],
"default_policy": "proxy",
"geoip": "./geoip.dat"
}
```
点击查看在
dae 中的使用方法
点击前往查看:[《吃鹅直通手册》](https://github.com/daeuniverse/dae/blob/main/docs/zh/README.md)
---
### V2Ray dat 下载地址
> 适用于 [V2Ray](https://github.com/v2fly/v2ray-core)、[Xray-core](https://github.com/XTLS/Xray-core)、[mihomo](https://github.com/MetaCubeX/mihomo/tree/Meta)、[hysteria](https://github.com/apernet/hysteria)、[Trojan-Go](https://github.com/p4gefau1t/trojan-go)、[dae](https://github.com/daeuniverse/dae)。
> 此 dat 格式文件不能用于 Nginx。
所有**国家/地区**、**新增类别**的 dat 格式文件,请查看本项目 `release` 分支下的 [dat 目录](https://github.com/Loyalsoldier/geoip/tree/release/dat)。
- **geoip.dat**:
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip.dat)
- **geoip.dat.sha256sum**:
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip.dat.sha256sum](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip.dat.sha256sum)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip.dat.sha256sum](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip.dat.sha256sum)
- **geoip-only-cn-private.dat**(精简版 GeoIP,只包含 `geoip:cn` 和 `geoip:private`):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-only-cn-private.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-only-cn-private.dat)
- **geoip-only-cn-private.dat.sha256sum**:
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat.sha256sum](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat.sha256sum)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-only-cn-private.dat.sha256sum](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-only-cn-private.dat.sha256sum)
- **geoip-asn.dat**(精简版 GeoIP,只包含上述新增类别):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-asn.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-asn.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-asn.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-asn.dat)
- **geoip-asn.dat.sha256sum**:
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-asn.dat.sha256sum](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-asn.dat.sha256sum)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-asn.dat.sha256sum](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/geoip-asn.dat.sha256sum)
- **cn.dat**(精简版 GeoIP,只包含 `geoip:cn`):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/cn.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/cn.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/cn.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/cn.dat)
- **cn.dat.sha256sum**:
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/cn.dat.sha256sum](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/cn.dat.sha256sum)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/cn.dat.sha256sum](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/cn.dat.sha256sum)
- **private.dat**(精简版 GeoIP,只包含 `geoip:private`):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/private.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/private.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/private.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/private.dat)
- **private.dat.sha256sum**:
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/private.dat.sha256sum](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/private.dat.sha256sum)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/private.dat.sha256sum](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/private.dat.sha256sum)
部分**国家/地区**类别:
- **中国大陆**(Mainland China):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/cn.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/cn.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/cn.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/cn.dat)
- **香港**(Hong Kong):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/hk.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/hk.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/hk.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/hk.dat)
- **澳门**(Macau):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/mo.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/mo.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/mo.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/mo.dat)
- **台湾**(Taiwan):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/tw.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/tw.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/tw.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/tw.dat)
- **美国**(America):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/us.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/us.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/us.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/us.dat)
- **日本**(Japan):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/jp.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/jp.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/jp.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/jp.dat)
- **韩国**(Korea):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/kr.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/kr.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/kr.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/kr.dat)
- **新加坡**(Singapore):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/sg.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/sg.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/sg.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/sg.dat)
- **缅甸**(Myanmar):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/mm.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/mm.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/mm.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/mm.dat)
- **伊朗**(Iran):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/ir.dat](https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/ir.dat)
- [https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/ir.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/geoip@release/dat/ir.dat)
- **俄罗斯**(Russia):
- [https://raw.githubusercontent.com/Loyalsoldier/geoip/release/dat/ru.dat](http