how I can block a whole host (internet provider), or allow only one country for ssh login?
feedback
|
migrated from stackoverflow.com Jun 13 '10 at 17:36
This question came from our site for professional and enthusiast programmers.
|
1.) Lookup the IP addresses of a specific ISP: You'll have to use Google and search WHOIS records. You can also get hold of an ip2location database which should help. 2.) The command you need is: Replace the IP (192.168.100.0) with your start IP of the range to block and the number afterwards with a netmask (see: http://www.computerhope.com/jargon/n/netmask.htm to work out what number you need) depending on how far you want to go, block-wise. | ||||
|
feedback
|
|
iptables GeoIP extension allows you to create rules matching by country. Unfortunately GeoIP is not part of standard iptables/netfilter, so you need to hack around a bit to get it enabled. | |||
|
feedback
|
|
In blogama you can pick the country you'd like to block. (i.e) CN China Now, if you want to get the whole IP range for China, just query in the following address
I found this a little bit tedious, so I made a script:
The script will generate a list with the iptables syntax, based on the country you picked.Afterwards you can add that file to your rules
Caveat: Too many rules will make you connection slower because the incoming packets will be matched against every rule you added. | |||||
feedback
|