Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Quick `whois` Country Lookups?

Quick `whois` Country Lookups?
Thread Tools
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Apr 23, 2010, 06:21 AM
 
Here's my situation. Particularly on my Mac repair website, I get lots of 1-off contact form spam. 1-off meaning its not a bot, it's an actual person. That person is in china, and wants me to buy knock-off Apple parts from them. It's a form so I can easily test the sender's IP and block anyone in China and/or Korea. So I'm wondering if there are any fast/easy/short cut ways to do country-only whois lookups. I have a Maxmind account for another website, but I don't want to pay for my lookups. And a full whois from the terminal will give the country, but thats really slower than what I'd like. Plus it outputs a huge long mess, not the clean and easily machine readable results I'd like.
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Apr 23, 2010, 11:22 AM
 
You could come up with your own GeoIP based spam filter, do you run your own SMTP server?

Other ways:

- firewall block China from even accessing your website
- update your form processing at the application level to omit submissions from Chinese IP blocks
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 16, 2010, 10:28 PM
 
The geoiplookup binary included in the GeoIP C package is very straight forward:

# geoiplookup forums.macnn.com
GeoIP Country Edition: US, United States
It would not be terribly hard to create a very simple GeoIP based SMTP gateway.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 16, 2010, 10:31 PM
 
What does that program use to do the lookups?
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 16, 2010, 10:40 PM
 
Itself, the GeoIP database:

MaxMind - GeoLite Country | Open Source IP Address to Country Database

You can download the SQL based database of netblock to country mappings, or use the C binary for faster lookups which is what I did above. A lot of applications and companies rely on this tool.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:55 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2