代码之家  ›  专栏  ›  技术社区  ›  Adam Tuttle

如何在AWStats配置文件中为SkipHosts指定IP范围(RegEx)?

  •  1
  • Adam Tuttle  · 技术社区  · 17 年前

    我正在更新一些旧的AWStats配置文件,以筛选出一些特定的IP范围。以下是配置文件的相关部分:

    # Do not include access from clients that match following criteria.
    # If your log file contains IP addresses in host field, you must enter here
    # matching IP addresses criteria.
    # If DNS lookup is already done in your log file, you must enter here hostname
    # criteria, else enter ip address criteria.
    # The opposite parameter of "SkipHosts" is "OnlyHosts".
    # Note: Use space between each value. This parameter is not case sensitive.
    # Note: You can use regular expression values writing value with REGEX[value].
    # Change : Effective for new updates only
    # Example: "127.0.0.1 REGEX[^192\.168\.] REGEX[^10\.]"
    # Example: "localhost REGEX[^.*\.localdomain$]"
    # Default: ""
    #
    SkipHosts=""
    

    例如,我想过滤掉X.Y.Z.[97-110]

    我尝试了这种格式(注意:不是这些IP值,使用私有范围作为示例):

    REGEX[^192\.168\.1\.[97-110]]
    

    CGI误差
    指定的CGI 应用程序因未执行而行为不当 返回一组完整的HTTP

    我讨厌所有东西都使用不同的正则表达式语法。有人知道这一个是如何工作的吗?我如何在这里指定一个范围?

    3 回复  |  直到 17 年前
        1
  •  2
  •   Markus Jarderot    17 年前

    假设正则表达式[]中支持字符类:

    SkipHosts = "REGEX[^192\.168\.1\.(9[7-9]|10[0-9]|110)$]"
    
        2
  •  2
  •   Peter Turner    17 年前

    您使用的正则表达式指定9或7到1或1或0,这会造成混乱。

    你可以用

    SkipHosts="REGEX[^192\.168\.1\.(97|98|99|100|101|102|103|104|105|106|107|108|109|110)]"
    

        3
  •  0
  •   Casper    17 年前

    如果将SkipHosts留空,AWStats会运行吗?否则,请尝试使用命令行实用程序检查错误。例如,使用Windows:

    c:\perlpath\perl.exe awstats.pl config=yourconfigfile -update -logfile=yourlogfile
    

    这应该提供更多细节。

    推荐文章