What GeoIP and GeoSite Updates Change
First, confirm that the client is actually running mihomo. A client with “Clash” in its name does not necessarily use mihomo, and switching cores may leave the client using its original configuration directory. When running mihomo directly, check the core version with mihomo -v. If a GUI client launches it, use the core version shown in the startup log. Don’t rely on the version of a different executable in your terminal.
| Setting or rule | What it matches | Data used |
|---|---|---|
GEOSITE,cn,DIRECT | Whether the requested domain is in the cn category | geosite.dat; unaffected by the geodata-mode setting |
GEOIP,CN,DIRECT | Whether the destination IP falls within the CN address ranges | geodata-mode: true uses geoip.dat; false uses an MMDB file containing country or region IP data |
RULE-SET | Determined by the contents of the corresponding rule set | Check the rule set’s source and update interval under rule-providers |
GeoSite’s cn category is a domain classification maintained by its data source; it does not include every domain ending in .cn. GeoIP matches the connection’s destination address and does not identify where a domain belongs. The same domain can resolve to different IPs when served by different CDN nodes, which can change the GeoIP result. Updating the database only changes the matching data—it does not alter rule order, proxy groups, or nodes in your subscription.
Configure automatic updates: enable the setting, then choose a source
Use the core’s default sources
Look for these three keys in the active configuration used by the current client. If a key already exists, edit it in place; don’t add a duplicate at the end of the file. If the configuration is generated from a subscription, use the client’s supported local override or merge feature, then verify the final configuration passed to the core after reloading. Editing the subscription cache directly may be undone at the next refresh.
geodata-mode: true
geo-auto-update: true
geo-update-interval: 24
geodata-modeselects the GeoIP file format. This example uses DAT. If you already have a working MMDB and only want scheduled updates, keep the existing mode; there’s no need to switch formats.geo-auto-updateenables scheduled geodata updates while the core is running. This setting won’t start the client in the background when the core is stopped.geo-update-intervalis measured in hours.24means an update every 24 hours—not a download at midnight each day, and not an instruction to download immediately after saving the configuration. If a data file already exists, restarting the core doesn’t confirm that an update has completed.
Override a single source with geox-url
geox-url is a top-level mapping of download URLs. geoip points to GeoIP DAT, geosite to GeoSite DAT, and mmdb to an MMDB containing country or region IP data. asn refers to separate ASN data; it is not the file used by GEOIP,CN. If you only need a different GeoSite source, leave the other keys unchanged.
For example, suppose a file server is already listening on 127.0.0.1:18080 and serves an updated geosite.dat at the path below. You can override just this entry. This port is for illustration; it is not mihomo’s default. If you haven’t set up this service, omit this section and use the core’s default source.
geox-url:
geosite: "http://127.0.0.1:18080/geosite.dat"
The download URL should return the data file itself, not a release page, login page, or archive. After changing the source, check the logs. If required rule data is missing, the core may try to download it while loading the configuration. Existing data won’t be replaced immediately just because the URL changed. If the download fails during startup, don’t assume the request used proxy rules that haven’t loaded successfully yet. First make sure the core process can reach the data source, or install the file offline as described in the next section.
Replace files manually: find the data directory, back up, then restart
- Find the core’s data directory. Check the
-dargument passed when the client launches mihomo, or locate the path to the data files in the startup log. The-fargument specifies the configuration file; it doesn’t mean the data files and YAML are in the same directory. In a container, confirm which mounted directory the core can see rather than relying on the host’s file path. - Identify the file to replace.
GEOSITEusesgeosite.dat;GEOIPuses DAT or MMDB, depending on the active configuration. Check the logs or existing files to confirm the local filename expected by the core. The filename in the download URL may differ from the local filename. Pay particular attention to letter case on Linux. - Stop the core and keep a backup. If you want to pin a specific data version, first set
geo-auto-updatetofalsein the active configuration to prevent scheduled updates from overwriting it later. Exit the client, then confirm that the core process or background service has actually stopped. Copy the old file to a backup location outside the data directory, and note its filename and source. - Install and verify the new file. Place the extracted data file at the path expected by the core, keep its original filename, and make sure the account running the core can read it. Restart the core and check the load logs, then make a new connection and inspect the matched rule. Don’t use a connection established before the restart for verification.
- Restore the original if anything goes wrong. If parsing fails, categories are missing, or matching results look wrong, stop the core and restore the corresponding old file. If you also changed
geodata-modeor any rule lines, restore those settings too; otherwise, you’d be testing the original data against different matching conditions.
For command-line deployments, test the configuration first using the same binary and paths as the service. For example, if both the data directory and configuration are in $HOME/.config/mihomo, run:
mihomo -d "$HOME/.config/mihomo" -f "$HOME/.config/mihomo/config.yaml" -t
Test with the right paths: If the production service runs under a different account or in a container, use the paths and permissions visible to that service. A successful configuration test only confirms that the configuration loaded in that test; check rule matches in connection logs from the production instance as well.
GEOSITE Rules: Syntax and Match Verification
A common format is GEOSITE,category,egress. Check the release notes for the current geosite.dat to confirm category names; different data sources may not provide the same categories. The egress can be the built-in DIRECT or a policy group defined in the active configuration. When using a policy group name, match its spelling, capitalization, and spacing exactly.
mode: rule
rules:
- DOMAIN,example.com,DIRECT
- GEOSITE,cn,DIRECT
- GEOIP,CN,DIRECT,no-resolve
- MATCH,REJECT
This example shows how rule order works. The final MATCH,REJECT rule rejects traffic that didn’t match anything above it, so don’t copy it into a normal configuration. Keep your existing fallback egress and insert only the rule you want to test before it. Rules are checked from top to bottom; matching stops at the first one. Here, no-resolve prevents the IP rule from triggering a DNS lookup just to match a destination that is still only a domain name. If the destination IP is already available, it can still be matched by address.
- Make sure the client is in Rule mode. Global and Direct modes don’t select an egress according to this
rulesorder. - First, visit
example.com. In the client’s connection view, check the domain and rule type, and confirm that it showsDOMAIN. This only verifies that the new connection reached the current core and that the rule configuration is active. - Next, choose a domain from the
cnlist provided by your GeoSite data source. Make sure no earlier rule takes precedence, then reconnect. Check that the matched rule type isGEOSITE, rather than checking only whether the egress isDIRECT: different rules can use the same egress.
Troubleshooting: Updates Fail or Rules Don’t Change
- Logs show a download timeout or connection refused: Check the download URL and the network available to the core. Being able to fetch the file in a browser doesn’t mean a background service or container can reach it too. Switch to a verified reachable source or replace the file manually. Don’t repeatedly delete a working old file to force a download.
- Startup reports a file parsing error: Check the format, filename, and directory first. Renaming a downloaded HTML page to
geosite.datwon’t turn it into a database, and an MMDB file can’t be used as DAT just by changing its extension. If the format is correct, check that the core’s account has read permission. - Logs say a category doesn’t exist: Check the category spelling in the rule, then confirm that the new data source includes that category. If the error appeared after updating GeoSite only, there’s no need to touch a GeoIP file that’s still working. Restore the backup or update the rule after confirming what the new category means.
- The file updated, but traffic behavior hasn’t changed: Confirm that you changed the file used by the running core, then use a new connection to check which rule matched first. A connection that only has a destination IP can’t be matched directly against a domain list. If the connection record doesn’t show a domain, check how the client captures traffic and its domain sniffing settings instead of trying another GeoSite file.
Check two things separately when verifying an update: logs or file modification times can help confirm that the data changed, while connection records show which rule selected the egress. If the new version doesn’t change the category you’re testing, the file can update successfully without changing the routing result.