contrib: geoip: add geoip python script
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest1 patch 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/1 | contrib: geoip: add geoip python scriptcontrib/ contrib/ | +561 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH nftables geoip 0/1] contrib: geoip: add geoip python script
This patch adds a python script which generates .nft files that contains mappings between the IP address and its geolocation.
It requires two csv files:
1) location database, this is stored in the location.csv file. This is currently a modified version of
https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.csv
You can specify the location database path via the --file-location
2) geoip database. Provided by db-ip.com. This csv file can be downloaded with the --download option.
You can also specify the file through --file-address
This script generates the following output files:
geoip-def-*.nft: contains definitions for countries of a continent to its 2-digit iso-3166 code
geoip-ipv{4/6}.nft: contains maps for ip blocks mapped to the 2-digit iso-3166 value of the country.
Output directory can be specified with '-o' option. It must be an existing directory.
Example, a counter of input packets from Spanish addresses, (there is a folder named "test-geoip" in the current directory):
./nft_geoip.py -o test-geoip/ --file-location location.csv --download
Then you can include the country definitions "geoip-def-all.nft" and geoip "geoip-ipv{4,6}.nft".
table filter {
include "./geoip-def-all.nft"
include "./geoip-ipv4.nft"
include "./geoip-ipv6.nft"
chain input {
type filter hook input priority filter; policy accept;
meta mark set ip saddr map @geoip4
meta mark $ES counter
}}
Jose M. Guisado Gomez (1):
contrib: geoip: add geoip python script
contrib/geoip/location.csv | 251 ++++++++++++++++++++++++++++++ contrib/geoip/nft_geoip.py | 310 +++++++++++++++++++++++++++++++++++++ 2 files changed, 561 insertions(+) create mode 100644 contrib/geoip/location.csv create mode 100755 contrib/geoip/nft_geoip.py
Signature · 1 line
2.23.0