Oct 14, 2026 · Routing · About 10 min

How to Update geoip.dat and geosite.dat: Using geoip:cn and geosite:category-ads

Learn what GeoIP and GeoSite databases do, where to update them in v2rayN, and how to use country and domain-category rules in routing examples.

At a glance

This guide is for users who have imported a subscription and are ready to adjust routing. First, distinguish the IP database from the domain database. Then update the Geo files in v2rayN, confirm which files the core actually loads, and configure country and ad-category rules. The examples use V2Ray/Xray DAT routing syntax. Before applying them, check which core is running and whether its data source includes the referenced categories.

GeoIP and GeoSite: What Each One Matches

geoip.dat stores IP ranges grouped by country or other labels; geosite.dat stores domain rules grouped by label. These are data files read by the core, not server lists or subscription URLs. Refreshing a subscription updates server configurations, but does not mean the Geo files have also been updated.

ItemGeoIPGeoSite
Common filenamesgeoip.datgeosite.dat
MatchesDestination IPv4 or IPv6 addressDomain provided by the connection or detected through sniffing
Rule example"ip": ["geoip:cn"]"domain": ["geosite:cn"]
Key limitationIP geolocation alone cannot determine where a site's operator is basedAvailable categories depend on the data source and require domain information

geoip:cn refers to the set of IP addresses labeled cn in the database; it does not mean “all Chinese-language websites.” geosite:cn refers to a domain category, and the two sets do not correspond one-to-one. Websites may use international CDNs, and the same domain can resolve to different addresses on different networks. Treat domain rules and IP rules separately.

Update Geo Files in v2rayN

First, check whether the active node uses V2Ray or Xray, and which routing profile is enabled. v2rayN generates configurations and manages the core; the core itself reads the databases and applies routing rules. The steps below use a desktop interface with a “Check for Updates” → “Update Geo Files” option. Menu names and locations may vary by version. Updating a subscription is not a substitute for updating Geo files.

  1. Note the Current Setup

    Record the active routing profile, the core used by the node, and the domain you're trying to fix. Save a copy of the routing configuration first so you can distinguish rule changes from database updates.

  2. Run the Update

    In the main window, select “Check for Updates” → “Update Geo Files.” Check the interface message or logs to confirm the download finished. Clicking the menu option alone doesn't prove the files were written successfully.

  3. Verify the Files

    Find the data directory used by this running client and check the modification times and file sizes of geoip.dat and geosite.dat, along with the update logs. If multiple files with the same name exist, confirm which one the core actually uses.

  4. Restart and Test

    Restart the active core. If there's no separate restart option, fully quit and reopen the client. Check the logs for Geo file loading errors, then reconnect and verify that the expected outbound is selected.

If the update fails, troubleshoot based on the error: for a download timeout, check network access to the update source; for a certificate error, check the system date and time; for a write failure, check directory permissions and whether another process has locked the file. “Update via proxy” in subscription settings applies to subscription updates; don't assume it also controls Geo file downloads.

File Locations: Check the Active Instance and Core Logs

Don't replace files based on a single path found online. Portable folders, installation directories, user data directories, and different package layouts can all vary. If two copies of v2rayN are installed, updating files in the old directory won't change the data used by the active instance.

Find the Right Location: Identify the Instance, Then Its Resource Directory

Windows
  • In Task Manager, use “Open file location” for the running process to identify which copy of the program is active.
  • Search the directories associated with the active instance for both DAT files, then check their updated modification times.
  • Use the client logs, generated configuration, and core startup information together to determine the actual resource path.
macOS and Linux
  • Distinguish the application installation location from the current user's data directory. Don't assume all resources are stored alongside the program.
  • Check the startup environment and core logs to see whether a resource directory has been explicitly set.
  • Before replacing files manually, stop the core, keep a copy of the originals, and make sure the target directory is writable.

Finding a file with the right name doesn't mean it's being used. Cross-check the active instance, startup environment, and load logs.

For example, in Windows PowerShell, you can run the read-only search below from the confirmed client directory. It only lists files in that directory tree and won't overwrite anything. If resources are stored in the user data directory, search there separately.

Get-ChildItem -Path . -Recurse -File -Filter '*.dat' |
  Where-Object { $_.Name -in @('geoip.dat', 'geosite.dat') } |
  Select-Object FullName, Length, LastWriteTime

When managing the core manually, also check resource-directory environment variables, such as V2Ray's V2RAY_LOCATION_ASSET or Xray's XRAY_LOCATION_ASSET. If the client manages the core, don't add these variables casually; they may cause the core to bypass the directory you just updated. Manual replacement only makes sense once you've confirmed how the core starts and which path it actually reads.

Rule Examples: Block Ads, Bypass the Proxy for Domains and IPs

The following is a routing snippet for a V2Ray/Xray configuration, not a complete client configuration you can run as-is. It shows three rules: send the ad category to a blocking outbound, and send domestic domains and IPs to a direct outbound. Before using it, check the actual outbound tags. block and direct are example tags here; adding them to a rule does not create those outbounds.

2
DAT Files Used in This Example
3
Rules Are Matched from Top to Bottom
1
Restart the Core at Least Once After Updating
{
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "domain": [
          "geosite:category-ads"
        ],
        "outboundTag": "block"
      },
      {
        "type": "field",
        "domain": [
          "geosite:cn"
        ],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "ip": [
          "geoip:cn"
        ],
        "outboundTag": "direct"
      }
    ]
  }
}

In v2rayN's routing editor, use geosite:category-ads for the domain condition and geoip:cn for the IP condition. Don't paste the entire JSON object into a single condition field. After saving, make sure this profile is the active routing profile. See the complete configuration guide for how the fields fit together.

Domain Strategy: Why an IP Rule Didn't Match

The example uses AsIs, which means the routing stage won't resolve a domain just to check it against an IP rule. If a connection already provides an IP address, it can still match geoip:cn. But if it provides a domain that doesn't match a domain rule, don't assume it will fall through to the domestic IP direct rule.

AsIs: Match Domains First

Recommended

A good starting point for troubleshooting this guide's examples. Domain categories and IP conditions remain clearly separated, so you don't introduce an extra DNS lookup into the same test. This doesn't mean the strategy is right for every network.

Best for: First checking whether GeoSite rules and rule order are correct.

IPIfNonMatch: Resolve, Then Match

If a domain doesn't match an existing rule, try resolving it and continue matching against IP conditions. Before using this strategy, check the core's DNS settings, resolution results, and default outbound so DNS differences aren't mistaken for an outdated database.

Best for: Deliberately using the resolved IP to add routing for domain traffic.

If an app connects directly to an IP address, GeoSite may not have a domain to match. Sniffing can extract domains from some protocol traffic, but it can't recover a domain from every connection; the app's transport and encryption also affect the result. Updating geosite.dat alone won't fix a routing problem where there's no domain to match.

Still Not Working After the Update? Narrow It Down with Logs

Don't verify the change solely by checking whether a webpage opens. Record a test domain, the expected outbound, and the time of the request, then review the core logs for that period. The detail shown depends on the current log level; temporarily increase it if needed, then restore it when you're done. Avoid sharing complete logs that contain subscription URLs or credentials.

The log says category-ads can't be found. Didn't the file update?

First check whether the data source includes this category. If it provides a different ad category, update the rule to use the label it actually supports; repeatedly downloading the same file won't help. After changing the rule, restart the core, confirm the category load error is gone, and test again.

The log says geoip.dat can't be opened. Where should I put it?

Start with the failed path in the logs. Check that the directory exists, the filename is correct, and the process has read permission. Then check whether the startup environment specifies a different resource directory. Don't copy the file to several locations and hope one works.

The ad rule is saved, but ads still appear. Why?

Check the active profile, rule order, and blocking outbound tag. Then verify that the domain used by the ad request is included in the category. Ads served from the same domain as page content are difficult to distinguish using domain lists alone, and cached pages or existing connections may retain old results.

A website in mainland China is going through the proxy. Is GeoIP outdated?

First check whether the connection target is a domain or an IP address. With AsIs, a domain that doesn't match isn't necessarily checked against IP rules. Also check for an earlier proxy rule, whether the destination uses an overseas CDN, and whether DNS is resolving as expected.

Why don't the same rules work with another core?

First check which rule formats the target core supports. The DAT files and geosite: and geoip: references in this guide are for V2Ray/Xray; changing the file extension won't convert them into rule sets for another core. Use the data format and configuration fields supported by the target core.

Ongoing Maintenance: Update Databases and Rules Separately

Updating a database changes which items belong to each category; updating routing changes conditions, order, and outbounds. Both can affect routing results. Change one variable at a time to pinpoint whether an issue comes from changed data, rule precedence, or DNS resolution differences. You don't need to replace every file manually after each subscription refresh.

If the client won't start or the network connection drops, restore the last working configuration first, then troubleshoot each setting separately. For common connection issues, see Troubleshooting. Geo data is only one part of routing; traffic capture, rule order, DNS strategy, and outbound tags all determine the final connection path.

Download v2rayN