Recipe 8.10. Tracking and Blocking Visitors Based on Their IP Numbers


You need to determine the geographic location or Internet service provider of a visitor, possibly because you suspect he is attempting to abuse or defraud your site.


Make a note of the visitor's IP number, and then submit the IP number as a query to the American Registry for Internet Numbers (ARIN) whois search form at


IP numbers are unique identifiers for every machine connected to the Internet. They take the form of a dotted quadfour numbers between 0 and 255 separated by periods. For example, my PC's IP number is

You should be able to get the IP number of a visitor from your web server access log or from your online store transaction records. If you receive an email from a visitor and can view the message header information with your email client, you might be able to get an IP number that way, too.

Search results from the ARIN database should supply you with the name, address, and phone number of the owner of the IP number (typically, the IP address belongs to an Internet service provider, not the end user). If the number is not in the ARIN registry, the results page might refer you to another regional registry where you can try another search. With this information, you can contact the ISP and report the suspicious activity.

You also might want to deny the visitor access to your site by blocking his IP number. Adding a few lines to an .htaccess file in your web site's root directory will prevent a specific IP number from accessing your web site:

 <Limit GET POST> order allow,deny allow from all deny from </Limit> 

To block a group of similar IP addressessince dialup accounts usually get a different IP for each online sessionleave off the last dot and quad:

 <Limit GET POST> order allow,deny allow from all deny from 70.113.31 </Limit> 

This rule will block all 256 possible IP numbers between and Bear in mind when using this technique that when you deny large groups of IP addresses, you stand a good chance of blocking legitimate access to your site.

See Also

The Net World Map project web site provides some additional geographic information for IP numbers searched against their database (at, but the results can be sketchyand the site design is cheesy.

Web Site Cookbook.
Web Site Cookbook: Solutions & Examples for Building and Administering Your Web Site (Cookbooks (OReilly))
ISBN: 0596101090
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Doug Addison

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: