mod-cidr
apt-get install cargo llvm-dev libclang-dev clang apache2-dev libapr1-dev
git clone https://gitlab.com/edneville/mod-cidr.git
cd mod-cidr
cargo build --release
You'll need to build a CIDR database.
Copy the module and the database file.
rsync -avP target/release/libmod_cidr_ng.so --rsync-path 'please rsync' remote:/usr/lib/apache2/modules/libmod_cidr_ng.so
rsync -avP ipdb.cdb --rsync-path 'please rsync' remote:/usr/local/share/
Tell Apache where to find the DB file and how to load the module
echo "LoadModule cidr_ng_module /usr/lib/apache2/modules/libmod_cidr_ng.so" | please tee /etc/apache2/mods-available/cidr-ng.load
please a2enmod cidr-ng
In a vhosts file
CIDR_NG_FILE /usr/local/share/ipdb.cdb
Then reload apache
please systemctl reload apache2
With the module loaded requests will now have headers added to them with values from the CDB, along with CIDR_match to show the matching CIDR range:
< Mod-Cidr-Ng-Version: 0.2.0
< CIDR_match: 51.6.0.0/15
< CIDR_ASNDESC: PLUSNET UK Internet Service Provider
< CIDR_ASNCC: GB
< CIDR_ASN: 6871
< CIDR_NET: 51.6.0.0/15
< Mod-Cidr-Ng: :-)