wordpress ip_如何在WordPress中阻止IP地址

wordpress ip

Do you want to block specific IP addresses from accessing your WordPress site? Blocking IP addresses is used as a solution to block spam and hacking attacks on your website. In this article, we will show you how to block IP addresses in WordPress, and we will also show you how to find out which IP addresses needs to be blocked.

您是否要阻止特定的IP地址访问您的WordPress网站? 阻止IP地址用作阻止网站上的垃圾邮件和黑客攻击的解决方案。 在本文中,我们将向您展示如何在WordPress中阻止IP地址,并且还将向您展示如何找出需要阻止哪些IP地址。

How to Block IP Addresses in WordPress
什么是IP地址? (What is an IP Address?)

If internet was a physical world, then think of IP addresses as country, street, and house numbers. They are basically 4 sets of numbers from 0-255 separated by dots and look like this:

如果互联网是一个物理世界,则将IP地址视为国家,街道和门牌号。 它们基本上是4组数字,从0-255之间用点分隔,看起来像这样:

172.16.254.1

172.16.254.1

Each computer connected to the internet has an IP address assigned to them by their internet service provider.

连接到互联网的每台计算机都有一个由其互联网服务提供商分配的IP地址。

All visitors to your website have an IP address which is stored in your website’s access log files. This means that all websites that you visit also stores your IP address.

您网站的所有访问者都有一个IP地址,该IP地址存储在您网站的访问日志文件中。 这意味着您访问的所有网站也会存储您的IP地址。

You can hide this information by using a VPN service. This allows you to hide your IP address and other personal information.

您可以使用VPN服务隐藏此信息。 这使您可以隐藏IP地址和其他个人信息。

为什么和何时需要阻止IP地址? (Why & When You Need to Block IP Addresses?)

Blocking an IP address from accessing your website is an effective way to deal with unwanted visitors, comment spam, email spam, hacking attempts, and DDOS (denial of service) attacks.

阻止IP地址访问您的网站是一种有效的方法,可应对有害访问者,评论垃圾邮件,电子邮件垃圾邮件, 黑客攻击和DDOS(拒绝服务)攻击。

The most common sign that your website is under a DDOS attack is that your website will frequently become inaccessible or your pages will start taking forever to load.

您的网站受到DDOS攻击的最常见迹象是,您的网站将经常无法访问,或者您的页面将永远被加载。

The other attacks are more obvious such as when you start getting spam comments or a lot of spam emails from your contact form. We have a list of ways to fight spam comments, but the last solution is to block IP addresses.

其他攻击更为明显,例如当您开始从联系表中收到垃圾邮件评论或大量垃圾邮件时。 我们提供了一系列打击垃圾邮件评论的方法 ,但是最后一种解决方案是阻止IP地址。

找出要在WordPress中阻止的IP地址 (Finding Out IP Addresses You Want to Block in WordPress)

WordPress stores an IP addresses for users that leave a comment on your website. You can see their IP address by visiting the comments page in your WordPress admin area.

WordPress为在您的网站上发表评论的用户存储IP地址。 您可以通过访问WordPress管理区域中的评论页面来查看其IP地址。

IP addresses stored in WordPress comments

If your website is under DDOS attack, then the best way to locate the IP addresses is by checking your server’s access log.

如果您的网站受到DDOS攻击,那么查找IP地址的最佳方法是检查服务器的访问日志。

To see those logs, you will need to login to the cPanel dashboard of your WordPress hosting account. Next, locate the ‘logs’ section and click on the ‘Raw Access Logs’ icon.

要查看这些日志,您将需要登录到WordPress托管帐户的cPanel仪表板。 接下来,找到“日志”部分,然后单击“原始访问日志”图标。

Raw access logs

This will take you to the access logs page where you need to click on your domain name to download the access logs file.

这将带您进入访问日志页面,您需要在其中单击域名以下载访问日志文件。

Download access log file

Your access log file will be inside a .gz archive file. Go ahead and extract the file by clicking on it. If your computer does not have a program to handle .gz archive files, then you will need to install one. Winzip or 7-zip are two popular choices among Windows users.

您的访问日志文件将位于.gz存档文件中。 继续并通过单击提取文件。 如果您的计算机没有用于处理.gz存档文件的程序,则需要安装一个程序。 Winzip7-zip是Windows用户中的两个流行选择。

Inside the archive, you will see your access log file which you can open in a plain text editor like Notepad or TextEdit.

在档案内部,您将看到访问日志文件,可以在纯文本编辑器(如记事本或TextEdit)中打开该文件。

The access log file contains raw data of all requests made to your website. Each line begins with the IP address making that request.

访问日志文件包含对您的网站的所有请求的原始数据。 每行都以发出该请求的IP地址开头。

IP addresses in access log file

You need to make sure that you don’t end up blocking yourself, legit users, or search engines from accessing your website. Copy a suspicious looking IP address and use online IP lookup tools to find out more about it.

您需要确保最终不会阻止自己,合法用户或搜索引擎访问您的网站。 复制外观可疑的IP地址,然后使用在线IP查找工具查找有关它的更多信息。

You will have to carefully look at your access logs for suspicious unusually high number of requests from a particular IP address. Tip: there’s a way to automate this that we share at the bottom of this article.

您将必须仔细查看您的访问日志,以查看来自特定IP地址的可疑异常大量请求。 提示:本文底部分享了一种自动化的方法。

Once you have located those IP addresses, you need to copy and paste them in a separate text file.

找到这些IP地址后,您需要将它们复制并粘贴到单独的文本文件中。

在WordPress中阻止IP地址 (Blocking IP Addresses in WordPress)

If you just want to stop users with a specific IP address from leaving a comment on your site, then you can do that inside your WordPress admin area.

如果您只想阻止具有特定IP地址的用户在您的网站上发表评论,则可以在WordPress管理区域内进行操作。

Head over to Settings » Discussion page and scroll down to ‘Comment Blacklist’ text box.

转到“设置”»“讨论”页面,然后向下滚动到“评论黑名单”文本框。

Blacklist IP addresses in WordPress comments

Copy and paste the IP addresses that you want to block and then click on the save changes button.

复制并粘贴您要阻止的IP地址,然后单击“保存更改”按钮。

WordPress will now block users with these IP addresses from leaving a comment on your website. These users will still be able to visit your website, but they will see an error message when they try to submit a comment.

WordPress现在将阻止具有这些IP地址的用户在您的网站上发表评论。 这些用户仍然可以访问您的网站,但是当他们尝试提交评论时,他们会看到错误消息。

使用cPanel阻止IP地址 (Blocking an IP Address Using 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.

此方法完全阻止IP地址访问或查看您的网站。 当您想保护WordPress网站免受黑客攻击和DDOS攻击时,应使用此方法。

First, you need to login to cPanel dashboard of your hosting account. Now scroll down to the security section and click on ‘IP Address Deny Manager’ icon.

首先,您需要登录到托管帐户的cPanel仪表板。 现在向下滚动到“安全性”部分,然后单击“ IP地址拒绝管理器”图标。

IP Address Deny Manager tool in cPanel

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.

这将带您进入IP地址拒绝管理器工具。 您可以在此处添加要阻止的IP地址。 您可以添加一个IP地址或IP范围,然后单击添加按钮。

Blocking IP addresses in cPanel

You can come back to the same page again if you ever need to unblock those IP addresses.

如果您需要取消阻止这些IP地址,则可以再次返回同一页面。

如果IP地址阻止不起作用–自动化它! (When IP Address Blocking Doesn’t Work – Automate It!)

Blocking an IP address would work if you are just blocking some basic hacking attempts, specific users, or users from specific regions or countries.

如果您仅阻止一些基本的黑客攻击尝试,特定用户或特定区域或国家的用户,则阻止IP地址将起作用。

However, many hacking attempts and attacks are made using a wide range of random IP addresses from all over the world. It is impossible for you to keep up with all those random IP addresses.

但是,许多黑客尝试和攻击都是使用来自世界各地的各种随机IP地址进行的。 您不可能跟上所有这些随机IP地址。

That’s when you need a Web Application Firewall (WAF). For the WPBeginner website, we use Sucuri. It is a website security service that protects your website against such attacks using a website application firewall.

那就是您需要Web应用程序防火墙(WAF)的时候。 对于WPBeginner网站,我们使用Sucuri 。 它是一种网站安全服务,可使用网站应用程序防火墙保护您的网站免受此类攻击。

Basically, all your website traffic goes through their servers where it is examined for suspicious activity. It automatically blocks suspicious IP addresses from reaching your website altogether. See how Sucuri helped us block 450,000 WordPress attacks in 3 months.

基本上,您所有的网站流量都通过其服务器进行检查,以进行可疑活动。 它会自动阻止可疑IP地址完全访问您的网站。 了解Sucuri如何帮助我们在3个月内阻止450,000次WordPress攻击

We hope this article helped you learn how to easily block IP addresses in WordPress. You may also want to see our ultimate step by step WordPress security guide for beginners.

我们希望本文能帮助您学习如何轻松地在WordPress中阻止IP地址。 您可能还想看看我们针对初学者的终极逐步WordPress安全指南

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-block-ip-addresses-in-wordpress/

wordpress ip

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值