Skip to content

Trying to figure out why <HOST> doesn't match any host. #3137

Answered by sebres
chrisinametalcan asked this question in Q&A
Discussion options

You must be logged in to vote

I've cut down the log to just the time and host to remove any complications
[25/Oct/2021:20:10:57 +0800] 1.2.3.4

You don't... Your log contains a timestamp enclosed in square brackets followed by space and IP address.
But your regex is searching for exact match of IP address only (anchored from both sides due to ^ and $).
Fail2ban would cut out the part with datetime matched the datepattern before it'd apply failregex, so it's attempting to match [] 1.2.3.4 with ^<HOST>$ what would not find anything.
For this "cutted down" log format the anchored RE would be something like ^\[\]\s+<HOST>$.
One could use ^(?:\[\])?\s*<HOST>$ to be compatible to jornals with different timestamp formats (w…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@chrisinametalcan
Comment options

Answer selected by sebres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants