简体   繁体   中英

Block IP Address by Geographic Location

I would like to block IP address's from being able to create accounts from certain geographic areas, in short I think it is actually more prudent to make a list of the specific geographies where IP address's are acceptable. The website only services local persons and they are the only ones that will be granted access to the site on a user by user basis.

So is there a way of only accepting IP's from a geographic region while sending the ones outside of the specified region to a trash bin or something of that sort?

We are using Dolphin to run the website and it is to time consuming to ban the IP addresses that come in everyday. I have read through and have seen many posts describing a service called MaxMind, but we would like to implement something of our own.

Thank you.

You have to have to be able to map the IP addresses onto geographical locations. You mention the MaxMind API, which is one option. They also provide a downloadable database.

Assuming you're using php, if you can install the GeoIP package , it would be very easy to do it.

Just call the following function to get back the country code of the client.

$country_code = geoip_country_code_by_name($ip_address);

If you prefer to obtain geo infos through a web service (it will costs 20$ for 200.000 lookups) , look at the web api:

MaxMind Web API

PHP Example

Here's a list of possible country codes: Country Codes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM