This lesson will teach you on how to block visits from countries to your site.
This can be achieved by a number of ways and they are as mentioned below. But all these ways have one thing in common and that is the IP range of the countries. The only way to understand the country from which the access is originated is by identifying the specific IP ranges that is assigned to it. The 32 is part of what is called CIDR (Classless Inter-Domain Routing) which is used to represent a range of IP addresses. You can find the details of IP ranges of countries by accessing here.
1) CDN level blocking.
This can be done by enabling cloudflare on your cPanel account and using their tool ‘threat control’ where you can add the IP address range for a particular nation.
2) Firewall level blocking.
You need to install Config Server firewall which is a reliable and efficient firewall software available for Linux and it’s integrated with WHM. It offers a lot of features to customize the firewall on the server.
Before the installation of csf you should check if APF is already installed on the server, if it is installed you would need to remove it.
rpm –qa |grep –i apf
1) Access the server via SSH and execute the commands mentioned below.
wget http://www.configserver.com/free/csf.tgz tar -xzf csf.tgz cd csf sh install.sh
Now the installation has completed and you can access the csf right the server WHM. on the left side bar you will see “ConfigServer security & Firewall ”.
IP addresses can be blocked both from WHM and server backend.
Here are the most common commands you will be using from backend:-
csf -d IPADDRESS will deny an IP.
csf -a IPADDRESS will allow an IP.
csf -r will reload all rules.
Whenever you apply rules to the firewall, you should restart it in the end.
3) Webserver level blocking:
In this case you don’t need to install any third party application as this is being handled by the webserver itself.
1) Access cPanel
2) Go to File Manager and open your document root (/home/accountname/public_html)
3) Open .htaccess file, it is not available already you need to create one.
4) You can generate block code from here
Using this tool will let you download a text file with the code needed to block a country. Copy and paste the code to the.htaccess file. Do not forget to save the file. Now any IP from those ranges are now denied access to your site.
These guys do a great job. Keep up the good work AIMVM team. www.marghotels.comAisten Correya
When choosing a hosting provider, I’m looking for fast, knowledgeable support and reliable systems. aimvm.com provided it all at a great price. www.tranzmedia.inTranzmedia