尝试使用 Postfix 作为 Nagios 邮件客户端时出错

尝试使用 Postfix 作为 Nagios 邮件客户端时出错

我有一个在 Debian10 上运行的 Nagios-Core 服务器,我希望当某些参数达到临界水平时能够收到电子邮件通知。因此我安装了 Postfix,并配置了我的 Nagios-core/etc/postfix/main.cfg(为了使用我的电子邮件服务器)为:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = debian-server.acopio.minag.cu
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, localhost.$your_domain, $your_domain
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = ipv4

smtpd_client_restrictions = permit_mynetworks,permit_sasl_authenticated
relay_domains = acopio.minag.cu
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/password
smtp_sasl_security_options=noanonymous
smtp_tls_security_level = encrypt
relayhost = 192.168.50.233

虽然我的电子邮件主配置文件看起来像(这个电子邮件服务器也是一个依赖):

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
compatibility_level = 2

############################################################################################################################################################

# require helo
smtpd_delay_reject  = yes
smtpd_helo_required = yes

strict_rfc821_envelopes = yes
disable_vrfy_command = yes

smtpd_helo_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, reject_invalid_hostname, reject_unknown_helo_hostname
smtpd_reject_unlisted_sender = yes

smtpd_banner = ldap.server.com ESMTP $mail_name (server)
biff = no

##############################################################################################################################################################

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

myorigin = /etc/mailname
myhostname = smtp.server.com
mydestination = $myorigin,$myhostname,localhost,localhost.$mydomain
smtp_helo_name = ldap.server.com
alias_maps = hash:/etc/aliases

alias_database = hash:/etc/aliases
local_recipient_maps = proxy:unix:passwd.byname $alias_maps

local_recipient_maps = proxy:unix:passwd.byname $alias_maps

relayhost = relay2.com:26

smtp_tls_security_level = may
smtp_tls_key_file  = /etc/postfix/sasl/postfix.pem
smtp_tls_cert_file = /etc/postfix/sasl/postfix.pem



################################################################################################
#mynetworks_style = subnet
#mynetworks = 127.0.0.0/8

mynetworks = 127.0.0.0/8 192.168.253.0/24 

###############################################################################################

message_size_limit = 4278190
mailbox_size_limit = 0
virtual_mailbox_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4

# Aliases
virtual_alias_domains = $virtual_alias_maps
virtual_alias_maps = ldap:/etc/postfix/valiases.cf,ldap:/etc/postfix/useraliases.cf,ldap:/etc/postfix/groupaliases.cf

# Virtual Domains
dovecot_destination_recipient_limit = 1
virtual_transport = dovecot
virtual_mailbox_base = /var/vmail/
virtual_mailbox_maps= ldap:/etc/postfix/mailbox.cf

virtual_mailbox_domains = ldap:/etc/postfix/vdomains.cf

virtual_minimum_uid = 100
virtual_uid_maps = static:110
virtual_gid_maps = static:116

# TLS/SSL
smtpd_use_tls = yes
smtpd_tls_key_file  = /etc/postfix/sasl/postfix.pem
smtpd_tls_cert_file = /etc/postfix/sasl/postfix.pem
#smtpd_tls_loglevel = 0

##################################################################################################################################################################################
# recipient restrictions
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/access-in.cf, permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_inv$
submission_recipient_restrictions = reject_non_fqdn_sender, reject_non_fqdn_recipient, permit_sasl_authenticated, permit_mynetworks, reject
smtpd_restriction_classes = submission_recipient_restrictions, cu-in, cu-out, int-in, int-out

cu-in = check_sender_access regexp:/etc/postfix/cu, reject
cu-out = check_recipient_access regexp:/etc/postfix/cu, reject
int-in = check_sender_access regexp:/etc/postfix/int, reject
int-out = check_recipient_access regexp:/etc/postfix/int, reject

#################################################################################################################################################################################

# SASL authentication
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
#smtpd_tls_auth_only = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain =  $myorigin
broken_sasl_auth_clients = yes

###################################################################################################################################################################################

###################################################################################################################################################################################

smtpd_sender_restrictions= reject_authenticated_sender_login_mismatch, check_sender_access hash:/etc/postfix/access-out.cf
smtpd_sender_login_maps = ldap:/etc/postfix/login.cf
smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject

####################################################################################################################################


sender_bcc_maps = hash:/etc/postfix/alwaysbcc
recipient_bcc_maps = hash:/etc/postfix/alwaysbcc

bounce_template_file = /etc/postfix/bounce.cf

但是当我在 Nagios-Core 中尝试时: 邮件-s“Nagios”[电子邮件保护]<<<“这是信息”

在我的电子邮件服务器中,我查看/var/log/mail.log | grep 删除,但我得到:

manzana postfix/smtpd[26172]: NOQUEUE: reject: RCPT from unknown[192.168.50.220]: 554 5.7.1 <unknown[192.168.50.220]>: Client host rejected: Access denied; from=<root@debian-server> to=<[email protected]> proto=ESMTP helo=<debian-server.com>

我想我应该在 Nagios-Core 服务器中进行一些配置,就像在 Outlook 客户端中进行配置一样,以检查我的发件服务器(SMTP)需要身份验证。 但我找不到路

编辑:我已关注一些类似这样的链接但我还是得到了同样的答案

答案1

回答我自己的问题:

在我的电子邮件服务器中/etc/posftix/main.cf我需要添加发送电子邮件的网络,因此我需要添加:

我的网络 = 127.0.0.0/8, 192.168.50.0/24

作为 192.168.50.0/24 网络上的 Nagios-Core 网络

这真是奇迹!!!

相关内容