How to Update geoip.dat and geosite.dat: V2Ray Routing Rules Guide

Outdated rule databases can cause routing rules to fail. Learn what geoip and geosite data files do, where to update them in your client, and how to use entries like geosite:cn.

At a glance

geoip.dat contains IP address ranges; geosite.dat contains domain lists. This guide is for users who can connect to a server but are having trouble with direct-versus-proxy routing. First, check which core and routing mode are active. Then update the data files actually in use, and verify the results by checking rule order, DNS behavior, and logs. Updating your subscription does not update the rule database, and a successful update does not guarantee that traffic will match the rule you expect.

geoip and geosite: Know what each one matches

The routing modules in V2Ray and Xray can reference external data sets, so you don't have to list large numbers of domains and IP ranges in your configuration. geosite.dat contains labeled domain lists; geoip.dat contains labeled IP range lists. The files don't determine where traffic goes on their own. Routing takes effect only when a rule references these data sets and specifies an outbound.

Itemgeosite.datgeoip.dat
MatchesDestination domainDestination IP address
Common referencegeosite:cngeoip:cn、geoip:private
JSON fielddomain arrayip array
Common causes of mismatchThe domain isn't in the data set, or the connection doesn't provide a domainThe IP's registered location has changed, or the destination IP hasn't been resolved yet

geosite:cn does not mean “all domains ending in .cn.” It refers to the data set named cn in the current source, which may include domains with other suffixes. The data source determines which domains are included. Likewise, geoip:cn matches IP ranges listed in the data file; it does not check a website's language or independently determine where its business is based.

An outdated rule database may miss newly added domains or changed IP ranges, but old files aren't the cause of every routing problem. The destination domain may be unavailable, an earlier rule may already match, or the current routing mode may not use this configuration—all of these can make an update appear ineffective. Note what happens before updating; this is more useful for troubleshooting than repeatedly swapping files.

Update Geo data files in v2rayN: check the core first

v2rayN is a management interface; the core it starts is what reads the rule database. The .dat instructions in this guide apply to V2Ray and Xray. If your current setup uses another rule data format, don't assume the file path is the same just because you're using the same client. Check the core name and configuration path in the startup logs before updating.

  1. Note the current setup

    On the main screen, note the current server, system proxy status, and routing mode. Save your existing routing settings; if you use a custom configuration, keep a recoverable copy. While troubleshooting, don't change both the server and routing mode at the same time.

  2. Find the update option

    In v2rayN builds that provide this option, open “Check for updates” → “Update Geo files.” The menu location and wording may vary between builds. If you don't see it, check the update menu in your current interface; “Update subscription” is not a substitute.

  3. Wait for confirmation

    Check the update result or logs to confirm that both required data files have finished downloading. If the operation times out, first check that the update source is reachable. If the updater offers a proxy option, retry through a proxy you've verified works; don't keep clicking repeatedly.

  4. Reload the core

    After the update finishes, restart the current service or core. If you're not sure it reloaded, close and reopen v2rayN. Check the startup logs for errors such as missing files, read failures, or unknown categories.

  5. Test the same destination again

    Keep the same server and routing mode, then reopen the destination that had the problem. Start a new connection and check the outbound in the logs; existing connections may not be evaluated by the routing rules again.

Update failed? Choose the built-in updater or replace files manually

Use the update option provided by the client whenever possible; it is more likely to put files where the current setup will use them. Don't copy someone else's absolute path: portable, installation, and user data directories, as well as custom launch methods, can use different resource paths. A file with the right name on disk doesn't necessarily mean the running core is reading it.

Built-in client updater

Recommended

Get the rule database through the current update option, and keep the update result and startup logs. Once complete, restart the core and verify which data directory it uses to reduce the chance of putting files in the wrong place.

Best for: routine maintenance and an accessible update source

Replace files manually

Get the relevant binary data files from the official release channel of your chosen rule data source. Stop the core and back up the old files before placing the new ones in the confirmed resource directory. If you downloaded an archive, extract it first; don't just rename the archive with a .dat extension.

Best for: failed automatic updates when you know the resource directory and data source

Bottom line: confirm the file path before replacing files

Before updating manually, note the core's startup parameters and resource directory. After replacing the files, restart immediately and check for loading errors. If the path is unclear, resolve that first; don't copy files into multiple directories, or you won't know which copy is being used next time.

When replacing files manually, also check that the required categories exist. Different data sources may use the same filename, geosite.dat, but provide different labels; filters using @ also depend on the source file's contents. If you see a “category not found” error, compare the rule's data set with the source documentation instead of changing the server protocol. Keep the original file so you can quickly roll back if the configuration fails to load.

Routing with geosite:cn and geoip:cn

The routing snippet below is intended to be merged into a core configuration; it is not a complete, runnable client configuration. It assumes an existing direct outbound named direct; outbound tags must match your configuration exactly. In v2rayN's graphical routing editor, enter the domain, IP, and outbound fields using the same logic. Don't overwrite the entire configuration generated by the client.

{
  "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"
      }
    ]
  }
}
2 files
Geo data files referenced in this example
3 rules
Private addresses, domain sets, and IP sets
Port 53
Common port for traditional DNS; check the query path separately

IPIfNonMatch means the core first tries to match using the available destination information. If a domain request doesn't match a rule, it then resolves the domain to an IP and tries the IP rules. It does not mean “resolve every request first.” If an earlier rule already proxies all domains, matching stops there, and geoip:cn won't act as a catch-all fix.

Routing rules not working? Check order, domains, and DNS

Routing rules are evaluated from top to bottom, and the first match determines the outbound. The database only tells the core whether a destination belongs to a set; it can't override an earlier match. When troubleshooting, check the rule list, destination address, and outbound tag in the logs—not just whether the page loads.

  1. Check the mode: Confirm that the routing mode selected on the main screen is the one you expect. Global proxy or global direct modes may bypass the split-routing rules you're editing.
  2. Check the domain: If an app passes only an IP address to the proxy, a domain rule may not match. Sniffing can recover a domain from some protocols, but it doesn't cover every connection or work reliably every time.
  3. Check DNS: When routing depends on an IP match, the resolved address affects the result. Traditional DNS commonly uses UDP/TCP port 53; encrypted DNS uses other transport methods. A web connection going through a proxy doesn't mean its DNS queries follow the same route.
  4. Check rule order: Look for broad domain, port, or fallback rules earlier in the list. Test the outbound with an exact-domain rule first, then restore the set-based rule. This helps distinguish a data source issue from a rule order issue.
  5. Test a new connection: Close the destination page or restart the test app, then try again. If necessary, enable more detailed logging briefly. Restore your usual log level once testing is complete, and don't share full logs that contain subscription URLs or destination domains.

If an exact-domain rule routes correctly but geosite:cn doesn't match, check whether that domain is actually in the current set. If the exact rule also fails, first check whether the current configuration is active, whether the outbound tag is correct, and whether an earlier rule is intercepting traffic. Downloading the rule database again is unlikely to help in that case.

Geo file update FAQ

The update succeeded. Why is traffic still taking the wrong route?

Restart the core, then start a new connection. Check the current routing mode and the outbound tag in the logs; next, temporarily add an exact-domain rule for the destination as a comparison. If the exact rule works but the set-based rule doesn't, check the set contents and the path the core actually reads.

Do both files need to be replaced together every day?

There's no need to update them mechanically every day. Update when categories change, when you start maintaining routing rules, or when the data source announces a significant change. If the client supports updating both at once, you can do so; with custom data sources, verify that each still provides the labels your rules need and keep backups for rollback.

The geosite category is missing. Should I add the subscription again?

First check the spelling of the label in the error, then verify the source of geosite.dat and its category list. If needed, restore the last working file or change the rule to use a category that the source actually provides. Adding the subscription again won't add missing labels to the data file.

Can I use the desktop directory on Android as-is?

No. v2rayNG uses the Xray core, while v2flyNG uses the v2fly core. Use the resource update option in each client; the exact menu depends on the current interface. The system manages mobile app data directories, and desktop configuration snippets should only be used with an import method supported by the client.

Download v2rayN