Select Page

I have a client who needs to host graphic content closer to their audience, partly to speed things up for their audience but also to allow them to save some money on bandwidth bills by spreading it out to cheaper hosts.
The obvious answer is to just use Akamai, but unless you have a huge amount of bandwidth it does not really make financial sense. So I proposed we get a few UML / Virtual Machines at ISPs and host the images there. Typically we’d just round-robin the A record but this doesn’t give us any geo-awareness.
I googled a bit and came across a guy who made a patch to bind 9.2.4. He bascially hooks the Maxmind GeoIP C Library into ISC Bind. As it turns out thats exactly the version RedHat uses in their Enterprise distribution so it seemed like a winner.
The basic idea is to setup a view that matches countries rather than just IP Blocks as is the default supported scenario. A sample view:

view "us" {
match-clients { country_US; };
zone "" {
type master;
file "data/";
view "other" {
match-clients { any; };
zone "" {
type master;
file "data/";

The above will serve to visitors from the United States and everyone else will get These 2 zone files are stock standard bind zone files, my sample just set a different A record in each.
To see this in action, first a query from my UK hosted machine:

% host has address

and now a query from the states:

% host has address

So to make a long story short, I’ve patched the stock RedHat Enterprise 4 bind RPM with the GeoDNS patch and am making the files available here, first I have the source files up if you want to look through them to ensure I didn’t put any funny stuff in them:
The actual patch from GeoDNS – I had to modify the file names in the patch since the one from the source site is made to patch from outside the bind source dir while RPM will change directory into the source directory before running the patch.
Changes made to the RPM Spec file
Sample config – this gets placed in the standard documentation directory
I’ve build a full RPMs of this on a CentOS 4.3 machine, the files are:
and finally a Source RPM that you can use to build this all on your own machine:
Before you can install these you’ll need to get GeoIP on your machine, CentOS has an extras Yum repository that you can enable in /etc/yum.repos.d/CentOS-Base.repo. Once enabled you can install it with yum:

# yum install GeoIP GeoIP-data
Running Transaction
Installing: GeoIP                        ######################### [1/2]
Installing: GeoIP-data                   ######################### [2/2]
Installed: GeoIP.i386 0:1.3.14-2.c4 GeoIP-data.i386 0:20060501-2.c4

RedHat Enterprise has an extras CD, you can find GeoIP on there and install it using RPM.
The bind RPMs above should simply install on your standard CentOS/RedHat Enterprise box, be sure to remove all the old bind stuff especially bind-libs before installing these.