Monday, 16 May 2011

Ubuntu - Get location using Maxmind

This is problem when I protected my VPS by DDoS. I just want to get location IP to filter attacker, but maybe my website make so much requests to API location website, and so they blocked me.

I must spent a lot of times to get the reason why my Firewall not works. And problem come from API location website. If you want to get location IP, just use Maxmind in Ubuntu. It's free 99.5% is correct.

This is structure how to use it:
  1. sudo apt-get install geoip-database
  2. sudo apt-get install geoip-bin
And using this command to get Location:
  • geoiplookup {$ip} -> GeoIP Country Edition: BR, Brazil
  • geoiplookup {$ip} | awk '{print substr($4, 1, 2)}' -> BR
One more thing. You must update library of this application every month at 1st.
  1. Download this file: http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
  2. http://geolite.maxmind.com/download/geoip/database/
  3. Decompress and move all file to /usr/share/GeoIP/
  4. Not tested!

Good luck!

No comments:

Post a Comment