How to Update geoip.dat and geosite.dat: Routing Rule Data and Syntax

Learn how GeoIP and GeoSite databases power routing, update rule files in your client, and use common tags such as geosite:cn and geoip:private.

At a glance

This guide is for users configuring routing in v2rayN, v2rayNG, or v2flyNG. First, learn the difference between domain and IP databases; then update the files through your client and see how Xray/V2Fly rules use tags, rule order, and DNS settings. By the end, you’ll be able to tell whether a problem lies with the data source, file path, or routing rules—without repeatedly reinstalling the client.

1. What GeoIP and GeoSite Match

geosite.dat contains domain rules organized by tags, while geoip.dat contains IP ranges organized by tags. These are binary data files read by the core—not server lists or DNS servers. Updating a file changes the entries in its sets; it does not automatically change where a rule sends traffic.

TargetExample referenceWhat it matches
Domain setgeosite:cnDomain rules included in the source’s cn set; this does not mean it matches only the .cn suffix.
IP geolocation setgeoip:cnWhether the destination IP falls within a corresponding range in the data source.
Private and special-use address setgeoip:privatePrivate, reserved, and other ranges defined by the data source; check that source for the exact coverage.

A connection may reach the core with a domain name, or with only a destination IP. Domain rules require the core to have the domain; IP rules require the destination address, or DNS resolution during routing. Being able to open a website does not mean both domain and IP sets were involved in the match.

For example, a local network address such as 192.168.1.1 can be matched directly against an IP range. A domain may be included in geosite:cn yet resolve to an overseas CDN. The two databases describe different properties and cannot replace each other.

10.0.0.0/8
RFC 1918 private IPv4 ranges
172.16.0.0/12
Range ends at 172.31.255.255
192.168.0.0/16
Common local network ranges

Rule of thumb: verify the address range first for LAN routing

Check a real gateway address against your direct-connection rule first, then check website categories. The three ranges above are specific private IPv4 ranges, not a complete list of every source’s private addresses. If you also need loopback, link-local, or IPv6 ranges, check the data source.

2. Data Sources and Tag Compatibility

Common sources include V2Fly’s domain-list-community, GeoIP data projects, and rule data builds maintained by projects such as Loyalsoldier. Source projects may publish text lists, while the build artifacts are the .dat files the core actually reads. Don’t rename a webpage or raw domain list to geosite.dat.

Client-provided source

Recommended

Keep using the Geo data download source already configured in your client, and first make sure it provides every tag your current routing rules use. This reduces the number of variables when troubleshooting.

Best for: standard routing, first-time updates, restoring an existing setup

Builds from a maintained project

If you need a specific category, choose a source that explicitly supports its tags. Note the source name, update date, and file names, and check that its tag definitions match the core’s format.

Best for: custom categories, pinned data sources, troubleshooting missing tags

Files with the same name don’t necessarily contain the same tags. The cn tag is common, but service-specific, ad-blocking, and attribute-based sets may be available only from certain sources. Referencing a missing tag can prevent the core from loading the configuration—not just disable one rule.

3. Update Geo Files in v2rayN

On desktop, first check whether the active configuration uses the Xray or V2Fly core, then update the corresponding data files. The steps below use a v2rayN interface with an “Update Geo files” option. Menu locations may vary by release; different labels don’t mean the files are corrupt.

  1. Back up your routing setup

    Open “Settings” → “Routing settings” and note the active routing profile and any custom rules. If you manage Geo files manually, copy the original files to a backup folder as well.

  2. Update the data

    In the main window, open “Check for updates” → “Update Geo files.” Wait for the result and check the status of geoip.dat and geosite.dat separately. A node subscription update notice does not confirm that the rule databases were updated.

  3. Check the logs

    Review the main window’s log or message panel. If the download fails, check network access and the source URL. If a tag can’t be loaded, verify the tag name and data source instead of deleting the entire routing setup.

  4. Reload the data

    Stop and restart the current connection through the client so the core reloads the files. If the client already restarted as part of the update, check the startup log for Geo file loading errors.

  5. Test the rules again

    Keep the same server, proxy mode, and DNS settings; change only the data files, then test the same destinations. This isolates the effect of the update from other configuration changes.

In v2rayNG and v2flyNG, first check “Routing settings” in the side menu to review the active rules and available data update options. Menus vary between Android client versions. If there’s no dedicated Geo update option, follow that version’s instructions for importing files or updating resources; don’t use desktop directory paths. Updating a subscription mainly refreshes server details, so it doesn’t confirm that Geo data was refreshed.

4. Writing Rules with geosite:cn and geoip:private

The following example uses the Xray/V2Fly routing object. It sends private addresses direct first, then checks domain sets, and finally uses the China IP set as a fallback. Tags must exist in the installed data files. Rules are checked from top to bottom, and the first match determines the outbound.

{
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "domain": ["geosite:cn"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "ip": ["geoip:cn"],
        "outboundTag": "direct"
      }
    ]
  }
}
FieldUse it this wayCommon mistake
domainAdd domain matchers such as geosite:cn.Using geoip:cn as a domain set.
ipAdd geoip:private or a CIDR range.Putting website domains in the IP address array.
outboundTagReference tags defined in the active configuration.Using the node name shown in the UI as the core’s outbound tag.
rulesPut specific exception rules before broad rules.Appending a corrective rule after an earlier rule that already matches.

Multiple different conditions in a rule usually all have to match; multiple options in the same array match any one of them. If you want direct routing when either the domain is in cn or the IP is in cn, split them into two rules as shown. Putting both fields in one rule won’t make them work as an “OR.”

5. How domainStrategy and DNS Affect Routing

routing.domainStrategy controls how domain resolution is handled during routing; it is not the DNS configuration for the entire client. Don’t confuse it with similarly named settings on an outbound: routing decides which outbound to use, while the outbound determines how to establish the connection.

That’s why the example uses IPIfNonMatch: it checks known domain sets first and tries IP classification only for unmatched destinations. The DNS lookup path also depends on DNS servers, query rules, and connection settings; updating these two data files alone won’t fix DNS pollution or timeouts.

Check whether the core receives a domain or an IP

If a “domain direct-routing rule isn’t working,” first check the request target and routing logs. If an app passes only an IP to the core, updating geosite.dat won’t restore the domain. Check the app’s proxy mode and, if needed, review sniffing settings and their scope before changing any rules.

6. Manual Replacement, Verification, and Common Errors

If automatic updates fail, you can manually obtain both build files from the same maintained source. Stop the core before replacing them, find the resource directory the active core actually reads, keep the exact file names, and restart the core afterward. Installed desktop versions, portable builds, and Android apps use different resource locations; there is no universal directory path.

  1. Verify the file location: Check the client’s directory documentation, resource settings, or logs. A file with the right name in the program folder doesn’t prove the running core reads it.
  2. Verify the download: The file shouldn’t be empty, a login page, an error page, or an archive. If your system hides extensions, make sure it hasn’t been saved as geosite.dat.dat.
  3. Verify startup: After restarting, check for errors such as missing files, data parsing failures, or unknown set tags. If startup fails, restore the backup before making further changes.
  4. Verify actual routing: Make sure the app is using the client’s proxy, then visit a local network destination, an expected direct-connection destination, and an expected proxy destination. Check the outbound tags in available access logs.
SymptomCheck firstWhat to do
Download succeeds, but the file is still reported missingThe running core’s resource directory and file names.Put the files where the core actually reads them, then restart it.
A tag is reported missing after the updateWhether the new source provides that tag.Restore the old data or update the relevant rules to use categories supported by the new source.
A website still uses the wrong outboundRule order, domain visibility, and the currently selected profile.Check which rule matches first and confirm you’re editing the active routing profile.
The core starts, but websites won’t loadServer connection, DNS, and destination service status.First separate connection failures from classification issues. Work through each check in Troubleshooting.
Do Geo files need daily updates?

There’s no universal need to update them daily. Updates are useful when categories change, IP ranges are reassigned, or maintainers fix the data. Check weekly, and update sooner if a category is wrong or you need a new tag. If your client doesn’t support scheduled Geo updates, don’t treat the subscription refresh interval as a substitute.

Will updating the databases automatically route China traffic direct?

No. The data files provide sets only. You still need rules that reference geosite:cn or geoip:cn and point to a working direct outbound. If the active mode bypasses those routing rules, even the newest databases won’t change the result.

Why hasn’t classification changed even though the file’s modified date has?

A changed timestamp only shows that a local file was written. It doesn’t prove the relevant entries changed or that the core reloaded the file. Check the source contents, runtime path, core restart, and the rule that actually matched—instead of repeatedly downloading the files.

Download the client