How to Block Any IP for WordPress Blog or Any Website
I have been observing that some IP addresses have been hitting some of websites lately and their attempts were consistent. So I have banned those IP to access my websites. This secures your website and saves bandwidth. I will tell you here how you can do this too. If you are a webmaster or site owner then you may have noticed certain IP addresses trying to bring your website down sometimes. The best you can do to block them is to ban them. For website you can use .htaccess file for that and for WordPress you have options of .htaccess file and some plugins. We we study different ways to ban IP, IP range or multiple IP to access your website.
WordPress Blog Default IP Ban
WordPress has a capability to ban or blacklist keywords and IP. For that go to admin:
Settings > Discussions > Comment Blacklist
and enter one keyword or IP per line to black or blacklist all spammers to keep them away from your blog comments area.
Using .htaccess to Ban IP
To block certain IP address from accessing your website / blog, just create a file with name .htaccess at your webhost root directory with the content below:
order allow,deny deny from 192.168.0.1 allow from all
Block Multiple IP Address
order allow,deny deny from 192.168.0.2 deny from 192.168.0.3 deny from 192.168.0.4 allow from all
Block an IP Network Range
order allow,deny deny from 129.0.0 allow from all
Using Wild Card IP Ban
Anyone at all with an IP that starts 189.189 will be blocked.
deny from 189.189.*.*
WP Ban WordPress Plugin
If you use WordPress and want to block some IP adresses permanently then you can use a plugin called WP-Ban. It will display a custom ban message when the banned IP, IP range, host name or referer url try to visit you blog. You can also exclude certain IPs from being banned. There will be statistics recorded on how many times they attempt to visit your blog. It allows wildcard matching too.