netvope
netvope

Reputation: 7967

Serving east/west coasts with Geoipdns and MaxMind GeoLite data

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?

Upvotes: 1

Views: 545

Answers (1)

Anirvan
Anirvan

Reputation: 6364

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 ($west_coast_states{$state}) {
    # send West Coast states to West Coast server
} else {
    # all other users sent to East Coast server
}

Upvotes: 2

Related Questions