· Advanced Setup · About 8 min

Update Geo databases and configure routing

Learn what geoip.dat and geosite.dat do, update them manually or automatically in v2rayN and v2rayNG, and build maintainable routing rules with geosite:cn and geoip:private.

At a glance

If connections work but routing rules don't match or LAN access is failing, first check which data files the current core has loaded. Then update the files and restart the connection. This guide covers update options on desktop and Android, plus how to use logs to tell whether data failed to load, a rule is out of order, or app traffic never reached the core.

What GeoIP and GeoSite Match

App requestDestination lookupRules checked in orderOutbound selected

GeoSite: Domain Categories

Data file
geosite.dat
Rule field
domain
Category example
geosite:cn

Checks whether a domain belongs to a category in the data source; it does not infer this from the domain suffix or server address.

GeoIP: Address Categories

Data file
geoip.dat
Rule field
ip
Category example
geoip:private

Matches the destination IP against an address range. The exact ranges depend on the data source in use.

These files provide matching data only; they do not change the outbound route. The rule's outboundTag determines whether matched traffic uses a direct or proxy connection. If the destination is an IP address, domain rules cannot infer its domain. Whether IP rules can match a domain-only destination depends on the routing domain strategy. Updating the category database does not change these settings.

v2rayN: Start with the Resource Update Options

  1. Note your active configuration first. In the main window, check which configuration is selected and which core is in use. Then open Settings → Routing Settings and confirm the active rule set. The files and rule syntax below assume an Xray or V2Ray configuration that reads these two DAT resources. Don't infer the resource format from the client name alone.
  2. Update from the client. In desktop versions that provide this option, look for Geo file updates under Check for Updates in the main window, then wait for the log to confirm completion. Some versions update GeoIP and GeoSite separately, so success for one does not mean both are updated. If there's no scheduled update option, trigger an update here when needed. Update subscription does not update these resources.
  3. Replace the files manually if needed. Exit the client and core processes, then back up both existing files. If the update log shows the target path, use it to locate the actual resource directory. Portable and installed setups may use different paths, so don't guess based on the program directory. Choose the corresponding files from the same compatible data source, replace them using the original filenames, and restart.
  4. Confirm the new files were loaded. Make sure the updated files are in the directory you just checked, then review the startup log. If it reports a missing file or category, restore the old files first to get the connection working again. Then check the path, resource format, and category name separately.

v2rayNG: Update Resources and Reconnect

  1. Open the top-left menu on the main screen and select Resource Files to view the GeoIP and GeoSite entries. Start the update from that page. If your version offers a separate update action for each entry, update them individually and wait for the results. Downloads within the client still need to be triggered manually unless your version explicitly provides and has enabled scheduled updates.
  2. If an online update fails and the resource page offers an import option, use the system file picker to select the corresponding downloaded DAT file. Saving the file to your phone's Downloads folder alone won't make the core load it. If there's no import option, use the client's built-in update feature instead; don't try to modify Android's protected app directories.
  3. Turn the current connection off and back on so the core reloads the resources. If rules still don't match on Android, check whether Per-app proxy in Settings allows the test app's traffic through the connection. If that app is bypassed, changing Geo rules won't affect the test.

Routing Rule Syntax and Priority

10.0.0.0/8
Private IPv4 Address Ranges
172.16.0.0/12
Covers 172.16 through 172.31
192.168.0.0/16
Common Home LAN Address Ranges

Test LAN Rules with a Known Address First

Test a direct connection to your home gateway's IP, then test using a domain name. If the IP works but the domain doesn't, keep the IP rule and investigate domain resolution and matching conditions.

The ranges above are examples of private IPv4 addresses, not a complete list of everything that may be included in geoip:private in any given data source. The example below shows only a routing section. Before adding it to a custom configuration, confirm that outbound tags direct and proxy already exist. In a graphical editor, fill in the IP, domain, and outbound fields separately rather than pasting the whole section into a single field.

{
  "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"},
      {"type": "field", "network": "tcp,udp", "outboundTag": "proxy"}
    ]
  }
}

Verify Updates and Roll Back Safely

  1. Start by checking the traffic path. From the same test app, visit a known-working service and confirm that the client log shows the destination. The system proxy only affects apps that use it. If there's no request in the log, check the proxy connection method and app settings first. Log level can also affect which entries are shown.
  2. Test one rule at a time. Visit a working LAN address, a site you know belongs to the current domain category, and a site outside that category. Check the selected outbound in the logs; don't judge routing by whether a page loads. For domain tests, use a new connection where possible to avoid reusing an existing one.
  3. Roll back one change at a time. If the core fails to start after updating the files, restore the old resources and reconnect. If it starts but selects the wrong outbound, restore the previous routing rule set and check which rule matched first. Record the data source, update date, and rule exceptions together so you can tell whether future differences come from the data or the configuration.
Download Clients