Blogs

Linux IP tables rule to block every thing but the United States

admindoom's picture
»

Attached is an iptables rule set for allowing all IPs from the United States, then denying everything else.

This was generated with the help of this site
http://www.blockacountry.com/
Which is where I got all of the Ips from. That site gave me a list of about 36000 ip blocks. Using a little perl script (also attached) I was able to reduce that to 15000 lines.

Which might work better for those of you whos system has issues loading huge iptables lists.

Share and enjoy.

Submitted by admindoom on Tue, 07/01/2008 - 14:35