1. What GeoIP and GeoSite Each Handle
Clash's routing rules don't ship with any built-in geographic or site data. The GEOIP and GEOSITE keywords in a rule are just lookup queries - the actual answers to "which region is this IP in" and "which category is this domain" come from database files sitting in the core's working directory. The core loads these files into memory on startup, and rules query them at match time. If a file is missing or hasn't been updated in a while, routing decisions drift: traffic that should go direct gets proxied, and vice versa.
GeoIP: Judging by IP Location
GeoIP data is essentially a mapping from IP ranges to region codes. When a rule like GEOIP,CN,DIRECT matches, it means the destination IP falls within a mainland China address range, so the connection goes through directly. If the destination is a domain rather than an IP, the core resolves it via DNS first, then checks the database. Adding no-resolve at the end of the rule skips that resolution step - it only applies when the target is already an IP, so you don't end up resolving every domain just to check one rule. mihomo defaults to geoip.metadb (mmdb format); setting geodata-mode to true switches to the v2ray-format geoip.dat instead. Pick one format based on where your rules come from - don't mix them.
GeoSite: Judging by Domain Category
GeoSite data maps domains to category tags, sourced from the community-maintained domain-list-community project and compiled into geosite.dat. Common categories include cn (mainland China sites), geolocation-!cn (common sites outside mainland China), google, github, telegram, and private (LAN and local domains). A single category can cover tens of thousands of domains and keeps growing with community contributions - far less work than hand-writing individual DOMAIN-SUFFIX rules, and less prone to gaps.
Note
GEOSITE rules only match domains and never trigger resolution; GEOIP rules only work with IPs. The two complement each other, and in practice are usually paired: domains get checked against GeoSite first, with GeoIP catching whatever falls through based on IP location.
2. Database Files and Download Sources
mihomo's GEO data files live in the core's working directory, usually alongside config.yaml. Common files include:
| File | Format | Purpose |
|---|---|---|
| geoip.metadb | mmdb | Default IP-to-region database, used when geodata-mode is off |
| geoip.dat | v2ray geodata | IP-to-region database used when geodata-mode is on |
| geosite.dat | v2ray geodata | Domain category database for GEOSITE rules |
| country.mmdb | mmdb | Optional, MaxMind-style country/region database, can replace metadb |
| GeoLite2-ASN.mmdb | mmdb | Optional, used for IP-ASN rules when routing by autonomous system |
The default download source is the Release page of the MetaCubeX/meta-rules-dat repo, rebuilt daily. To point to a different address, use geox-url in your config:
# config.yaml snippet
geox-url:
geoip: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.dat"
geosite: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat"
mmdb: "https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb"
If GitHub is unreliable on your network, swap in a working mirror; leaving a field blank falls back to the default address. On memory-constrained setups, you can also set geodata-loader: memconservative to cut down on the database's resident memory footprint.
3. Update Methods: Manual and Automatic
Automatic Updates
geo-auto-update: true
geo-update-interval: 24
With geo-auto-update turned on, the core checks for and downloads the latest databases at the interval set by geo-update-interval (in hours), hot-loading them once the download finishes - no restart needed. A 24-hour interval is plenty: the community repo rebuilds daily, so checking once a day already keeps you current. Shorter intervals just re-download the same file with no real benefit.
Manual Updates
- Download
geoip.metadb(orgeoip.datin geodata mode) andgeosite.datfrom the release page, keeping the original filenames. - Drop them into the core's working directory: on desktop clients this is usually the core's working folder inside its config directory; for command-line deployments it's typically
~/.config/mihomo/, alongsideconfig.yaml. - Restart the core to load the new files - or click the update-Geo-database button in the dashboard, or call
PUT /configs/geoon the external controller API to have the core re-download and reload immediately.
Heads up
The most common cause of update failures is an unreachable download source. First check whether your network can reach the address in geox-url directly; if not, switch to a mirror or fall back to manual updates. After each update, check the logs to confirm the number of loaded geosite and geoip entries looks right - zero entries or an error usually means a corrupted file, or a mismatch between the file format and your geodata-mode setting.
4. Referencing GEO Data in Rules
The syntax is fixed: GEOSITE,category,policy and GEOIP,region-code,policy, with the latter optionally taking a fourth parameter, no-resolve. Region codes are two-letter, like CN, US, or JP. Common examples:
| Example rule | Meaning |
|---|---|
| GEOSITE,private,DIRECT | Direct connection for LAN and local domains |
| GEOSITE,cn,DIRECT | Direct connection for mainland China sites |
| GEOSITE,geolocation-!cn,PROXY | Proxy for common sites outside mainland China |
| GEOSITE,github,PROXY | Proxy for GitHub-related domains |
| GEOIP,CN,DIRECT,no-resolve | Direct if the target is already an IP in mainland China |
| GEOIP,CN,DIRECT | Resolve the domain first, then direct if it's in mainland China |
Rules are matched top to bottom, stopping at the first hit. Put domain-based rules (GEOSITE, DOMAIN family) before GEOIP: placing GEOIP earlier forces a lot of domain requests through DNS resolution first, slowing down first-byte response and triggering resolutions that could otherwise be skipped. A common closing pattern for "direct in mainland China, proxy elsewhere":
rules:
- GEOSITE,private,DIRECT
- GEOSITE,cn,DIRECT
- GEOSITE,geolocation-!cn,PROXY
- IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
- IP-CIDR,172.16.0.0/12,DIRECT,no-resolve
- IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
- GEOIP,CN,DIRECT,no-resolve
- MATCH,PROXY
What the last two rules mean: if the target is already an IP in mainland China, go direct; everything else goes through the proxy. If you'd rather have "direct once the resolved domain turns out to be in mainland China," drop no-resolve from the GEOIP rule - the tradeoff is that every domain not caught by earlier rules gets resolved once.
For categories with a lot of data, consider switching to rule providers instead. meta-rules-dat also publishes rule sets in mrs format, which you can reference selectively via rule-providers for faster loading and lower memory use:
rule-providers:
geosite-cn:
type: http
behavior: domain
format: mrs
interval: 86400
path: ./ruleset/geosite-cn.mrs
url: "https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/cn.mrs"
rules:
- RULE-SET,geosite-cn,DIRECT
5. FAQ
Do I need both GeoIP and GeoSite enabled?
Not necessarily. If your rules only use GEOIP, you don't need geosite.dat at all; geosite.dat is only required once you have GEOSITE rules. Most routing setups pair the two: domain requests get checked against GeoSite first, with GeoIP catching whatever falls through based on IP location.
What's a good auto-update interval?
24 hours. The community database is rebuilt and released daily, so checking once a day keeps you current enough - shorter intervals just re-download the same file with no real benefit.
Routing behavior didn't change after updating?
Work through this in order: restart the core or reload the config first; make sure the files actually landed in the core's working directory, not your browser's downloads folder; then check the startup logs for the number of loaded geosite and geoip entries - zero entries or an error means a corrupted file, or a mismatch between the file format and your geodata-mode setting.
My subscription config has no geo-related fields - do I need to add them?
It works fine without them; the core downloads the required databases from its default address automatically. Only add geox-url and geo-auto-update to your override or global config if you need a fixed mirror address or a different update interval.
Should I turn on geodata-mode?
It depends on your rule source. If you're only using standard GEOIP/GEOSITE syntax, the default mmdb mode is fine; turn it on only if a rule set or guide you're following specifically requires geoip.dat. Once enabled, geoip.dat must exist, or GEOIP rules will fail to load and the core will error out on startup.
6. Wrap-Up
GeoIP handles IPs, GeoSite handles domains. Get the files in the right directory, make sure the download address is reachable, and order your rules correctly - and routing stays stable. Keep auto-updates running daily, and adjust your rule syntax as the community databases evolve. Clients and cores for every platform are organized in the download center, with setup basics covered in the tutorial.