After my last blog I needed to setup Geographic IP support in BIND. Apparently Debian ships with the patch from Caraytech already so there isn’t any patching needed, just configuration.
First off, because we’re using views in BIND we need to remove the inclusion for /etc/bind/named.conf.default-zones in /etc/bind/named.conf – so you can do that with vi or your editor of choice.
Secondly so we don’t have to duplicate zone definitions I created /etc/bind/named.conf.zones for domains that do not require Geographic IP support. I’ve then included it in each view on the config below.
We then we need to edit /etc/bind/named.conf.local to have something like this:
view “Australiasia” {
match-clients { country_AU; country_NZ; };
recursion no;
include “/etc/bind/named.conf.default-zones”;
include “/etc/bind/named.conf.zones”;
zone “example.com” {
type master;
file “/etc/bind/geoip/au.example.com.hosts”;
};
};
view “Europe” {
match-clients { country_AD; country_AL; country_AM; country_AT;
country_AZ; country_BA; country_BE; country_BG; country_BY;
country_CH; country_CZ; country_DE; country_DK; country_EE;
country_ES; country_FI; country_FR; country_GE; country_GR;
country_HR; country_HU; country_IE; country_IS; country_IT;
country_KZ; country_LI; country_LT; country_LU; country_LV;
country_MC; country_MD; country_ME; country_MK; country_MT;
country_NL; country_NO; country_PL; country_PT; country_RO;
country_RS; country_RU; country_SE; country_SI; country_SK;
country_SM; country_TR; country_UA; country_UK; country_VA; };
recursion no;
include “/etc/bind/named.conf.default-zones”;
include “/etc/bind/named.conf.zones”;
zone “example.com” {
type master;
file “/etc/bind/geoip/eu.example.com.hosts”;
};
};
view “Default” {
match-clients { any; };
recursion no;
include “/etc/bind/named.conf.default-zones”;
include “/etc/bind/named.conf.zones”;
zone “example.com” {
type master;
file “/etc/bind/geoip/us.example.com.hosts”;
};
};
With that all done we also need to keep in mind that AXFR zone transfers will not work with GeoIP. This is why I’ve placed the GeoIP zones in /etc/bind/geoip – so that with some scripting magic we can use rsync and when the files are changed, reload BIND (this script I’ve omitted as I believe its my intellectual property).
Enjoy.
UPDATE: Provided some further configuration here.