Postfix + reject_unverified_sender + relay smtp.yandex.ru

Обсуждение настройки и работы сервисов, резервирования, сетевых настроек и вопросов безопасности ОС.

Модератор: SLEDopit

Ответить
Аватара пользователя
denel
Сообщения: 497
ОС: Gentoo Linux
Контактная информация:

Postfix + reject_unverified_sender + relay smtp.yandex.ru

Сообщение denel »

Хочу в защите от спама попробовать функцию reject_unverified_sender, но как только я её включаю - я перестаю получать письма, а в логе появляются строки:

Код: Выделить всё

Sender address rejected: unverified address: host smtp.yandex.ru[87.250.250.38] said: 553 5.7.1 Sender address rejected: not owned by auth user.
Предполагаю, что дело в том, что postfix при попытке отправки тестового письма пробует отправлять от адреса, который есть на моём сервере, но разумеется его нет на сервере yandex.ru. Чтобы было возможно использовать релей в обычном режиме постфикс у меня подставляет в адрес отправителя единственный существующуй на яндексе адрес, на который у постфикса имеются и регистрационные данные. Как сделать чтобы он и при отправке тестового письма делал так же? Конфиг конечно сумбурный:

Код: Выделить всё

soft_bounce = no
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
default_privs = nobody
myhostname = mail.denel85.dynalias.org
mydomain = denel85.dynalias.org
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$myhostname, localhost
local_recipient_maps = $virtual_mailbox_maps, $virtual_alias_maps, $transport_maps
unknown_local_recipient_reject_code = 550
mynetworks_style = host
mynetworks = 127.0.0.0/8
relay_domains =
relayhost = [smtp.yandex.ru]
alias_maps = hash:/etc/mail/aliases
alias_database = hash:/etc/mail/aliases.db
mail_spool_directory = /var/spool/mail
header_checks = regexp:/etc/postfix/header_checks
smtpd_banner = $myhostname ESMTP
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         xxgdb $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
message_size_limit = 100000000
mailbox_size_limit = 200000000
virtual_mailbox_limit = 200000000
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /etc/postfix
readme_directory = no
inet_protocols = ipv4
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/ssl/postfix/server.key
smtpd_tls_cert_file = /etc/ssl/postfix/server.crt
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
config_directory=/etc/postfix
virtual_mailbox_domains = mysql:$config_directory/sql/vdomains.cf
virtual_mailbox_base = /home/vmail
virtual_mailbox_maps = mysql:$config_directory/sql/vmailbox.cf
virtual_alias_maps = mysql:$config_directory/sql/valias.cf
virtual_minimum_uid = 1150
virtual_uid_maps = static:1150
virtual_gid_maps = static:12
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
smtpd_sasl_auth_enable = yes
smtpd_sasl_exceptions_networks = $mynetworks
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = /var/spool/postfix/private/auth
disable_vrfy_command = yes
smtpd_delay_reject = yes
smtpd_helo_required = yes
mime_header_checks = $header_checks
nested_header_checks = $header_checks
smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unknown_client,
    reject_invalid_hostname,
    reject_non_fqdn_hostname,
    reject_unknown_hostname,
    reject_non_fqdn_recipient,
    reject_unauth_pipelining,
    reject_unauth_destination,
    reject_unlisted_recipient,
    reject_non_fqdn_sender,
    reject_unknown_sender_domain,
reject_unverified_sender,
    reject_invalid_helo_hostname,
    reject_non_fqdn_helo_hostname,
    reject_unknown_helo_hostname,
    check_helo_access regexp:/etc/postfix/helo_regexp,
        check_policy_service unix:/var/spool/postfix/private/postgrey
    permit
body_checks = regexp:/etc/postfix/body_checks
address_verify_sender = <>
content_filter = scan:127.0.0.1:10025
receive_override_options = no_address_mappings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/private/auth/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_type = cyrus
smtp_sasl_mechanism_filter = login
sender_canonical_maps = hash:/etc/postfix/private/auth/canonical
local_header_rewrite_clients =
config_directory = /etc/postfix
Где засада?
Спасибо сказали:
Аватара пользователя
denel
Сообщения: 497
ОС: Gentoo Linux
Контактная информация:

Re: Postfix + reject_unverified_sender + relay smtp.yandex.ru

Сообщение denel »

Ну или сделать так, чтобы при отправке такого сообщения он не пытался использовать релей яндекса
Спасибо сказали:
Аватара пользователя
stannum
Сообщения: 322
Статус: Свободолюбитель
ОС: Debian GNU/Linux unstable
Контактная информация:

Re: Postfix + reject_unverified_sender + relay smtp.yandex.ru

Сообщение stannum »

Sender address rejected - говорит о том что письмо не поступило в очередь и было отклонено в ответ на MAIL FROM.
В документации написано: http://www.postfix.org/postconf.5.html#rej...verified_sender
Reject the request when mail to the MAIL FROM address is known to bounce, or when the sender address destination is not reachable. Address verification information is managed by the verify(8) server; see the ADDRESS_VERIFICATION_README file for details.

Что значит, что адрес отправителя должен быть в базе процесса verify, и поэтому verify делает запрос на сервера яндекса, чтобы проверить существование ящика отправителя. Там же написано, что нельзя просто так включать эту проверку и это правильно. Поэтому уберите эту проверку совсем. То же касается проверки reject_unverified_recipient - тот же принцип работы, только касательно получателя, но вы не сможете нормально отправлять письма пока не попадёте из грейлиста принимающей стороны.

Вот пример, настроенного MX-сервера, крупного предприятия, отсекается примерно 90% всякого спама:
smtpd_helo_required = yes
smtpd_client_restrictions = permit_mynetworks, reject_unknown_reverse_client_hostname, check_client_access hash:/etc/postfix/rbl_override, reject_rbl_client xbl.spamhaus.org, permit
smtpd_helo_restrictions = permit_mynetworks, reject_non_fqdn_helo_hostname, reject_unknown_helo_hostname, reject_invalid_helo_hostname, permit
smtpd_sender_restrictions = permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, permit

Далее, если письмо попало в очередь оно проверяется Касперским.
Можно еще сделать проверки спам асассином перед Касперским, но у нас и без него нормально.
Главное при борьбе со спамом не переусредствовать и, как говорится, "не выплеснуть дитя вместе с водой".
Спасибо сказали:
Аватара пользователя
denel
Сообщения: 497
ОС: Gentoo Linux
Контактная информация:

Re: Postfix + reject_unverified_sender + relay smtp.yandex.ru

Сообщение denel »

Немного отредактировал конфиг, привёл к такому виду:

Код: Выделить всё

compatibility_level = 2
soft_bounce = no
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
default_privs = nobody
myhostname = denel85.dynalias.org
mydomain = $myhostname
myorigin = $mydomain
inet_interfaces = all
mydestination = localhost
local_recipient_maps = $virtual_mailbox_maps, $virtual_alias_maps, $transport_maps
unknown_local_recipient_reject_code = 550
mynetworks_style = host
mynetworks = 127.0.0.0/8
relay_domains =
relayhost =
alias_maps = hash:/etc/mail/aliases
alias_database = hash:/etc/mail/aliases.db

mail_spool_directory = /var/spool/mail

header_checks = regexp:/etc/postfix/header_checks
smtpd_banner = $myhostname ESMTP
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         xxgdb $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
message_size_limit = 100000000
mailbox_size_limit = 200000000
virtual_mailbox_limit = 200000000
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /etc/postfix
readme_directory = no
inet_protocols = ipv4
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/ssl/postfix/server.key
smtpd_tls_cert_file = /etc/ssl/postfix/server.crt
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
config_directory=/etc/postfix
virtual_mailbox_domains = mysql:$config_directory/sql/vdomains.cf
virtual_mailbox_base = /home/vmail
virtual_mailbox_maps = mysql:$config_directory/sql/vmailbox.cf
virtual_alias_maps = mysql:$config_directory/sql/valias.cf
virtual_minimum_uid = 1150
virtual_uid_maps = static:1150
virtual_gid_maps = static:12
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
smtpd_sasl_auth_enable = yes
smtpd_sasl_exceptions_networks = $mynetworks
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = /var/spool/postfix/private/auth
disable_vrfy_command = yes
smtpd_delay_reject = yes
mime_header_checks = $header_checks
nested_header_checks = $header_checks
smtpd_client_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
        reject_unknown_client,
        ## проверяет есть ли PTR запись у того что шлет письмо
        reject_unknown_reverse_client_hostname,
        reject_rbl_client xbl.spamhaus.org,
        permit
smtpd_helo_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
        check_helo_access regexp:/etc/postfix/helo_regexp,
        reject_invalid_helo_hostname,
        reject_non_fqdn_helo_hostname,
        reject_unknown_helo_hostname,
        permit
smtpd_sender_restrictions =
        reject_non_fqdn_sender,
        reject_unknown_sender_domain,
        check_helo_access regexp:/etc/postfix/helo_regexp_red,
        reject_unverified_sender,
        permit
smtpd_recipient_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
        reject_non_fqdn_recipient,
        reject_unauth_destination,
        reject_unlisted_recipient,
        check_policy_service unix:/var/spool/postfix/private/postgrey,
        permit
smtpd_data_restrictions =
        reject_unauth_pipelining,
        permit
body_checks = regexp:/etc/postfix/body_checks
address_verify_sender = <>
smtpd_helo_required = yes
content_filter = scan:127.0.0.1:10025
receive_override_options = no_address_mappings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/private/auth/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_type = cyrus
smtp_sasl_mechanism_filter = login
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/private/auth/sender_relay
sender_canonical_maps = hash:/etc/postfix/private/auth/canonical
local_header_rewrite_clients =
config_directory = /etc/postfix
Но от спама избавиться не удалось, проходит все проверки:

Код: Выделить всё

Jan  6 15:49:06 denel85 postfix/smtpd[2598]: connect from 1792.ru[92.63.107.40]
Jan  6 15:49:06 denel85 postfix/smtpd[2598]: Anonymous TLS connection established from 1792.ru[92.63.107.40]: TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)
Jan  6 15:49:07 denel85 postfix/cleanup[2734]: 54B1912012F: message-id=<20160106104907.54B1912012F@denel85.dynalias.org>
Jan  6 15:49:07 denel85 postfix/qmgr[1195]: 54B1912012F: from=<>, size=232, nrcpt=1 (queue active)
Jan  6 15:49:07 denel85 postfix/smtp[2735]: 54B1912012F: to=<info@1792.ru>, relay=mail.1792.ru[92.63.107.40]:25, delay=0.54, delays=0.04/0.03/0.43/0.04, dsn=2.0.0, status=deliverable (250 Accepted)
Jan  6 15:49:07 denel85 postfix/qmgr[1195]: 54B1912012F: removed
Jan  6 15:49:10 denel85 postfix/smtpd[2598]: NOQUEUE: reject: RCPT from 1792.ru[92.63.107.40]: 450 4.2.0 <mymail@denel85.dynalias.org>: Recipient address rejected: Greylisted for 60 seconds; from=<info@1792.ru> to=<mymail@denel85.dynalias.org> proto=ESMTP helo=<1792.ru>
Jan  6 15:49:10 denel85 postfix/smtpd[2598]: disconnect from 1792.ru[92.63.107.40] ehlo=2 starttls=1 mail=1 rcpt=0/1 data=0/1 quit=1 commands=5/7
Грейлист, вродебы хорошо, но от этих спамеров не спасает:

Код: Выделить всё

Jan  6 16:27:54 denel85 postfix/smtpd[7283]: connect from 1792.ru[92.63.107.40]
Jan  6 16:27:54 denel85 postfix/smtpd[7283]: Anonymous TLS connection established from 1792.ru[92.63.107.40]: TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)
Jan  6 16:27:54 denel85 postfix/smtpd[7283]: AFAC512027D: client=1792.ru[92.63.107.40]
Jan  6 16:27:54 denel85 postfix/cleanup[7294]: AFAC512027D: message-id=<08d7e6fcbc7512c495abf8cf99ac5c3c@info.emailconfig.ru>
Jan  6 16:27:54 denel85 postfix/qmgr[1195]: AFAC512027D: from=<info@1792.ru>, size=9361, nrcpt=1 (queue active)
Jan  6 16:27:54 denel85 postfix/smtpd[7283]: disconnect from 1792.ru[92.63.107.40] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7
Jan  6 16:27:54 denel85 postfix/smtpd[7297]: connect from denel85.dynalias.org[127.0.0.1]
Jan  6 16:27:54 denel85 postfix/smtpd[7297]: DC753120542: client=denel85.dynalias.org[127.0.0.1], orig_queue_id=AFAC512027D, orig_client=1792.ru[92.63.107.40]
Jan  6 16:27:58 denel85 postfix/cleanup[7294]: DC753120542: message-id=<08d7e6fcbc7512c495abf8cf99ac5c3c@info.emailconfig.ru>
Jan  6 16:27:58 denel85 postfix/qmgr[1195]: DC753120542: from=<info@1792.ru>, size=9610, nrcpt=1 (queue active)
Jan  6 16:27:58 denel85 postfix/smtp[7295]: AFAC512027D: to=<mymail@denel85.dynalias.org>, relay=127.0.0.1[127.0.0.1]:10025, delay=4.3, delays=0.46/0.03/0.07/3.8, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as DC753120542)
Jan  6 16:27:58 denel85 postfix/smtpd[7297]: disconnect from denel85.dynalias.org[127.0.0.1] ehlo=1 xforward=2 mail=1 rcpt=1 data=1 quit=1 commands=7
Jan  6 16:27:58 denel85 postfix/qmgr[1195]: AFAC512027D: removed
Jan  6 16:27:58 denel85 postfix/pipe[7320]: DC753120542: to=<mymail@denel85.dynalias.org>, relay=dovecot, delay=4, delays=3.8/0.02/0/0.23, dsn=2.0.0, status=sent (delivered via dovecot service)
Jan  6 16:27:58 denel85 postfix/qmgr[1195]: DC753120542: removed

Может есть какие блок листы, в которые эти спамеры входят? Этих отправителей и почтовых серверов, учавствующих в этой рассылке, так много... Каждый раз используют новые. Я конечно добавляю эти серверы в свой лист, но от этого спам пока не убавляется
Спасибо сказали:
Ответить