fail2ban failregex模式格式(添加teamspeak日志文件禁令)

fail2ban failregex模式格式(添加teamspeak日志文件禁令),regex,fail2ban,Regex,Fail2ban,也许有人能帮我用fail2ban的正则表达式 我需要创建一个failregex来过滤包含以下内容的行: 2020-09-11 18:44:05.122235|INFO |VirtualServer |1 |ban added reason='' ip='127.0.0.1' bantime=0 by client 'name'(id:1345) 我尝试了很多正则表达式,但我总是从fail2ban regex命令中得到这个错误: 错误:无法编译正则表达式“\etc\fail2ban\fi

也许有人能帮我用fail2ban的正则表达式

我需要创建一个failregex来过滤包含以下内容的行:

2020-09-11 18:44:05.122235|INFO    |VirtualServer |1  |ban added reason='' ip='127.0.0.1' bantime=0 by client 'name'(id:1345)
我尝试了很多正则表达式,但我总是从fail2ban regex命令中得到这个错误:

错误:无法编译正则表达式“\etc\fail2ban\filter.d\01teamspeak ban.conf”

我试过一些例子:

failregex = /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])) (?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d).*[|]INFO    [|]VirtualServer [|].*  [|]ban added reason='.*' ip='(<HOST>)' bantime=0 by client '.*[)]/g

failregex = ^([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])) (?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d).*[|]INFO    [|]VirtualServer [|].*  [|]ban added reason='.*' ip='(<HOST>)' bantime=0 by client '.*[)]$
 
failregex = /ban added reason='.*' ip='(<HOST>)' bantime=0 by client '.*'/g

failregex = ^ban added reason='.*' ip='(<HOST>)' bantime=0 by client '.*'$

我的案例中的工作模板:

/etc/fail2ban/filter.d/01teamspeak-permanentban.conf

[INCLUDES]
before = common.conf
[Definition]
failregex = ^.*ban.*ip='(<ADDR>)' bantime=0.*
ignoreregex = 
[包括]
before=common.conf
[定义]
failregex=^.*ban.*ip='()'bantime=0*
ignoreregex=

多亏了OneWO12

^\d+-\d+-\d+.*$
其他行是什么样子的?有什么区别?对于您想要捕获的行,是否有类似于
ban
的词?我添加了一个日志文件exsample-yes get line with=ban added。。。。。从日志文件中,您只需要捕获第12行和第13行?如果是这种情况,请编辑问题并使其更清楚。在这个较大日志文件的简短示例中,是的,只需第13行和ip地址。
^.*ban.*ip=.*$
这将只捕获第13行和类似的内容。
[INCLUDES]
before = common.conf
[Definition]
failregex = ^.*ban.*ip='(<ADDR>)' bantime=0.*
ignoreregex =