Advanced Config 8 min read

GeoIP and GeoSite Databases: Updates, Download URLs, and Rule Syntax

Learn what GeoIP and GeoSite data files do, how to configure manual and automatic updates, and how to reference them correctly in rules.

GeoIP matches destination IPs; GeoSite matches destination domains

The two data types use different inputs. GEOIP looks up the destination IP to find its address category. It is useful for connections made directly to an IP address or for routing based on the resolved destination address. GEOSITE looks up the destination domain instead. Even when a CDN maps the same domain to different IPs, domain rules still match by name.

RuleData fileDownload URL field
GEOIP (DAT mode)GeoIP.datgeox-url.geoip
GEOIP (MMDB mode)country.mmdbgeox-url.mmdb
GEOSITEGeoSite.datgeox-url.geosite

In mihomo, geodata-mode: true selects DAT data for GEOIP, while geodata-mode: false selects MMDB. This setting does not change the file format used by GEOSITE. A domain being categorized under cn does not mean every IP address it resolves to will be categorized as CN by GeoIP. If the two rules produce different results, first check which rule the connection matched rather than assuming the database is corrupted.

Configure download URLs and automatic updates in mihomo

Add the data URLs and update interval at the top level of the active configuration. Do not nest them under dns: or rules:. This example is for the mihomo 1.19 series, uses MetaCubeX data files, and explicitly selects DAT mode. To check the version of a standalone core, run mihomo -v. In FlClash, refer to the core information shown by the client and the configuration load results.

geodata-mode: true
geox-url:
  geoip: https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/release/geoip.dat
  geosite: https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/release/geosite.dat
  mmdb: https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/release/country.mmdb
geo-auto-update: true
geo-update-interval: 24
  • geox-url must point directly to a data file, not a repository homepage, file preview, or subscription URL. The example keeps the mmdb URL for use in MMDB mode; changing it does not affect the source of GEOIP data in DAT mode.
  • Set geo-auto-update: true to enable scheduled updates. geo-update-interval: 24 sets the interval to 24 hours. Saving the configuration does not trigger an immediate download. If a usable file already exists, reloading the configuration may continue to use it. Check the core logs and the file's modification time to confirm that an update occurred.
  • Refreshing a subscription updates the configuration; updating Geo data replaces the category data read by the core. If the client overwrites local changes when refreshing a subscription, put these top-level fields in an override configuration that the client supports and actually applies, or maintain a local configuration. If geox-url already exists, merge the child entries into it instead of adding another top-level key with the same name.

Manual updates: replace files in the core's data directory

Manual updates are useful for offline devices, failed initial downloads, or when you need to pin a specific data version. The target is the data directory actually used by the core; it may not be the installation directory or the directory containing your subscription YAML. For a standalone mihomo process, first check the path specified by the -d startup argument. If FlClash manages the core, use the client or core logs to confirm the path.

  1. Identify the files you need. You need the corresponding GeoSite data only if your rules use GEOSITE. For rules using GEOIP, choose DAT or MMDB according to the active geodata-mode. Saving a webpage with a .dat extension does not turn it into a usable database.
  2. Exit the client and back up the existing files. Make sure the tray process and core have stopped before replacing any files. Keep the existing filenames whenever possible. If a file is missing, use the expected filename reported in the core logs. On case-sensitive file systems, geoip.dat and GeoIP.dat are different filenames.
  3. Restart and verify that the files loaded. Check for errors about reading or parsing the database, or missing categories, then test with a new connection. If the configuration fails to load, restore the backup and check that the new file format matches the current mode. To pin a data version, set geo-auto-update to false so scheduled updates do not overwrite the local files.

Rule syntax: put specific exceptions first and MATCH last

In rule mode, mihomo checks rules from top to bottom, and the first match determines the policy. This minimal example sends the specified LAN subnet directly, then checks domain and destination IP categories, and sends all other connections to the existing Proxy policy group. When merging it into your configuration, replace Proxy with the name of your actual group. DIRECT is the built-in direct-connection policy.

mode: rule
rules:
  - IP-CIDR,192.168.1.0/24,DIRECT,no-resolve
  - GEOSITE,cn,DIRECT
  - GEOIP,CN,DIRECT,no-resolve
  - MATCH,Proxy

Handle domain or IP exceptions separately

To route specific domains differently, put the relevant DOMAIN or DOMAIN-SUFFIX rule before a broad GEOSITE rule. The 192.168.1.0/24 range in the example applies only to that subnet; if your LAN uses 192.168.50.0/24, adjust it to match your network settings. cn is a domain category in the example data, not a list automatically derived from the .cn suffix. If you switch data sources, make sure the category you reference still exists.

How no-resolve affects domain connections

no-resolve means this IP rule will not trigger a domain lookup just to find a match. The rule can still match when the destination is already an IP address or the core has a destination IP available. If a connection has only a domain, does not match GEOSITE, and has no destination IP available, the GEOIP rule in this example may be skipped, and the request will continue to MATCH. If you need GEOIP to trigger a lookup for these connections, remove the trailing no-resolve and check the DNS results and match logs. There is no need to change the domain rules at the same time.

Rules still not working after an update? Check the logs and test a new connection

First, separate the download, load, and match stages. An updated file only confirms that its contents on disk may have changed; seeing a rule in the configuration does not mean test traffic has reached the core. Change one stage at a time and start a new connection to identify what made a difference.

SymptomCheck firstWhat to do
Download error or timeoutThe download URL and request result in the core logsCheck that the URL returns the data file directly. If the core cannot reach it during startup, update the file manually first.
File replaced, but loading failsThe actual data directory, filename, format, and categoryUse the error details to check for a DAT/MMDB mismatch or categories referenced by your rules that are missing from the new data.
Connection falls through to MATCHThe active configuration, rule order, destination domain, and IPCheck whether an earlier rule already matches the destination. For domain-only connections, check whether the IP rule is skipped because of no-resolve.
Test request does not appear in the connection listWhether app traffic reaches the coreCheck whether the app uses the system proxy or is routed through TUN, then check the database rules.

Test the two rule types separately. For GEOSITE, use a domain known to belong to the cn category. For GEOIP, use a public IP categorized as CN in the current GeoIP data that you own or are authorized to access. Do not use an address in 192.168.1.0/24 for the second test, because it will match the example's first subnet rule. Check the matched rule and actual policy in the connection details. A webpage loading successfully alone cannot tell you whether the connection went direct, through a proxy, or reused an existing connection.

Download Clash