How to Update GeoIP and GeoSite Databases and Configure Routing

Learn what geoip.dat and geosite.dat do, where to update them in popular clients, and how to combine rules like geosite:cn and geoip:private for traffic routing.

At a glance

Updating a rule database only replaces its classification data; it does not enable traffic routing for you. This guide is for readers who can already connect to a node and want to customize routing. First check which data the running core has loaded, then split domain and IP conditions into separate rules, and finally test a new connection to see which rule determines the outbound.

GeoIP matches IP addresses; GeoSite matches domains

geoip.dat stores IP ranges grouped by tags, while geosite.dat stores domain matching rules grouped by tags. The filenames do not guarantee that different sources contain the same data. For the cn tag, GeoIP matches address ranges classified under that tag, while GeoSite matches domain rules listed under it. GeoSite's cn tag does not simply check whether a domain ends in .cn, and it does not check where a server is located.

Request enters the coreTarget address is identifiedRules are checked in orderOutbound is selected
2
Common Geo data files
3
V2Ray domain routing strategies

GeoSite domain condition

Resource files
geosite.dat
Rule fields
domain
Common rule patterns
geosite:cn

If the core receives only an IP address, this rule will not perform a reverse lookup to find the domain.

GeoIP address condition

Resource files
geoip.dat
Rule fields
ip
Common rule patterns
geoip:private

The database determines which addresses match. For a single service subnet, specify the subnet directly for a more precise match.

Update rule databases in v2rayN and Android clients

First identify the running core and the active routing configuration. The .dat files and JSON fields below apply to V2Ray and Xray routing formats. If v2rayN is using a different core, updating these two files does not tell you whether that core's rule sets have been updated. Before updating, note the current resource source. If you maintain the files manually, keep the previous versions of both the resources and routing configuration so you can roll back.

  1. v2rayN 7.x: In the main window, open the "Check for Updates" menu and select the Geo file update option. Wait for the status or log to report the download result. Then open "Settings" → "Routing Settings" and check which routing configuration is selected. If the files update successfully but a different routing profile remains selected, the new database tags may not be used at all.
  2. v2rayNG: Open the main menu in the upper-left corner and select "Geo resource files." On the resource page, check geoip.dat and geosite.dat, then use the available update or import option. Button locations vary by version. When finished, disconnect and reconnect so Xray reloads the configuration and resources.
  3. v2flyNG: Use resources compatible with the v2fly core. If your version has a "Geo resource files" option in the sidebar, manage resources there, then disconnect and reconnect. If you cannot find the option, check which features your version supports. Do not copy v2rayNG's private directories or import Xray-specific configuration unchanged.

After updating on desktop, make sure the core has restarted or reloaded its configuration. To replace files manually, stop the core first and confirm that you are replacing files in the resource directory the running core actually uses—not the download folder or another copy of the application. If reconnecting produces errors such as an unreadable file or a missing category, restore the old files first, then check the file format and tags separately. Avoid changing the subscription URL and routing rules at the same time; otherwise, it will be difficult to tell what caused the change.

Routing rules: bypass private IPs and selected domains

This routing snippet sends traffic directly when the destination IP matches geoip:private, and also when the destination domain matches geosite:cn. Other TCP and UDP connections go through the proxy. The first two conditions are two separate rules. Putting ip and domain in the same rule object requires both conditions to match; it does not mean either one can match. The core checks rules in order, and the first match in a pass determines the outbound.

{
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "domain": ["geosite:cn"],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "network": "tcp,udp",
        "outboundTag": "proxy"
      }
    ]
  }
}

This is not a complete core configuration. direct and proxy must be existing outbound tags; if your client uses different tags, follow the configuration it actually generates. In the GUI, add one IP rule and one domain rule, select the direct outbound, and put the catch-all rule last. To create an exception for one host, add an exact domain condition such as full:example.com before the group rule. To match the domain and its subdomains, use domain:example.com.

StrategyHow domain targets are evaluated against IP rulesWhat to check
AsIsDuring routing, domains are not proactively resolved to IP addresses for matching IP rules.Accessing a local network host by name may use a different outbound from accessing it by IP address.
IPIfNonMatchThe domain is resolved and checked again only if no rule matches on the first pass.If a catch-all rule at the end already matches the TCP or UDP connection, it will match on the first pass, so this strategy will not trigger a second pass.
IPOnDemandDomains can be resolved before matching when routing evaluation requires an IP condition.An earlier IP rule may take precedence over a later domain rule, and DNS results can also affect routing.

How to verify routing after an update

First confirm that the request reaches the core, then check whether a rule matches. The desktop system proxy only affects apps that use it. A browser's ability to reach a local network does not prove that geoip:private is working; the system proxy's bypass list may keep the request from reaching the core at all. Use a test app confirmed to send traffic through the proxy entry point, start a new connection, and temporarily check the target and outbound in the access log or client connection log. Do not rely only on whether a webpage loads.

Change one thing at a time: first confirm that traffic is captured, then check whether the input is a domain or an IP address, and finally review rule order and outbound tags. Even a correctly entered address or domain may be intercepted by an earlier rule.

Common Geo rule database questions

Why does it report a missing category even though the update succeeded?

Check the startup log to identify the file and tag involved in the error, then verify which resource source is actually loaded. A custom tag may not exist in a different database. Switch back to the original resources or change the rule to use a tag supported by the current database, reload the core, and check the log again.

Why does a local network IP connect directly while its hostname goes through the proxy?

First check whether the core receives a domain or an IP address. If it receives a domain and uses AsIs, the private IP condition will not resolve it proactively. For a fixed internal host, add an explicit domain direct rule before the catch-all, and make sure the current DNS can resolve the internal hostname.

Why do image requests go through the proxy when a site's homepage connects directly?

Check the actual hostnames used by image requests in the browser's developer tools Network panel, then compare them with the client logs. The page, images, and APIs may use different domains, and routing is evaluated per connection. If they need the same route, add precise rules for the relevant hosts instead of broadening an entire category for one site.

Download clients