| 1 | <!--startmeta |
| 2 | custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/crates/netflow-plugin/integrations/ipip_country_database.md" |
| 3 | meta_yaml: "https://github.com/netdata/netdata/edit/master/src/crates/netflow-plugin/metadata.yaml" |
| 4 | sidebar_label: "IPIP Country Database" |
| 5 | learn_status: "Published" |
| 6 | learn_rel_path: "Network Flows/Enrichment Methods" |
| 7 | keywords: ['ipip', '17mon', 'geoip', 'country', '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 | # IPIP Country Database |
| 14 | |
| 15 | |
| 16 | <img src="https://netdata.cloud/img/network-wired.svg" width="150"/> |
| 17 | |
| 18 | |
| 19 | Plugin: netflow-plugin |
| 20 | Module: ipip |
| 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 IPIP's country database. The |
| 27 | supported downloader source fetches IPIP's `country.zip` archive and reads the |
| 28 | `country.txt` file, where each line maps a prefix to a country token. |
| 29 | |
| 30 | IPIP Country is country-only. The current `country.zip` source validated during |
| 31 | this work contained IPv4 prefixes only. It does not provide ASN, AS |
| 32 | organization, state, city, latitude, or longitude. Pair IPIP with another ASN |
| 33 | source when you also need AS fields, and use DB-IP, MaxMind, IP2Location, or a |
| 34 | custom MMDB when IPv6 country coverage is required. |
| 35 | |
| 36 | For the IP-intelligence mechanism (lookup order, MMDB composition, refresh, |
| 37 | provider chains), see |
| 38 | [IP Intelligence](https://learn.netdata.cloud/docs/network-flows/enrichment). |
| 39 | |
| 40 | |
| 41 | The netflow plugin reads MMDB files only. Use Netdata's |
| 42 | `topology-ip-intel-downloader` to fetch the IPIP country ZIP, convert the |
| 43 | prefix list to `topology-ip-geo.mmdb`, and write the file into the standard |
| 44 | auto-detected cache directory. The plugin reloads the generated MMDB |
| 45 | automatically when the file changes. |
| 46 | |
| 47 | |
| 48 | This integration is only supported on the following platforms: |
| 49 | |
| 50 | - Linux |
| 51 | |
| 52 | This integration runs as a single instance per Netdata Agent. |
| 53 | |
| 54 | |
| 55 | ### Default Behavior |
| 56 | |
| 57 | #### Auto-Detection |
| 58 | |
| 59 | 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. |
| 60 | |
| 61 | #### Limits |
| 62 | |
| 63 | Country-only source. The currently validated `country.zip` payload is IPv4-only and carries no ASN, AS name, state, city, latitude, or longitude. |
| 64 | |
| 65 | #### Performance Impact |
| 66 | |
| 67 | 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. |
| 68 | |
| 69 | ## Setup |
| 70 | |
| 71 | |
| 72 | ### Prerequisites |
| 73 | |
| 74 | #### Downloader with IPIP support |
| 75 | |
| 76 | Run the bundled downloader when available. Packaged 32-bit installs do not |
| 77 | include this binary: |
| 78 | |
| 79 | ```bash |
| 80 | sudo /usr/sbin/topology-ip-intel-downloader \ |
| 81 | --asn iptoasn:combined \ |
| 82 | --geo ipip:country |
| 83 | ``` |
| 84 | |
| 85 | `ipip:country` is valid only for `--geo`. The example pairs it with |
| 86 | IPtoASN so the resulting cache contains both AS and country fields. |
| 87 | |
| 88 | |
| 89 | #### IPIP data terms |
| 90 | |
| 91 | Review IPIP's current terms before redistributing the data or generated |
| 92 | derivative files. The plugin consumes only the generated MMDB and does not |
| 93 | contact IPIP during flow decoding. |
| 94 | |
| 95 | |
| 96 | |
| 97 | ### Configuration |
| 98 | |
| 99 | #### Options |
| 100 | |
| 101 | Once the downloader has produced an IPIP-derived geo MMDB in the cache |
| 102 | directory, the plugin auto-detects it. To pin paths explicitly, set |
| 103 | `enrichment.geoip.geo_database` and keep `asn_database` pointed at your chosen |
| 104 | ASN provider. |
| 105 | |
| 106 | |
| 107 | <details open><summary>Config options</summary> |
| 108 | |
| 109 | |
| 110 | |
| 111 | | Option | Description | Default | Required | |
| 112 | |:-----|:------------|:--------|:---------:| |
| 113 | | enrichment.geoip.asn_database | Optional ASN MMDB paths supplied by another provider. | [] | no | |
| 114 | | enrichment.geoip.geo_database | Path to the IPIP-derived geo MMDB. Empty = auto-detect from the cache directory. | [] | no | |
| 115 | | enrichment.geoip.optional | When true, missing or unreadable MMDBs are warnings, not fatal at startup. | false (true when auto-detected) | no | |
| 116 | |
| 117 | |
| 118 | </details> |
| 119 | |
| 120 | |
| 121 | |
| 122 | #### via File |
| 123 | |
| 124 | The configuration file name for this integration is `netflow.yaml`. |
| 125 | |
| 126 | |
| 127 | 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 |
| 128 | Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#locate-your-config-directory). |
| 129 | |
| 130 | ```bash |
| 131 | cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata |
| 132 | sudo ./edit-config netflow.yaml |
| 133 | ``` |
| 134 | |
| 135 | ##### Examples |
| 136 | |
| 137 | ###### After running the downloader with IPtoASN ASN and IPIP country |
| 138 | |
| 139 | Auto-detection picks up both generated cache files. |
| 140 | |
| 141 | ```yaml |
| 142 | enrichment: |
| 143 | geoip: |
| 144 | asn_database: [] |
| 145 | geo_database: [] |
| 146 | optional: true |
| 147 | |
| 148 | ``` |
| 149 | ###### Explicit IPIP country path |
| 150 | |
| 151 | Pin IPIP for country and keep a separate ASN source. |
| 152 | |
| 153 | <details open><summary>Config</summary> |
| 154 | |
| 155 | ```yaml |
| 156 | enrichment: |
| 157 | geoip: |
| 158 | asn_database: |
| 159 | - /var/cache/netdata/topology-ip-intel/topology-ip-asn.mmdb |
| 160 | geo_database: |
| 161 | - /var/cache/netdata/topology-ip-intel/topology-ip-geo.mmdb |
| 162 | optional: false |
| 163 | |
| 164 | ``` |
| 165 | </details> |
| 166 | |
| 167 | |
| 168 | |
| 169 | ### IPv6 country fields are empty |
| 170 | |
| 171 | The currently validated IPIP `country.zip` source contains IPv4 prefixes. |
| 172 | Use DB-IP, MaxMind, IP2Location, or a custom MMDB if IPv6 country |
| 173 | enrichment is required. |
| 174 | |
| 175 | |
| 176 | ### ASN fields are empty |
| 177 | |
| 178 | IPIP country data carries country prefixes only. Configure a separate ASN |
| 179 | provider in the downloader. |
| 180 | |
| 181 | |
| 182 | ### City or coordinates are empty |
| 183 | |
| 184 | The supported IPIP source is country-only. Use DB-IP city-lite, MaxMind |
| 185 | GeoLite2 City, GeoIP2 City, or a custom MMDB for richer geo fields. |
| 186 | |
| 187 | |
| 188 |