從 2.11 升級到 3.4 後 Postfix Relay 存取被拒絕

從 2.11 升級到 3.4 後 Postfix Relay 存取被拒絕

Postfix 2.11.3 版本在過去幾年中運作完美。我升級到3.4.14版本後,伺服器無法再向外部發送電子郵件。

在該mail.err文件中,我找到了以下行:

postfix/smtpd[1043]: fatal: in parameter smtpd_relay_restrictions or smtpd_recipient_restrictions, specify at least one working instance of: reject_unauth_destination, defer_unauth_destination, reject, defer, defer_if_permit or check_relay_domains

之後我將其中的兩個參數配置master.cf

  -o smtpd_recipient_restrictions=reject_unauth_destination
  -o smtpd_relay_restrictions=reject_unauth_destination

在 Postfix 2.11 版本中,這兩個參數都被註解掉了。

配置完成後,訊息mail.err消失了,但我在mail.log文件中發現了另一個錯誤

Jun  3 08:01:22 smtp-out postfix/smtpd[19915]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 554 5.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<[127.0.0.1]>

由於我正在使用sender_dependent_relayhost_maps = hash:/etc/postfix/transport_sender這兩個參數的正確配置是什麼(如果這是問題的話)?

這是我的main.cf文件:

inet_protocols = ipv4
smtpd_banner = Company ESMTP NO UCE/UBE
biff = no
append_dot_mydomain = no
myhostname = smtp-out.company.com
mydomain = company.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = smtp-out.local, localhost.dmz.local.dmz.local, localhost, $mydomain, localhost.$mydomain

relayhost = [mail.external-relayserver.com]

relay_domains =
mynetworks = 192.168.10.0/24, 192.168.15.0/24, 127.0.0.0/8, [::1]/128
header_checks = regexp:/etc/postfix/regexp/header_checks
message_size_limit = 47185920
recipient_delimiter = +

transport_maps = hash:/etc/postfix/transport

undisclosed_recipients_header=
local_recipient_maps =
smtp_tls_security_level=may
smtp_tls_loglevel=1

# relay transport
sender_dependent_relayhost_maps = hash:/etc/postfix/transport_sender
smtp_sender_dependent_authentication = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

default_destination_concurrency_limit = 2
default_destination_rate_delay = 1s

master.cf文件:

smtp      inet  n       -       -       -       -       smtpd
  -o smtpd_recipient_restrictions=reject_unauth_destination
  -o smtpd_relay_restrictions=reject_unauth_destination

pickup    unix  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
relay     unix  -       -       -       -       -       smtp
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache

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}

答案1

您需要指定誰可以透過您的 postfix 伺服器進行中繼reject_unauth_destination

例如,允許您自己的網路透過您的伺服器進行中繼:

smtpd_relay_restrictions = permit_mynetworks, reject_unauth_destination

或者如果您使用 sasl_authentication:

smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated,
                           reject_unauth_destination

請記住,這些規則是按列出的順序指定的...因此上述規則允許網路上的用戶端無需進行身份驗證即可中繼郵件。來自網路外部的用戶端必須驗證自己的身分。其他人的中繼嘗試都會被拒絕。


順便說一句,對於像您這樣的簡單後綴配置,最好將這些選項放在文件中main.cf,而不是master.cf.

相關內容