stop2ban 중지 / 시작 알림 중지 보냅니다. [asterisk-iptables] enabled = true filter =

서버가 다시 시작되거나 fail2ban이 중지 / 시작된 경우에도 알림을 보냅니다.

[asterisk-iptables]
enabled  = true
filter   = asterisk
action   = iptables-allports[name=ASTERISK, protocol=all]
           sendmail-whois[name=ASTERISK, dest=blah@foo.com, sender=blah@foo.com]
logpath  = /var/log/asterisk/messages
maxretry = 5
bantime = 259200

sendmail-whois를 제거하면 중지되지만 금지 알림도 중지됩니다. 프로세스가 시작 / 중지 될 때 알림을 중지하려면 어떻게해야합니까?

감사



답변

에 모습을 가지고있는 action.d/mail.confaction.d/sendmail.conf있는 시작 / 정지 / 금지에 대한 메일을 제어 할 수 있습니다.


답변

모든 파일에서이 문제를 해결할 필요는 없습니다. 의 구성에 따라 다릅니다 jail.conf.

구성한 경우 mta = sendmail파일 범위를 좁힐 수 있습니다 action.d/sendmail-*.

그럼 당신은을 봐야합니다 action = %(action_*)s. 구성한 경우

“action_”: action.d / sendmail .conf 에서 “actionstart”및 “actionstop”주석

“action_mw”: action.d / sendmail -whois.conf의 주석 …

“action_mwl”: action.d / sendmail -whois-lines.conf의 주석 …

mta를 “mail”로 구성한 경우 sendmailmail로 변경 하고 특정 파일을 구성하십시오.

파일을 주석 처리 한 후 다시 시작하는 것을 잊지 마십시오!


답변

CentOS 7 (RHEL 7)의 Fail2Ban v0.9.1 (epel 저장소의)에서이 문제를 해결하기 위해 /etc/fail2ban/action.d/sendmail-common에서 sendmail 시작 및 중지 조치를 무시 (아무 것으로 설정) 할 수 있습니다. 현지. 다음 명령을 루트로 실행하여이 파일을 만듭니다.

cat << EOF >> /etc/fail2ban/action.d/sendmail-common.local
# Override the Fail2Ban defaults in sendmail-common.conf with these entries

[Definition]
# Disable email notifications of jails stopping or starting
actionstart =
actionstop =
EOF
cat /etc/fail2ban/action.d/sendmail-common.local

답변

시작 / 중지 알림을 비활성화하는 유일한 방법 은 다음의 모든 파일에서 actionstartactionstop섹션 을 주석 처리하는 것 입니다 .action.d/

mail-buffered.conf
mail.conf
mail-whois.conf
mail-whois-lines.conf
sendmail-buffered.conf
sendmail.conf
sendmail-whois.conf
sendmail-whois-lines.conf

답변

게으른에 대한 자세한 내용과 긴 명령으로 이전 답변의 비트와 조각을 모 으려고합니다.

귀하의 jail.{conf,local}메일을 보내는 방법을 정의합니다. 기본적으로입니다 sendmail. 확인 :

grep 'mta *=' jail.{conf,local}

감옥에 어떤 시작 / 중지 조치가 구성되어 있는지 보려면을 사용하십시오 fail2ban-client -d.

둘 다 합치기 :

mta=$(grep 'mta *=' /etc/fail2ban/jail.{conf,local} | awk '{print $NF}')
fail2ban-client -d | awk "/action(start|stop).*$mta/ {print \$4}" | sort -u

내 구성에서 출력은 'sendmail-whois-lines',편집 할 파일입니다. 설정이 / etc / fail2ban 아래에 있다고 가정하면 전체 파일 이름은 /etc/fail2ban/action.d/sendmail-whois-lines.conf입니다.

그러나 Rabin이 언급했듯이 해당 파일은 업데이트 중에 덮어 쓰기 때문에 직접 편집하지 마십시오. 대신, /etc/fail2ban/action.d/sendmail-whois-lines.local(또는 action.d/file-name.local구성에 올바른 것을 작성 하고) 다음 행을 추가하십시오.

[Definition]
actionstart =
actionstop  =

또는 정말 게으른 사람이 올바른 파일을 찾고 생성하는 데 방해가되지 않는 경우 :

mta=$(grep 'mta *=' /etc/fail2ban/jail.{conf,local} | awk '{print $NF}')
fail2ban-client -d \
| awk "/action(start|stop).*$mta/ {print \$4}" \
| sort -u \
| while read f; do \
    f=${f//\'/}
    f="/etc/fail2ban/action.d/${f/%,/}.local"
    cat <<EOF >>"$f"
[Definition]
actionstart =
actionstop  =
EOF
done

답변

/etc/fail2ban/action.d/sendmail-common.conf파일을 작성하여 actionstart 및 actionstop 정의를 대체 하십시오 /etc/fail2ban/action.d/sendmail-common.local.

이 파일에 아래 텍스트를 추가하십시오

[Definition]
actionstart =
actionstop =

이제 fail2ban 서비스를 시작 / 중지 할 때 메일을받지 않습니다.


답변

나는 이것을하는 빠르고 쉬운 방법을 찾았습니다.

cd당신의 /etc/fail2ban/action.d디렉토리에.

그런 다음 각 actionstart 문을 자신의 것으로 대체하십시오.

for FILE in *mail* ; do echo -e "actionstart =\nactionstop =\n" >> $FILE ; done

메일을 보내는 각 파일에 새로운 actionstart 및 actionstop 섹션이 추가됩니다.

1 줄, 작업 완료