Difference between revisions of "How to block country IP"

From Kolmisoft Wiki
Jump to navigationJump to search
 
(3 intermediate revisions by 2 users not shown)
Line 4: Line 4:


DISCLAIMER - we are not against the Palestine or People of Palestine. We are against hackers from Palestine.
DISCLAIMER - we are not against the Palestine or People of Palestine. We are against hackers from Palestine.
Here we will provide guide how to block whole country. For this example we will block Palestine - from where most VoIP attacks are originating.




Line 15: Line 13:
Download list of IP ranges from http://www.ipdeny.com/ipblocks/data/countries/
Download list of IP ranges from http://www.ipdeny.com/ipblocks/data/countries/


  wget http://www.ipdeny.com/ipblocks/data/countries/pl.zone
  wget http://www.ipdeny.com/ipblocks/data/countries/ps.zone


Create list for in ipset for Palestine IPs:
Create list in ipset for Palestine IPs:


  ipset create palestine hash:net
  ipset create palestine hash:net
Line 23: Line 21:
Import IP list from file to ipset list:
Import IP list from file to ipset list:


  while read LINE; do ipset add palestine $LINE; echo -ne $LINE ' \r'; done < pl.zone
  while read LINE; do ipset add palestine $LINE; echo -ne $LINE ' \r'; done < ps.zone


Add rule to iptables, which instructs to drop packets coming from IPs within list:
Add rule to iptables, which instructs to drop packets coming from IPs within list:
Line 32: Line 30:




You can repeat same for other countries. By replacing "pl" with two letters code of other country (visit http://www.ipdeny.com/ipblocks/data/countries/ to see whole list). Also replacing "palestine" name to name of other country.
You can repeat same for other countries. By replacing "ps" with two letters code of other country (visit http://www.ipdeny.com/ipblocks/data/countries/ to see whole list). Also replacing "palestine" name to name of other country.


NOTE: configuration needs to be repeated after server reboot.
NOTE: configuration needs to be repeated after server reboot.

Latest revision as of 12:30, 14 July 2016

Palestine hacker.jpg

Here we will provide guide how to block whole country. For this example we will block Palestine - from where most VoIP attacks are originating.

DISCLAIMER - we are not against the Palestine or People of Palestine. We are against hackers from Palestine.


Install ipset tool:

yum -y install ipset

Download list of IP ranges from http://www.ipdeny.com/ipblocks/data/countries/

wget http://www.ipdeny.com/ipblocks/data/countries/ps.zone

Create list in ipset for Palestine IPs:

ipset create palestine hash:net

Import IP list from file to ipset list:

while read LINE; do ipset add palestine $LINE; echo -ne $LINE ' \r'; done < ps.zone

Add rule to iptables, which instructs to drop packets coming from IPs within list:

iptables -I INPUT -m set --match-set palestine src -j DROP

Configuration is completed.


You can repeat same for other countries. By replacing "ps" with two letters code of other country (visit http://www.ipdeny.com/ipblocks/data/countries/ to see whole list). Also replacing "palestine" name to name of other country.

NOTE: configuration needs to be repeated after server reboot.