Allow and Deny by IP Address
From Lunarpages Web Hosting Wiki
Having issues with somebody at a particular IP address that is giving you problems? Are they bugging your users or poking you with the proverbial stick of annoyance? There are two ways to block an IP, first through the IP Deny Manager in cPanel, and the other by manually editing your .htaccess file.
cPanel IP Deny Manager
Log into your cPanel and scroll down to the Security section and click the icon for IP Deny Manager.
Enter the IP address, or range, and click the Add button. Acceptable entries are:
- 10.5.3.333 (Single IP Address)
- 10.5.3.3-10.5.3.40 (Range)
- 10.5.3.5-40 (Implied Range)
- 10.5.3.3/32 (CIDR Format)
- 10. (Implies 10.*.*.*)
At the bottom of the page you will find a list of the current IP addresses being blocked. If you need to remove an IP address, click on the red X under the Remove column.
Editing your .htaccess file
To get this done, all you need to do is add this to your .htaccess file:
order allow,deny deny from XXX.XXX.XXX allow from all
Just replace the “XXX.XXX.XXX” with the IP address you wish to block. You can also add a second line like this if you wish to block multiple IP addresses:
order allow,deny deny from XXX.XXX.XXX deny from MMM.MMM.MMM allow from all
One last tip. If you want to block everybody from seeing your web site, just put in deny from all.
order deny,allow allow from QQQ.QQQ.QQQ allow from LLL.LLL.LLL deny from all
This would turn everybody away except for the people who have the IP address QQQ.QQQ.QQQ and LLL.LLL.LLL.
For more help with getting this done, check out the official Apache page on the process: