| 1 | <!--startmeta |
| 2 | custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/crates/netflow-plugin/integrations/ip2location_lite_ip-country.md" |
| 3 | meta_yaml: "https://github.com/netdata/netdata/edit/master/src/crates/netflow-plugin/metadata.yaml" |
| 4 | sidebar_label: "IP2Location LITE IP-Country" |
| 5 | learn_status: "Published" |
| 6 | learn_rel_path: "Network Flows/Enrichment Methods" |
| 7 | keywords: ['ip2location', 'ip2location lite', 'geoip', 'country', 'csv', 'ip intelligence', 'flow enrichment'] |
| 8 | message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE FLOWS' metadata.yaml FILE" |
| 9 | endmeta--> |
| 10 | |
| 11 | <!-- markdownlint-disable-file --> |
| 12 | |
| 13 | # IP2Location LITE IP-Country |
| 14 | |
| 15 | |
| 16 | <img src="https://netdata.cloud/img/network-wired.svg" width="150"/> |
| 17 | |
| 18 | |
| 19 | Plugin: netflow-plugin |
| 20 | Module: ip2location |
| 21 | |
| 22 | <img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" /> |
| 23 | |
| 24 | ## Overview |
| 25 | |
| 26 | Enrich network flows with country codes from the IP2Location LITE |
| 27 | IP-Country database. The supported downloader source is the DB1 LITE CSV ZIP |
| 28 | (`IP2LOCATION-LITE-DB1.CSV.ZIP`), whose documented fields are |
| 29 | `ip_from`, `ip_to`, `country_code`, and `country_name`. |
| 30 | |
| 31 | IP2Location DB1 is country-only. It does not provide ASN, AS organization, |
| 32 | state, city, latitude, or longitude. Pair it with CAIDA, IPtoASN, DB-IP, or |
| 33 | MaxMind ASN data when you also need AS fields. |
| 34 | |
| 35 | For the IP-intelligence mechanism (lookup order, MMDB composition, refresh, |
| 36 | provider chains), see |
| 37 | [IP Intelligence](https://learn.netdata.cloud/docs/network-flows/enrichment). |
| 38 | |
| 39 | |
| 40 | The netflow plugin reads MMDB files only. Use Netdata's |
| 41 | `topology-ip-intel-downloader` to fetch the IP2Location LITE CSV ZIP, convert |
| 42 | the ranges to `topology-ip-geo.mmdb`, and write the file into the standard |
| 43 | auto-detected cache directory. The plugin reloads the generated MMDB |
| 44 | automatically when the file changes. |
| 45 | |
| 46 | |
| 47 | This integration is only supported on the following platforms: |
| 48 | |
| 49 | - Linux |
| 50 | |
| 51 | This integration runs as a single instance per Netdata Agent. |
| 52 | |
| 53 | |
| 54 | ### Default Behavior |
| 55 | |
| 56 | #### Auto-Detection |
| 57 | |
| 58 | Not used by the default install. After the downloader writes `topology-ip-geo.mmdb` into the standard cache path, the plugin auto-detects the generated file. |
| 59 | |
| 60 | #### Limits |
| 61 | |
| 62 | Country only. No ASN, AS name, state, city, latitude, or longitude are available from this source. |
| 63 | |
| 64 | #### Performance Impact |
| 65 | |
| 66 | Lookups are local MMDB reads after conversion. Memory use is mostly the mapped database file and the kernel page cache needed to keep active pages hot. |
| 67 | |
| 68 | ## Setup |
| 69 | |
| 70 | |
| 71 | ### Prerequisites |
| 72 | |
| 73 | #### Downloader with IP2Location LITE support |
| 74 | |
| 75 | Run the bundled downloader when available. Packaged 32-bit installs do not |
| 76 | include this binary: |
| 77 | |
| 78 | ```bash |
| 79 | sudo /usr/sbin/topology-ip-intel-downloader \ |
| 80 | --asn iptoasn:combined \ |
| 81 | --geo ip2location:country-lite |
| 82 | ``` |
| 83 | |
| 84 | `ip2location:country-lite` is valid only for `--geo`. The example pairs it |
| 85 | with IPtoASN so the resulting cache contains both AS and country fields. |
| 86 | |
| 87 | |
| 88 | #### IP2Location LITE license |
| 89 | |
| 90 | Review the IP2Location LITE terms before redistributing the data or |
| 91 | generated derivative files. The plugin consumes only the generated MMDB and |
| 92 | does not contact IP2Location during flow decoding. |
| 93 | |
| 94 | |
| 95 | |
| 96 | ### Configuration |
| 97 | |
| 98 | #### Options |
| 99 | |
| 100 | Once the downloader has produced an IP2Location-derived geo MMDB in the cache |
| 101 | directory, the plugin auto-detects it. To pin paths explicitly, set |
| 102 | `enrichment.geoip.geo_database` and keep `asn_database` pointed at your chosen |
| 103 | ASN provider. |
| 104 | |
| 105 | |
| 106 | <details open><summary>Config options</summary> |
| 107 | |
| 108 | |
| 109 | |
| 110 | | Option | Description | Default | Required | |
| 111 | |:-----|:------------|:--------|:---------:| |
| 112 | | enrichment.geoip.asn_database | Optional ASN MMDB paths supplied by another provider. | [] | no | |
| 113 | | enrichment.geoip.geo_database | Path to the IP2Location-derived geo MMDB. Empty = auto-detect from the cache directory. | [] | no | |
| 114 | | enrichment.geoip.optional | When true, missing or unreadable MMDBs are warnings, not fatal at startup. | false (true when auto-detected) | no | |
| 115 | |
| 116 | |
| 117 | </details> |
| 118 | |
| 119 | |
| 120 | |
| 121 | #### via File |
| 122 | |
| 123 | The configuration file name for this integration is `netflow.yaml`. |
| 124 | |
| 125 | |
| 126 | You can edit the configuration file using the [`edit-config`](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#edit-configuration-files) script from the |
| 127 | Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#locate-your-config-directory). |
| 128 | |
| 129 | ```bash |
| 130 | cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata |
| 131 | sudo ./edit-config netflow.yaml |
| 132 | ``` |
| 133 | |
| 134 | ##### Examples |
| 135 | |
| 136 | ###### After running the downloader with IPtoASN ASN and IP2Location country |
| 137 | |
| 138 | Auto-detection picks up both generated cache files. |
| 139 | |
| 140 | ```yaml |
| 141 | enrichment: |
| 142 | geoip: |
| 143 | asn_database: [] |
| 144 | geo_database: [] |
| 145 | optional: true |
| 146 | |
| 147 | ``` |
| 148 | ###### Explicit IP2Location country path |
| 149 | |
| 150 | Pin IP2Location for country and keep a separate ASN source. |
| 151 | |
| 152 | <details open><summary>Config</summary> |
| 153 | |
| 154 | ```yaml |
| 155 | enrichment: |
| 156 | geoip: |
| 157 | asn_database: |
| 158 | - /var/cache/netdata/topology-ip-intel/topology-ip-asn.mmdb |
| 159 | geo_database: |
| 160 | - /var/cache/netdata/topology-ip-intel/topology-ip-geo.mmdb |
| 161 | optional: false |
| 162 | |
| 163 | ``` |
| 164 | </details> |
| 165 | |
| 166 | |
| 167 | |
| 168 | ### ASN fields are empty |
| 169 | |
| 170 | IP2Location DB1 is country-only. Configure `--asn iptoasn:combined`, |
| 171 | `--asn caida:prefix2as`, or another ASN provider in the downloader. |
| 172 | |
| 173 | |
| 174 | ### City or coordinates are empty |
| 175 | |
| 176 | The DB1 LITE source does not include city, state, latitude, or longitude. |
| 177 | Use DB-IP city-lite, MaxMind GeoLite2 City, GeoIP2 City, or a custom MMDB |
| 178 | when those fields are required. |
| 179 | |
| 180 | |
| 181 | ### Stale country data |
| 182 | |
| 183 | Check the upstream IP2Location LITE page for the current version and next |
| 184 | update date, then schedule the downloader accordingly. The plugin reloads |
| 185 | the generated MMDB in place when the file signature changes. |
| 186 | |
| 187 | |
| 188 |