【问题标题】:Block IP address range with .htaccess使用 .htaccess 阻止 IP 地址范围
【发布时间】:2015-04-14 10:44:41
【问题描述】:

如何使用 .htaccess 阻止 IP 范围 103.4.8.0 - 103.4.15.255

我的意思是我想阻止

  • 103.4.8.0-103.4.8.255
  • 103.4.9.0-103.4.9.255
  • ..
  • 103.4.15.0-103.4.15.255

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    您可以使用 ip/网络掩码对给出地址范围:

    deny from 127.0.55.0/24
    

    但是,由于范围 55 - 75 不是 2 的幂,所以我不知道如何从中得出范围。我会添加几条规则。

    order allow,deny
    deny from 127.0.55.0/24  // Matches 55
    deny from 127.0.56.0/21  // Matches 56 to 64
    deny from 127.0.64.0/21  // Matches 64 to 71
    deny from 127.0.72.0/22  // Matches 72 to 75
    
    deny from 127.0.235.0/24 // Matches 235
    deny from 127.0.236.0/22 // Matches 236 to 239
    deny from 127.0.240.0/21 // Matches 240 to 255
    allow from all
    

    【讨论】:

    • 你从@Starkeen那里得到这些IP地址的?
    【解决方案2】:

    我最终使用了:

    <Limit GET HEAD POST>
    order allow,deny
    allow from all
    deny from 103.4.8.
    deny from 103.4.9.
    ..
    deny from 103.4.15.
    </Limit>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-01
      • 2015-04-21
      • 1970-01-01
      • 2016-06-09
      • 2011-09-14
      • 2010-11-04
      • 2013-08-24
      • 1970-01-01
      相关资源
      最近更新 更多