如何阻止linux服务器中多个ip adddress的意外请求?

时间:2015-06-12 11:20:39

标签: php linux wordpress brute-force ddos

我从最近几天的某个时间收到多个IP地址的意外请求。我在我的服务器上安装了一个wordpress网站,他们的人在我的wp-login.php页面上点击,在日志文件中我看到了类似的东西......

  

Blo [05 / Jun / 2015:06:19:14 +0200]“POST /wp-login.php HTTP / 1.0”503   2966“ - ”“hjelp.tips-info.com”“ - ”

然后我改变了这个文件的权限。但我仍然在错误日志文件中收到一些消息。他们仍然在该文件上发送一些帖子请求(wp-login.php)并返回404错误。有什么担心吗?我不知道。

我的服务器是否因处理这些错误请求而变慢?这个请求来自多个ip地址,所以我不能阻止那些ip。 我不知道这个问题,请有人帮助我。 感谢。

1 个答案:

答案 0 :(得分:0)

对于php,我有一个快速的解决方案。尝试将IP范围或特定IP置于阻止状态。

未经测试但我觉得它会起作用。您可能还需要根据自己的需要进行更改。

public static function isIpInRange($ip,$rangeArray){
    foreach ($rangeArray as $ipOrRange) {
        if(is_array($ipOrRange)){
            //If $ipOrRange is array then it must be range where 0th element is min range and 1st element is max range
            $min = ip2long($ipOrRange[0]);
            $max = ip2long($ipOrRange[1]);
            if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max)){
                return true;
            }
        }elseif($ip==$ipOrRange){
            return true;
        }
    }
    return false;
}

希望有所帮助!!