views:

30

answers:

1

I want to serve east (west) coast visitors with my Virginia (California) server. To do so, I plan to use Geoipdns and the IP-to-location mappings from MaxMind. MaxMind provide two datasets for free: GeoLite Country and GeoLite City. However, neither of them has east/west coast regions defined. A possible solution is to write a script to combine all the IP ranges for the east/west coast cities in GeoLite City, but that sounds a little bit stupid.

What is the best practice in doing this? Any suggestions or alternatives?

+1  A: 

You're overthinking the problem.

The GeoIP City API gives you a state code.

Spend ten minutes, and make a list of states that you want to send to your secondary server.

In Perl:

my %west_coast_states = qw( ca or wa ut nv ... ); 
my $state = ip_to_state_code();
if (defined $state and $west_coast_states{$state}) {
    # send West Coast states to West Coast server
} else {
    # all other users sent to East Coast server
}
Anirvan