Mod cidr

From usenix.org.uk
Jump to: navigation, search

mod-cidr is a way to perform hash lookups based on the inbound connection source in a network router style. This module is useful for geo-location or net block lookups. Information is set in the server headers retrieved from CDB hash. Lookups are extremely fast since CDB interface is very quick.

The latest copy of the module source can be found in the code directory here mod-cidr.

The module has the following directives:

directive definition
CIDR_CDB_File CIDR CDB File location. This is the location of the file that should be used for making lookups against.

This module creates the following environment variables

variable purpose
CIDR_CC CIDR country code - this is probably the most useful variable for you
CIDR_MASK This is the network mask for the matching net block
CIDR_RANGE This is the block size for the network mask
CIDR_RIR This is the Regional Internet registry

So you can pick these variables out from your CGI or just put them into your log, which ever you find the most useful or interesting.

building

This module has been packaged in a way that should be easy for building. This is mostly since DJB has released his code to the public domain (which was a really good move).

Untar the source code and build:

tar -zxvf mod_cidr-latest.tar.gz
cd mod-cidr
make module

When you make this module it will automatically be installed and linked into your apache configuration - easy!

cdb file

You can create your own CDB File, or you can download the one which I use, for 32bit linux systems.

To create your own, make sure you have CDB_File installed. If you don't want or have access to install this library globally you might consider following the perl user space guide.


Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox