Fail2ban 작업 ipset 재시도 또는 시간 초과

Fail2ban 작업 ipset 재시도 또는 시간 초과

최근 Ubuntu 20.04 상자에서 fail2ban다음 오류가 발생했습니다.

2023-07-13 06:57:05,129 fail2ban.actions        [3063]: NOTICE  [nginx-http-auth] Ban 2600:1005:b02d:3b6a:c1e:4a7e:6a9f:ccc4
2023-07-13 06:57:05,151 fail2ban.utils          [3063]: ERROR   7f106882c6c0 -- exec: ipset create f2b-nginx-http-auth-v6 hash:ip timeout 600 family inet6
ip6tables -w -I ban -m set --match-set f2b-nginx-http-auth-v6 src -j REJECT --reject-with icmp6-port-unreachable
2023-07-13 06:57:05,152 fail2ban.utils          [3063]: ERROR   7f106882c6c0 -- timed out after 0 seconds.
2023-07-13 06:57:05,353 fail2ban.utils          [3063]: ERROR   ipset create f2b-nginx-http-auth-v6 hash:ip timeout 600 family inet6
ip6tables -w -I ban -m set --match-set f2b-nginx-http-auth-v6 src -j REJECT --reject-with icmp6-port-unreachable -- failed with [Errno 3] No such process
2023-07-13 06:57:05,353 fail2ban.utils          [3063]: ERROR   7f106882c6c0 -- killed with SIGTERM (return code: -15)
2023-07-13 06:57:05,354 fail2ban.actions        [3063]: ERROR   Failed to execute ban jail 'nginx-http-auth' action 'iptables-ipset-proto6-allports' info 'ActionInfo({'ip': '2600:1005:b02d:3b6a:c1e:4a7e:6a9f:ccc4', 'family': 'inet6', 'fid': <function Actions.ActionInfo.<lambda> at 0x7f1068839750>, 'raw-ticket': <function Actions.ActionInfo.<lambda> at 0x7f1068839e10>})': Error starting action Jail('nginx-http-auth')/iptables-ipset-proto6-allports: 'Script error'

작업은 다음으로 시작됩니다./etc/fail2ban/action.d/iptables-ipset-proto6-allports.local

actionstart = ipset create <ipmset> hash:ip timeout <default-timeout> <familyopt>
              <iptables> -I <chain> -m set --match-set <ipmset> src -j <blocktype>

문제에 대한 나의 이해는 / fail2ban실행될 수 없다는 것입니다 (교착 상태?)ipsetip6tables

fail2ban여러 번 재시도하거나 종료하기 전에 더 긴 시간 초과를 허용하도록 설정을 완화하는 방법이 있습니까?

답변1

fail2ban공유해 주신 오류 로그를 보면 ip6tablesipset create 및 명령을 실행하는 데 문제가 있는 것 같습니다.

이 문제를 해결하려면 더 긴 재시도 및 시간 초과를 허용하도록 Fail2ban 설정을 조정해 보세요. 가능한 해결책은 다음과 같습니다.

fail2ban편집할 구성 파일을 엽니다 .

Ubuntu 20.04에서 이 파일은 일반적으로 /etc/fail2ban/fail2ban.conf.

nginx-http-auth 감옥과 관련된 actionban 줄을 찾으세요. 다음과 같이 보일 수 있습니다:

actionban = ipset create <ipmset> hash:ip timeout <default-timeout> <familyopt>
iptables -I <chain> -m set --match-set <ipmset> src -j <blocktype>

더 긴 시간 초과 또는 재시도 간격을 포함하도록 작업 금지 줄을 수정합니다.

--retry <num>재시도 횟수를 지정하는 옵션과 --timeout <secs>더 긴 시간 초과를 설정하는 옵션을 추가할 수 있습니다 .

예를 들어:

actionban = ipset create <ipmset> hash:ip --timeout 1200 <familyopt>
iptables -I <chain> -m set --match-set <ipmset> src -j <blocktype> --retry 3

위의 예에서 제한 시간은 1200초(20분)로 설정되고 재시도 횟수는 3으로 설정됩니다.

구성 파일에 대한 변경 사항을 저장하고 수정 사항을 적용하려면 Fail2ban 서비스를 다시 시작하십시오. 다음 명령을 사용할 수 있습니다.

sudo service fail2ban restart

Fail2ban 구성에서 시간 초과 및 재시도 값을 조정하면 필요한 명령을 실행하는 데 더 많은 시간을 제공하고 교착 상태 발생 시 추가 재시도를 허용할 수 있습니다. 이렇게 하면 직면한 문제가 해결될 수 있습니다.

fail2ban문제가 해결되고 fail2ban예상대로 실행되도록 변경한 후에는 로그를 모니터링하는 것을 잊지 마세요.

답변2

timed out after 0 seconds.

하나 있다문제 #2790ipset 작업의 경우 이는 timeout작업 매개변수와의 이름 혼동으로 인해 발생합니다. Ubuntu 20.04에는 오래된 버전의 fall2ban이 있는 것 같습니다. 업데이트를 시도하다0.11부터 action.d 구성 시작포크 이상 업그레이드 실패2반https://github.com/fail2ban/fail2ban/releases(최소 버전 0.11.2의 Ubuntu에서 작동하는 Debian 기반 패키지가 있습니다.) 또한 참고하시기 바랍니다실패2반 :: wiki :: 실패2반을 수동으로 설치하거나 업그레이드하는 방법.

관련 정보