IP Address blocking is a security measure that prevents a connection between a specific or group of IP addresses and a mail, web or Internet server. This is usually done to ban or block any undesirable sites and hosts from entering the server or node and causing harm to a network of individual computers. IP blocking is usually used by companies and websites to prevent intrusion, block spam and protect against hacking attacks.
In this article, we will demonstrate how to block IP addresses within WordPress and also how to identify the necessary IP addresses to block.
Identifying The IP Addresses You Want To Block
There might be several instances when you will want to discover a certain IP address in order to block it. If someone is leaving spam comments on your page then you can head over to the “Comments” tab on the left-hand sidebar of WordPress Admin page. You will be able to see full details of including the IP address of any commenters.
If you find that your website is under an attack, for example, a DDOS attack, then the best way to locate the offending IP address is to head to your servers access log. You will need to login to the cPanel dashboard of your WordPress Hosting account and locate the ‘Logs’ section. Once there, click ‘Raw Access Logs’.
You will be redirected to the access logs page where your next step is to click on your Domain Name to download the access log file.
Once you have extracted the file by clicking on it, you will be shown your access log file. The best way to view this is with a plain text editor such as Notepad.
All the raw date of requests being made to your website are logged here, with each line beginning with the IP Address making that request.
We recommend copying any suspicious IP address and using this online IP lookup tool before you block any IP addresses, as you wouldn’t want to inadvertently block legitimate users. You want to check for IP addresses with an unusually high number of requests.
Once you have located any offending IP addresses, copy and paste them into a separate Notepad file.
Block IP Addresses In WordPress
If all you want to do is stop a specific IP address from leaving comments on your WordPress site, just head to the ‘Settings > Discussion’ page and scroll to the “Comment Blacklist” box. Paste any IP addresses you want to be blocked in this box and they will no longer be able to leave comments on your website.
Blocking An IP Address With cPanel
This method completely blocks an IP address from accessing or viewing your website. You should use this method when you want to protect your WordPress site from hacking attempts and DDOS attacks.
First, you need to login to cPanel dashboard of your hosting account. Now scroll down to the security section and click on the ‘IP Address Deny Manager’ icon. This will take you to the IP Address Deny Manager tool. Here you can add the IP addresses you want to block. You can add a single IP address or an IP range and then click on the add button.
Come back here to unblock any IP addresses.