What GeoIP, GeoSite, and MMDB Match

Before updating, check what your current configuration matches. GEOIP checks which data category the connection’s destination IP belongs to. GEOSITE checks whether the destination domain appears in a category. A service can use multiple domains, and DNS results can vary by location or CDN routing, so these two rules may not produce the same result. Updating the databases changes which addresses or domains are covered; it does not change rule order or update the nodes in your subscription.

mihomo Data Files, Configuration Keys, and Their Purpose
File in the Working Directory Download URL Key Rule Purpose
geoip.dat geox-url.geoip Used by GEOIP to look up IP categories when geodata-mode: true.
country.mmdb geox-url.mmdb Used by GEOIP to look up IP categories when geodata-mode: false.
geosite.dat geox-url.geosite Used by GEOSITE to look up domain categories, regardless of the mode above.

GeoIP and GeoSite DAT files are both binary, but they contain different data: IP ranges and domain-matching entries, respectively. MMDB is a separate format for IP lookups. Changing a file’s extension does not convert its format. The examples below use mihomo configuration. If you use another Clash core, first check which configuration keys and rule types it supports.

Choose a Data Source and File Version

If your current setup works, stick with the data source already in use. Find the relevant release files through the channels used by the core project or data projects explicitly recommended in your client’s documentation. Before switching sources, check the asset names, file formats, and category lists. Even when different projects provide a file named geosite.dat, the domains covered by a category with the same name may differ.

Check Your Existing Rules Before Downloading

  • If your configuration uses GEOSITE,cn or GEOSITE,google, make sure the new file includes those categories. Minimal data builds may include only a subset of tags.
  • If you only want to refresh IP data, first check geodata-mode in the active configuration. If the current setup uses MMDB, replacing geoip.dat alone will not change the results of GEOIP rules.
  • Make sure you download the data file itself, not a release notes page, login page, or archive. If the publisher provides an archive, extract it and use the required data file.

If your configuration uses RULE-SET, also check that the referenced rule name matches an entry under rule-providers. Remote rule sets have their own sources and update intervals; replacing GeoIP or GeoSite data will not refresh them. Keep these two update paths separate to avoid replacing the wrong file.

Manual Replacement: Find the Core’s Working Directory

The client’s installation directory, subscription directory, and core working directory may all be different. For a GUI client, look for its core data directory option or check the startup logs. For command-line use, check the -d startup argument. For example, run mihomo -v to see which mihomo v1.19.0 binary is being called. If both a standalone core and a GUI client are installed, the version shown in your terminal may not be the one the client is running.

  1. Note the data mode, rule tags, and update source in the active configuration. Before replacing anything, copy the old file to another directory so you have a backup ready to restore.
  2. Stop the core. If the tray app or background service keeps running after you close the client window, use the client’s quit option or stop the service to shut down the core.
  3. Copy the new file into the core’s working directory using the filename the core expects. For example, if the release asset is named geoip-lite.dat, confirm that it is a compatible GeoIP DAT file, then save it in the working directory as geoip.dat. Watch for double extensions if your system hides file extensions.
  4. Restart the core and check the startup logs first. Then verify that a new connection matches the expected rule. If the logs report a missing category or a data parsing error, stop the core, restore the old file, and restart.

Replace one type of data at a time. Update GeoSite first and verify domain rules, then update the IP data. If anything goes wrong, you’ll only need to roll back the last file you replaced.

Automatic Updates: Configure geox-url and the Update Interval

This mihomo top-level configuration snippet uses GeoIP DAT and sets automatic updates to every 24 hours. The example domain is only there to illustrate the URL format; it is not a working download link. Before applying the config, replace it with a direct HTTPS link to a data file provided by the publisher. If your configuration already has a geox-url block, edit the relevant entries there rather than adding a second block with the same name.

geodata-mode: true
geo-auto-update: true
geo-update-interval: 24

geox-url:
  geoip: https://updates.example.org/clash/geoip.dat
  geosite: https://updates.example.org/clash/geosite.dat

If your existing configuration uses geodata-mode: false, you can keep that mode and set the IP data URL under the mmdb key in geox-url. You don’t need to switch formats to enable automatic updates. Continue to use the geosite key for GeoSite. The file extension is only a hint; make sure the server returns a file in the format expected by that key.

Check That the Configuration Took Effect and the File Downloaded

With a subscription-based GUI client, use its supported override or merge mechanism to set these top-level keys. Editing a cached subscription file directly may not stick; the next subscription update could overwrite your changes. After saving, check the configuration actually passed to the core. Confirm that geo-auto-update is still true, then check the download result in the core logs.

A 24-hour interval is the update schedule; it doesn’t replace the file as soon as you save the settings. To confirm the new version was saved, check the logs and the file’s modified time in the working directory. To replace it immediately, follow the manual steps above. If the URL opens in a browser but the core times out, check whether the core’s runtime environment can reach the URL and whether the redirected URL is accessible. Simply shortening the update interval won’t fix a connectivity problem.

Common Category Tags and Rule Order

This example assumes your configuration already has a policy group named “Proxy” and that the selected data source includes google and cn. It puts the specified domain categories first, uses IP categories as a fallback, and assigns an outbound route to any connections that don’t match. When adding these rules to an existing configuration, put any custom exceptions you want to keep before the broader categories, and leave MATCH last.

rules:
  - GEOSITE,google,Proxy
  - GEOSITE,cn,DIRECT
  - GEOIP,CN,DIRECT,no-resolve
  - MATCH,Proxy
  • GEOSITE,google matches related domains included in the data source. GEOSITE,cn matches domains classified as related to mainland China by the data source; it does not match every domain ending in .cn.
  • GEOIP,CN matches the mainland China category in the IP data. Here, no-resolve means the rule won’t actively resolve a domain just to make a match. It can still match if the connection already has a destination IP available.
  • Some data sources provide a geolocation-!cn domain category. It is a list of domains curated by the maintainers, not the mathematical complement of the cn category, and it cannot replace MATCH as a fallback for all unmatched connections.

Still Not Working After an Update? Check Rule Matches

A website loading successfully doesn’t prove the connection used the expected outbound route. After updating, start a new connection and check its destination domain or IP, matched rule, and outbound route in the client’s connection details. Existing connections may keep their previously selected route. A single page load can also create connections to several different domains, so inspect the specific connection you’re troubleshooting.

  1. Startup error says a category is missing: Compare the rule’s tag with the data publisher’s category list, then check that the file is in the working directory of the core that’s actually running. If the error started after switching subscriptions, check whether the new subscription refers to a category missing from the old data source.
  2. Logs show a successful download, but matches haven’t changed: Confirm that you updated the file used by the current mode. Then check whether an explicit domain rule or RULE-SET matches the connection first. Once an earlier rule matches, later GeoIP or GeoSite rules are not evaluated.
  3. Domain rules miss only some apps: Check whether the connection shows a domain in the client. Some connections expose only a destination IP, which gives GeoSite no domain to match. Don’t treat switching to TUN mode as a database update step. First confirm that the traffic reaches the core and check what the core can actually see.
  4. A few services route differently after the update: Restore the old data with the same configuration and compare which rules match before and after. If only a few domains need a fixed route, adding narrowly scoped domain exceptions is usually easier to review than changing an entire regional category.

To confirm an update is complete, check two things: whether the core loaded the expected data file, and whether new connections match the expected rules. A newer file with connections still handled by earlier rules is normal rule-order behavior. If the file hasn’t changed, check the data URL, update mechanism, and working directory.