Skip to content

Instantly share code, notes, and snippets.

@kolya-t
Created November 21, 2018 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolya-t/dde5bbf2cba581180f86e6fb2327aba8 to your computer and use it in GitHub Desktop.
Save kolya-t/dde5bbf2cba581180f86e6fb2327aba8 to your computer and use it in GitHub Desktop.
Script will create subnets directory with subnets
#!/bin/sh
# script will create 2 dirs iprange and subnets
# iprange dir will contain iprange tool
# subnets dir will contain GeoIP subnets files
# install iprange
mkdir iprange
cd iprange
wget https://raw.githubusercontent.com/haproxy/haproxy/master/contrib/iprange/Makefile
wget https://raw.githubusercontent.com/haproxy/haproxy/master/contrib/iprange/iprange.c
make
rm Makefile iprange.c
cd ..
# download GeoIP database
mkdir subnets
cd subnets
wget https://netcologne.dl.sourceforge.net/project/neustarwebtop/GeoIPCountryWhois.csv
cut -d, -f1,2,5 GeoIPCountryWhois.csv | ../iprange/iprange | sed 's/"//g' | awk -F' ' '{ print $1 >> $2".subnets" }'
rm GeoIPCountryWhois.csv
cd ..
rm -r iprange
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment