centos8 Fail2ban이 작동하지 않습니다

centos8 Fail2ban이 작동하지 않습니다

SSH 및 Nginx가 구성된 CentOS 8에서 fall2ban을 실행하고 있습니다. Fail2ban-client status를 수행하면 둘 다 IP가 차단되고 있는 것으로 표시되지만 실제로는 방화벽에 의해 차단되지는 않습니다. SSH 공격을 받고 있는데 방화벽 측에서는 아무 일도 일어나지 않습니다. "tcpdump - i any port 80, port 443 또는 port 22"를 실행 중인데 여러 번 실패한 시도가 표시됩니다. 다시 Fail2ban은 이를 보고 금지되었다고 말하지만 실제로는 금지되지 않습니다. 어떤 제안??

[DEFAULT] 
ignoreip = 127.0.0.1 192.168.1.0/24
bantime  = 21600
findtime  = 300
maxretry = 3
banaction = iptables-multiport
backend = systemd

[sshd] 
enabled = true

[nginx-http-auth]
enabled  = true
filter   = nginx-http-auth
port     = http,https
logpath  = /var/log/gitlab/nginx/error.log

[nginx-noscript]
enabled  = true
port     = http,https
filter   = nginx-noscript
logpath  = /var/log/gitlab/nginx/access.log
maxretry = 6

[nginx-badbots]
enabled  = true
port     = http,https
filter   = nginx-badbots
logpath  = /var/log/gitlab/nginx/access.log
maxretry = 2

[nginx-nohome]
enabled  = true
port     = http,https
filter   = nginx-nohome
logpath  = /var/log/gitlab/nginx/access.log
maxretry = 2

[nginx-noproxy]
enabled  = true
port     = http,https
filter   = nginx-noproxy
logpath  = /var/log/gitlab/nginx/access.log
maxretry = 2

[gitlab]
enabled = true
port = http,https
filter = gitlab
logpath = /var/log/gitlab/gitlab_error.log

답변1

실제로 방화벽을 사용 하고 있다면 banaction.firewallcmd-ipset

답변2

구성이 양호해 보입니다. 특히 failure2ban-client status sshd의 출력에 IP가 나열되어 있는 경우 더욱 그렇습니다.

차단된 IP인지 어떻게 확인하시나요? 금지된 IP로 내가 담당하고 있는 시스템에서 확인하는 방법입니다.

            iptables -L f2b-sshd
Chain f2b-sshd (1 references)
target     prot opt source               destination         
REJECT     all  --  120.29.125.240       anywhere             reject-with icmp-port-unreachable
RETURN     all  --  anywhere             anywhere

거기에 나열되어 있지 않다면 너무 빨리 금지되거나 금지 해제되는 것일까요? 구성이 6시간으로 설정되어 있으면 충분히 긴 것으로 알고 있습니다.

실패하면 관련 활동이 있는지 /var/log/fail2ban.log를 확인할 수도 있습니다. 예를 들어:

2020-12-04 09:17:07,590 fail2ban.filter         [9089]: INFO    [sshd] Found 120.29.125.240
2020-12-04 09:17:09,883 fail2ban.filter         [9089]: INFO    [sshd] Found 120.29.125.240
2020-12-04 09:17:12,163 fail2ban.filter         [9089]: INFO    [sshd] Found 120.29.125.240
2020-12-04 09:17:14,381 fail2ban.filter         [9089]: INFO    [sshd] Found 120.29.125.240
2020-12-04 09:17:16,874 fail2ban.filter         [9089]: INFO    [sshd] Found 120.29.125.240
2020-12-04 09:17:17,805 fail2ban.actions        [9089]: NOTICE  [sshd] Ban 120.29.125.240

관련 정보