The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]



"Безусловная доставка для postmaster с любых почтовиков"
Вариант для распечатки  
Пред. тема | След. тема 
Форум Открытые системы на сервере (Почта / Linux)
Изначальное сообщение [ Отслеживать ]

"Безусловная доставка для postmaster с любых почтовиков"  +/
Сообщение от allexnew (ok), 14-Янв-25, 11:01 
Здравствуйте.
Есть задача безусловно принимать всю почту с любых, даже криво настроенных (в пределах разумного), серверов для ящика postmaster@mydomain.ru. Сервер под управлением postfix.
Понятно, что для пропуска проверки smtpd_recipient_restrictions используем maps check_recipient_access. Однако остаются еще milters, которые непонятно как обойти. В частности нужно пропустить проверку dkim и dmarc. В документации по milter есть smtpd_milter_map, но он предназначен только для IP, причем клиента. Игнорирования для получателя в opendkim и opendmarc не предусмотрено насколько я понял.
Т.е. postfix пропускает проверки smtpd_recipient_restrictions, но далее идут milters. Если что-то не так с dkim или sfp dmarc шлет получателя куда подальше в соответствии настройкам DNS записи сервера отправителя.
Ниже портянка master.cf, main.cf и логи приема письма с "нормального" сервера.

main.cf


compatibility_level = 2
debug_peer_level = 2
debugger_command =
     PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
     ddd $daemon_directory/$process_name $process_id & sleep 5

soft_bounce = no

smtputf8_enable = no

bounce_template_file = /etc/postfix/bounce.cf
delay_warning_time = 1h
maximal_queue_lifetime = 1d
bounce_queue_lifetime = 1d

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/lib/postfix/sbin
data_directory = /var/lib/postfix

mail_owner = postfix

myhostname = mx1.mydomain.ru
mydomain = mydomain.ru

myorigin = $mydomain

inet_interfaces = all
inet_protocols = ipv4

mydestination = localhost.$mydomain, localhost, $myhostname

unknown_local_recipient_reject_code = 550

mynetworks = 127.0.0.0/8,172.20.0.15,172.20.0.16,172.20.0.10,172.20.0.11
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

smtp_generic_maps = hash:/etc/postfix/maps/generic
smtpd_banner = Hi, the SMTP server $myhostname is ready.

sendmail_path = /usr/sbin/postfix
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq

setgid_group = postdrop

html_directory = no

relay_domains = mysql:/etc/postfix/mysql/relay_domains.cf
virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps.cf,
mysql:/etc/postfix/mysql/virtual_alias_domain_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_mailbox_domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf

smtpd_sender_login_maps = unionmap:{
mysql:/etc/postfix/mysql/sender_verify.cf,
pcre:/etc/postfix/maps/sender_verify.pcre}

smtpd_discard_ehlo_keywords = etrn, silent-discard
smtpd_forbidden_commands = CONNECT GET POST
broken_sasl_auth_clients = yes

smtpd_delay_reject = yes
smtpd_helo_required = yes
smtp_always_send_ehlo = yes
strict_rfc821_envelopes = yes
disable_vrfy_command = yes
policy-spf_time_limit = 3600s
reversehn_time_limit = 3600s

########### 1 START client_restrictions #############
smtpd_client_restrictions =
sleep 3,
reject_unauth_pipelining,
permit_sasl_authenticated,
check_client_access hash:/etc/postfix/maps/access_client,
check_client_access pcre:/etc/postfix/maps/access_client.pcre,
permit_mynetworks,
########### 1 END client_restrictions #############

########### 2 START helo_restrictions #############
smtpd_helo_restrictions =
permit_sasl_authenticated,
check_helo_access hash:/etc/postfix/maps/access_helo,
reject_non_fqdn_helo_hostname,
reject_invalid_helo_hostname,
reject_unknown_helo_hostname,
reject_unknown_hostname,
reject_invalid_hostname,
########### END helo_restrictions #############

########### 4 START sender_restrictions #############
smtpd_sender_restrictions =
check_sender_access hash:/etc/postfix/maps/access_sender,
reject_authenticated_sender_login_mismatch,
reject_non_fqdn_sender,
permit_sasl_authenticated,
reject_unknown_sender_domain,
########### END sender_restrictions #############

########### 5 START recipient_restrictions #############
smtpd_recipient_restrictions =
check_recipient_access hash:/etc/postfix/maps/access_recipients,
check_sender_access hash:/etc/postfix/maps/access_sender,
check_sender_access regexp:/etc/postfix/maps/reject_sender.regexp,
reject_non_fqdn_recipient,
reject_unlisted_recipient,
reject_unknown_recipient_domain,
permit_mynetworks,
reject_unauth_destination,
permit_sasl_authenticated,
check_policy_service unix:private/policy-spf,
warn_if_reject reject_unknown_reverse_client_hostname,
check_policy_service unix:private/reversehn,
check_policy_service inet:localhost:10023,
#### RBL списки
reject_rhsbl_client xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.dblack.mail.abusix.zone,
reject_rhsbl_helo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.dblack.mail.abusix.zone,
reject_rhsbl_sender xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.dblack.mail.abusix.zone,
Permit_dnswl_client xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.white.mail.abusix.zone
reject_rbl_client xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.combined.mail.abusix.zone,
permit
########### END recipient_restrictions #############

########### 6 START data_restrictions #############
smtpd_data_restrictions =
reject_unauth_pipelining,
reject_multi_recipient_bounce
########### END data_restrictions #############

# Настройка сертификатов, SSL
smtp_tls_security_level = may
smtp_tls_loglevel = 1
smtpd_tls_security_level = may
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtp_tls_session_cache_database = btree:$data_directory/smtp_tls_session_cache
smtpd_tls_key_file = /etc/postfix/certs/privkey.pem
smtpd_tls_cert_file = /etc/postfix/certs/fullchain.pem
tls_random_source = dev:/dev/urandom
smtpd_tls_mandatory_ciphers = low
smtpd_tls_ciphers = low
smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3
smtp_tls_mandatory_protocols  = !SSLv2,!SSLv3
smtp_tls_ciphers = low
smtp_tls_mandatory_ciphers = low
smtp_tls_protocols = !SSLv2,!SSLv3
smtp_tls_policy_maps = hash:/etc/postfix/maps/tls_policy_maps
smtp_tls_note_starttls_offer = yes

message_size_limit = 27000000
smtpd_soft_error_limit = 10
smtpd_hard_error_limit = 15
smtpd_error_sleep_time = 20
smtpd_client_event_limit_exceptions = 127.0.0.0/8
smtpd_client_connection_limit_exceptions = 127.0.0.0/8

bounce_queue_lifetime = 1d

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/dovecot-auth
smtpd_tls_auth_only = no

virtual_mailbox_base = /var/mail
virtual_minimum_uid = 2000
virtual_uid_maps = static:2000
virtual_gid_maps = static:2000
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1

# MILTERS
smtpd_milters = inet:127.0.0.1:8891, local:opendmarc/opendmarc.sock
non_smtpd_milters = $smtpd_milters
milter_default_action = accept
milter_protocol = 6

smtpd_sasl_authenticated_header = yes
queue_run_delay = 2m
minimal_backoff_time = 5m
maximal_backoff_time = 10m
maximal_queue_lifetime = 1d

anvil_rate_time_unit = 60s

spamassassin_destination_recipient_limit = 1
recipient_delimiter = +

master.cf

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================
smtp      inet  n       -       y       -       -       smtpd
-o content_filter=spamassassin

submission inet n       -       n       -       -       smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_tls_auth_only=yes
-o smtpd_reject_unlisted_recipient=no
-o smtpd_recipient_restrictions=
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING

smtps     inet  n       -       n       -       -       smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
-o smtpd_reject_unlisted_recipient=no
-o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject
-o smtpd_relay_restrictions=permit_mynetworks,permit_sasl_authenticated,defer_unauth_destination
-o milter_macro_daemon_name=ORIGINATING

#628       inet  n       -       y       -       -       qmqpd
pickup    unix  n       -       y       60      1       pickup
cleanup   unix  n       -       y       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
#qmgr     unix  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       y       1000?   1       tlsmgr
rewrite   unix  -       -       y       -       -       trivial-rewrite
bounce    unix  -       -       y       -       0       bounce
defer     unix  -       -       y       -       0       bounce
trace     unix  -       -       y       -       0       bounce
verify    unix  -       -       y       -       1       verify
flush     unix  n       -       y       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       y       -       -       smtp
relay     unix  -       -       y       -       -       smtp
-o syslog_name=postfix/$service_name

showq     unix  n       -       y       -       -       showq
error     unix  -       -       y       -       -       error
retry     unix  -       -       y       -       -       error
discard   unix  -       -       y       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       y       -       -       lmtp
anvil     unix  -       -       y       -       1       anvil
scache    unix  -       -       y       -       1       scache
postlog   unix-dgram n  -       n       -       1       postlogd

maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}

uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)

ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)

bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient

scalemail-backend unix    -    n    n    -    2    pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}

mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}

spamassassin unix -     n   n   -   -   pipe
flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -u ${recipient} -f -e
/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}

# Check SPF
policy-spf   unix    -    n    n    -    -    spawn
    user=vmail argv=/usr/sbin/postfix-policyd-spf-perl

# Check reverse hostname and PTR filter
reversehn     unix    -       n       n       -       0       spawn
    user=vmail argv=/etc/postfix/reversehn.pl

mail.log postmaster это alias на admin. Во второй половине идет еще пересылка с admin на другой внутренний ящик, не обращайте внимания. Это лог с нормального сервера, но тут видно, что проверки milters не пропускаются.


Jan 13 17:42:48 mail postfix/smtpd[2620907]: connect from mail.our-domain.ru[111.11.11.11]
Jan 13 17:42:48 mail postfix/smtpd[2620907]: Anonymous TLS connection established from mail.our-domain.ru[111.11.11.11]: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)
Jan 13 17:42:51 mail postfix/smtpd[2620907]: 6BD277FE7D7B: client=mail.our-domain.ru[111.11.11.11]
Jan 13 17:42:51 mail postfix/cleanup[2619329]: 6BD277FE7D7B: message-id=<224bbbbc7bfbf9eaf6fa374460158f52@our-domain.ru>
Jan 13 17:42:51 mail opendkim[786321]: 6BD277FE7D7B: mail.our-domain.ru [111.11.11.11] not internal
Jan 13 17:42:51 mail opendkim[786321]: 6BD277FE7D7B: not authenticated
Jan 13 17:42:51 mail opendkim[786321]: 6BD277FE7D7B: DKIM verification successful
Jan 13 17:42:51 mail opendkim[786321]: 6BD277FE7D7B: s=mail d=our-domain.ru a=rsa-sha256 SSL
Jan 13 17:42:51 mail opendmarc[909537]: 6BD277FE7D7B: our-domain.ru pass
Jan 13 17:42:51 mail postfix/qmgr[2530368]: 6BD277FE7D7B: from=<allex@our-domain.ru>, size=2313, nrcpt=1 (queue active)
Jan 13 17:42:51 mail postfix/smtpd[2620907]: disconnect from mail.our-domain.ru[111.11.11.11] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7
Jan 13 17:42:51 mail spamd[2419239]: spamd: connection from 127.0.0.1 [127.0.0.1]:39512 to port 783, fd 5
Jan 13 17:42:51 mail spamd[2419239]: spamd: handle_user (userdir) unable to find user: 'admin@mydomain.ru'
Jan 13 17:42:51 mail spamd[2419239]: spamd: processing message <224bbbbc7bfbf9eaf6fa374460158f52@our-domain.ru> for admin@mydomain.ru:123
Jan 13 17:42:51 mail spamd[2621969]: util: setuid: ruid=123 euid=123 rgid=128 128 128 egid=128 128 128
Jan 13 17:42:51 mail spamd[2621970]: util: setuid: ruid=123 euid=123 rgid=128 128 128 egid=128 128 128
Jan 13 17:42:52 mail spamd[2419239]: spamd: clean message (2.5/5.0) for admin@mydomain.ru:123 in 0.7 seconds, 2695 bytes.
Jan 13 17:42:52 mail spamd[2419239]: spamd: result: . 2 - PYZOR_CHECK scantime=0.7,size=2695,user=admin@mydomain.ru,uid=123,required_score=5.0,rhost=127.0.0.1,raddr=127.0.0.1,rport=39512,mid=<224bbbbc7bfbf9eaf6fa374460158f52@our-domain.ru>,autolearn=no autolearn_force=no
Jan 13 17:42:52 mail spamd[2257816]: prefork: child states: II
Jan 13 17:42:52 mail postfix/pickup[2595200]: 4D29C7FE8C33: uid=2000 from=<allex@our-domain.ru>
Jan 13 17:42:52 mail opendmarc[909537]: ignoring connection from localhost
Jan 13 17:42:52 mail postfix/cleanup[2619329]: 4D29C7FE8C33: message-id=<224bbbbc7bfbf9eaf6fa374460158f52@our-domain.ru>
Jan 13 17:42:52 mail opendkim[786321]: 4D29C7FE8C33: localhost [127.0.0.1] not internal
Jan 13 17:42:52 mail opendkim[786321]: 4D29C7FE8C33: not authenticated
Jan 13 17:42:52 mail opendkim[786321]: 4D29C7FE8C33: DKIM verification successful
Jan 13 17:42:52 mail opendkim[786321]: 4D29C7FE8C33: s=mail d=our-domain.ru a=rsa-sha256 SSL
Jan 13 17:42:52 mail postfix/pipe[2620613]: 6BD277FE7D7B: to=<admin@mydomain.ru>, orig_to=<postmaster@mydomain.ru>, relay=spamassassin, delay=3.9, delays=3.1/0/0/0.79, dsn=2.0.0, status=sent (delivered via spamassassin service)
Jan 13 17:42:52 mail postfix/qmgr[2530368]: 6BD277FE7D7B: removed
Jan 13 17:42:52 mail postfix/qmgr[2530368]: 4D29C7FE8C33: from=<allex@our-domain.ru>, size=3342, nrcpt=1 (queue active)
Jan 13 17:42:52 mail postfix/pipe[2620291]: 4D29C7FE8C33: to=<me@mydomain.ru>, relay=dovecot, delay=0.31, delays=0.09/0/0/0.22, dsn=2.0.0, status=sent (delivered via dovecot service)
Jan 13 17:42:52 mail postfix/qmgr[2530368]: 4D29C7FE8C33: removed

Ответить | Правка | Cообщить модератору


Архив | Удалить

Рекомендовать для помещения в FAQ | Индекс форумов | Темы | Пред. тема | След. тема



Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2025 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру