How To block some country from your server

Hello guys block

How to i Can Block specific country from my server?

Is it possible to do so?

Yes, definitely and very easily you can block certain countries from your server ?

Follow me step by step

step 1 :

What is the state required blocked?

For example, the State of Israel to block

i have get all ips country from : http://www.ip2location.com/free/visitor-blocker

select country and Select one output format from list. ( CIDR )

country-block

 

then start download ips list

Step 2 :

login ssh your server :

touch new file

touch /root/israel.txt

and paste ips

exp :

2.22.233.0/24
2.52.0.0/14
5.22.128.0/21
5.28.128.0/18
5.29.0.0/16
5.34.168.0/24
5.34.169.0/27
5.34.169.40/29
5.34.169.56/29
5.34.169.64/29
5.34.169.120/29
5.34.169.168/29
5.34.169.192/28
5.34.169.208/29
more ...

Step 3 :
touch new file block.sh and put this code :


#!/bin/bash
# www.east4serv.com

shit=”/root/israel.txt”
ips=$(grep -Ev “^#” $shit)
for ip in $ips
do
ip r a blackhole $ip
done

 

make sure replace israel.txt to your file name

 

step 4 :

run it : sh block.sh

 

now all done ?

If there are other questions i’m present for help via free support:

 

Regards 🙂

Share Button