0

我可以在 apache 模块中阻止 IP 地址吗?

我搜索了它,但它没有给出答案,是真的吗?

4

1 回答 1

1

您可以使用 iptables 阻止。用一个简单的规则。但是,如果您担心某些 IP 地址会导致 DOS 攻击或其他原因,则可以使用 DOS deflate 程序将其自动添加到您的黑名单中。为了您的方便,我在下面提供它。

此脚本将有助于保护我们服务器上的 dos 攻击。我们将使用 DDos deflate 方法。

此方法将使用 iptables 阻止任何 dos 流量。并将创建一个每分钟执行一次以执行脚本的 cronjob,然后脚本将监视任何威胁并使用 iptables 阻止它们。

1. Install the deflate script

    wget http://www.mattzuba.com/wordpress/wp-content/uploads/2011/02/ddos_deflate-0.7.tar.gz

    tar -xf ddos_deflate-0.7.tar.gz

    cd ddos_deflate-0.7

    sudo ./install.sh

2. now the above script is installed in the directory /usr/local/ddos


    cd /usr/local/ddos


you will see a file called ddos.conf, edit the file


    vi ddos.conf

在这里你会看到各种选项,寻找#####多少个连接定义了一个坏IP?在下面指出。

NO_OF_CONNECTIONS=xyz

change no of connections to 200

    NO_OF_CONNECTIONS=200

其中 200 是一个 IP 地址在一秒钟内允许的总连接数。数量可根据需要增加或减少。超过定义数量的连接将被视为 dos 攻击。

3. setting ip address block time    


    cd /usr/local/ddos

you will see a file called ddos.conf, edit the file

    vi ddos.conf

and look for  ##### Number of seconds the banned ip should remain in blacklist.
BAN_PERIOD=60

change ban period to 


    BAN_PERIOD=600 

其中 600 是 IP 地址将被阻止的秒数,之后它将被释放。可以根据需要更改此编号。

4. allow selected ip address to access the system without getting banned or restrictions.


    cd /usr/local/ddos

you will see a file called ignore.ip.list, edit the file

    vi ignore.ip.list


enter the following ip address to be unblocked

    127.0.0.1  ----> the localhost ip address
    92.235.247.186 ----> public ip address of the server (change as required)

希望这有所帮助。

于 2013-04-16T16:44:24.390 回答