Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I easily get the IP address blocks for a particular state or city within the US?

I was thinking that I could plug that into my iptables firewall to restrict traffic.

share|improve this question
3  
I'm not sure IP blocks are strictly allocated based on location. Many of the original blocks were allocated to multinational corporations. Do you have a specific need to block traffic from certain geographic locations? This sounds somewhat like hunting for a solution to a problem that doesn't exist, mostly since the geographic region of traffic's origin will likely play little role in the quality of traffic on this specific of a scale. –  Darth Android May 16 '12 at 19:46
3  
I will add that if you are trying to block traffic from individuals based on geographic location, it would be trivial for them to appear to be coming from a different location. –  EBGreen May 16 '12 at 19:52
    
MaxMind's GeoLite City is a free database that you can download that contains IP address to city mappings. –  David Schwartz May 16 '12 at 20:03
add comment

2 Answers

this is the service that I have used for that: http://www.maxmind.com/app/javascript_city

ips are not allocated based on state/city etc.

share|improve this answer
add comment

A lot of IPs are allocated by state and town or neighborhood. If you use any of the free IP lookup services you will see that this is so. You can also add code to your website to block access to any range of IP addresses that you want to block.

The only remaining task is to get a list of IP addresses by city or state. There have to be such lists, otherwise all those free IP lookup services would not work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.