Postfix два домена?
Добрый день, есть Postfix, на нем один домен example.ru , все работает отлично, проблем нету, потребовалось прикрутить второй домен третьего уровня gr.example.ru, для создания одного ящика.
Пробовал вот по этой инструкции
Не помогло, выдает вот такую ошибку при отправке сообщения:
This is the mail system at host mx1.example.ru. I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below. For further assistance, please send mail to postmaster. If you do so, please include this problem report. You can delete your own text from the attached returned message. The mail system <piter@gr.example.ru>: user unknown |
This is the mail system at host mx1.example.ru. I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below. For further assistance, please send mail to postmaster. If you do so, please include this problem report. You can delete your own text from the attached returned message. The mail system <piter@gr.example.ru>: user unknown
Вычитал, что требуется дописать:
mydestination = example.ru, gr.example.ru
Письма стали падать на piter@gr.example.ru, но перестали ходить письма на домен example.ru с отбивкой:
moscow@example.ru SMTP error from remote mail server after RCPT TO:<moscow@example.ru>: host mail.example.ru [Ip address]: 550 5.1.1 <moscow@example.ru>: Recipient address rejected: User unknown in local recipient table |
moscow@example.ru SMTP error from remote mail server after RCPT TO:<moscow@example.ru>: host mail.example.ru [Ip address]: 550 5.1.1 <moscow@example.ru>: Recipient address rejected: User unknown in local recipient table
Как правильно настроить, что бы postfix переваривал два домена на одном IP ?
Прикладываю конфиг main.cf
queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix mail_owner = postfix myhostname = mx1.example.ru mydomain = example.ru myorigin = example.ru #mydestination = example.ru, gr.example.ru #relay_domains = $mydestination, gr.example.ru inet_interfaces = all inet_protocols = ipv4 unknown_local_recipient_reject_code = 550 mynetworks = 127.0.0.0/8, 111.0.0.0/8, Ip address/32 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mail_spool_directory = /var/spool/mail debug_peer_level = 5 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /usr/share/doc/postfix32u-3.2.5/samples readme_directory = /usr/share/doc/postfix32u-3.2.5/README_FILES #mailbox_delivery_lock = fcntl, dotlock mailbox_delivery_lock = dotlock mailbox_size_limit = 1073741824 message_size_limit = 62914560 virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 virtual_mailbox_base = /var/spool/mail virtual_transport = dovecot-spamassassin dovecot-spamassassin_destination_recipient_limit = 1 virtual_mailbox_maps = ldap:/etc/postfix/ldap_virt_mailbox.cf, hash:/etc/postfix/virtualmaps virtual_alias_maps = ldap:/etc/postfix/ldap_aliases.cf, ldap:/etc/postfix/ldap_multicast_aliases.cf, regexp:/etc/postfix/aliases.filter virtual_mailbox_domains = example.ru, gr.example.ru #Encryption section smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes smtp_tls_security_level = may #smtp_sasl_auth_enable=yes smtpd_tls_cert_file = /etc/postfix/ssl/wildcard.example.ru.pem smtpd_tls_key_file = /etc/postfix/ssl/wildcard.example.ru.pem smtpd_sasl_auth_enable=yes smtpd_sasl_type=dovecot smtpd_sasl_path=private/auth smtpd_sasl_security_options=noanonymous smtpd_sasl_local_domain=$myhostname broken_sasl_auth_clients = yes smtpd_tls_auth_only = no #Enable ClamAV content_filter = scan:[127.0.0.1]:10025 receive_override_options = no_address_mappings #Antispam restrictions light version smtpd_delay_reject = yes smtpd_helo_required = yes smtpd_client_restrictions = permit_mynetworks, check_client_access hash:/etc/postfix/sender_access2, permit_sasl_authenticated, reject_unauth_pipelining, reject_unknown_client_hostname, reject_rbl_client bl.spamcop.net # for access need add permit smtpd_helo_restrictions = permit_sasl_authenticated, permit_mynetworks, check_helo_access hash:/etc/postfix/sender_access2, reject_non_fqdn_hostname, reject_invalid_helo_hostname, reject_unknown_helo_hostname # hard sender smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_rhsbl_sender bl.spamcop.net, regexp:/etc/postfix/access, check_sender_access hash:/etc/postfix/sender_access2 smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_pipelining, reject_unauth_destination, check_policy_service unix:private/policyd-spf, check_policy_service unix:postgrey/socket, reject_non_fqdn_recipient, reject_unknown_hostname, reject_unknown_recipient_domain, reject_unlisted_recipient, regexp:/etc/postfix/access smtpd_data_restrictions = reject_multi_recipient_bounce, reject_unauth_pipelining smtpd_relay_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination #Antispam restrictions hard version. In case of an emergency delete # and reload postfix. #smtpd_client_restrictions = permit_mynetworks, reject_rhsbl_client sbl-xbl.spamhaus.org, reject_rhsbl_client bl.spamcop.net #smtpd_helo_restrictions = permit_mynetworks, reject_invalid_hostname, reject_non_fqdn_hostname, reject_unknown_recipient_domain #smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unverified_sender,reject_rhsbl_sender bl.spamcop.ne #smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_pipelining,reject_unauth_destination,check_policy_service unix:postgrey/socket #smtpd_relay_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unverified_sender,reject_non_fqdn_hostname,reject_invalid_hostname #mime_header_checks = regexp:/etc/postfix/header_checks header_checks = regexp:/etc/postfix/header_checks #header_checks = pcre:/etc/postfix/header_checks body_checks = regexp:/etc/postfix/body_checks # Если отправитель сделал больше 2-х ошибок (обычно это попытка отправки письма на несуществующий ящик) # после каждой команды делаем задержку 5 секунд. # это частично помогает от перебора (bruteforce) названий ящиков спамерами smtpd_soft_error_limit = 2 smtpd_error_sleep_time = ${stress?0}${stress:10s} smtpd_hard_error_limit = ${stress?3}${stress:20} # Copy mails recipient_bcc_maps = hash:/etc/postfix/recipient_bcc address_verify_sender = <> smtp_connect_timeout = 20s # 30.11.2022 disabled for Levon resolve_numeric_domain = yes # 30.11.2022 disabled for Levon strict_rfc821_envelopes = yes # dns and lookup smtp_host_lookup = native, dns queue_run_delay = 15m maximal_queue_lifetime = 300m minimal_backoff_time = 20m maximal_backoff_time = 40m smtpd_recipient_limit = 60 # Количество одновременных доставок возможно первоначально. (по умолчанию 5 ) initial_destination_concurrency = 3000 # The default maximal number of parallel deliveries to the same destination (default: 20) #default_destination_concurrency_limit = 10000 # Сколько одновременных доставок. (по умолчанию: 100) smtp_destination_concurrency_limit = 10000 # Период времени, в течение которого рассчитываются показатели. (default: 60s) #anvil_rate_time_unit = 60s # Cколько клиенту можно отправлять сообщений за anvil_rate_time_unit. По умолчанию 0, то есть, ограничений нет. #smtpd_client_message_rate_limit = 10000 # Параметр указывает количество получателей для одного авторизованного пользователя postfix. т.е. сколько адресов будет написано в поле «Кому». #smtpd_client_recipient_rate_limit = 10000 # Колическо одновременных соединений (default: 50) smtpd_client_connection_count_limit = 1000 # for opendkim milter_default_action = accept #milter_protocol = 2 smtpd_milters = inet:127.0.0.1:10024 non_smtpd_milters = inet:127.0.0.1:10024 default_process_limit = 200 disable_vrfy_command = yes |
queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix mail_owner = postfix myhostname = mx1.example.ru mydomain = example.ru myorigin = example.ru #mydestination = example.ru, gr.example.ru #relay_domains = $mydestination, gr.example.ru inet_interfaces = all inet_protocols = ipv4 unknown_local_recipient_reject_code = 550 mynetworks = 127.0.0.0/8, 111.0.0.0/8, Ip address/32 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mail_spool_directory = /var/spool/mail debug_peer_level = 5 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /usr/share/doc/postfix32u-3.2.5/samples readme_directory = /usr/share/doc/postfix32u-3.2.5/README_FILES #mailbox_delivery_lock = fcntl, dotlock mailbox_delivery_lock = dotlock mailbox_size_limit = 1073741824 message_size_limit = 62914560 virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 virtual_mailbox_base = /var/spool/mail virtual_transport = dovecot-spamassassin dovecot-spamassassin_destination_recipient_limit = 1 virtual_mailbox_maps = ldap:/etc/postfix/ldap_virt_mailbox.cf, hash:/etc/postfix/virtualmaps virtual_alias_maps = ldap:/etc/postfix/ldap_aliases.cf, ldap:/etc/postfix/ldap_multicast_aliases.cf, regexp:/etc/postfix/aliases.filter virtual_mailbox_domains = example.ru, gr.example.ru #Encryption section smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes smtp_tls_security_level = may #smtp_sasl_auth_enable=yes smtpd_tls_cert_file = /etc/postfix/ssl/wildcard.example.ru.pem smtpd_tls_key_file = /etc/postfix/ssl/wildcard.example.ru.pem smtpd_sasl_auth_enable=yes smtpd_sasl_type=dovecot smtpd_sasl_path=private/auth smtpd_sasl_security_options=noanonymous smtpd_sasl_local_domain=$myhostname broken_sasl_auth_clients = yes smtpd_tls_auth_only = no #Enable ClamAV content_filter = scan:[127.0.0.1]:10025 receive_override_options = no_address_mappings #Antispam restrictions light version smtpd_delay_reject = yes smtpd_helo_required = yes smtpd_client_restrictions = permit_mynetworks, check_client_access hash:/etc/postfix/sender_access2, permit_sasl_authenticated, reject_unauth_pipelining, reject_unknown_client_hostname, reject_rbl_client bl.spamcop.net # for access need add permit smtpd_helo_restrictions = permit_sasl_authenticated, permit_mynetworks, check_helo_access hash:/etc/postfix/sender_access2, reject_non_fqdn_hostname, reject_invalid_helo_hostname, reject_unknown_helo_hostname # hard sender smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_rhsbl_sender bl.spamcop.net, regexp:/etc/postfix/access, check_sender_access hash:/etc/postfix/sender_access2 smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_pipelining, reject_unauth_destination, check_policy_service unix:private/policyd-spf, check_policy_service unix:postgrey/socket, reject_non_fqdn_recipient, reject_unknown_hostname, reject_unknown_recipient_domain, reject_unlisted_recipient, regexp:/etc/postfix/access smtpd_data_restrictions = reject_multi_recipient_bounce, reject_unauth_pipelining smtpd_relay_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination #Antispam restrictions hard version. In case of an emergency delete # and reload postfix. #smtpd_client_restrictions = permit_mynetworks, reject_rhsbl_client sbl-xbl.spamhaus.org, reject_rhsbl_client bl.spamcop.net #smtpd_helo_restrictions = permit_mynetworks, reject_invalid_hostname, reject_non_fqdn_hostname, reject_unknown_recipient_domain #smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unverified_sender,reject_rhsbl_sender bl.spamcop.ne #smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_pipelining,reject_unauth_destination,check_policy_service unix:postgrey/socket #smtpd_relay_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unverified_sender,reject_non_fqdn_hostname,reject_invalid_hostname #mime_header_checks = regexp:/etc/postfix/header_checks header_checks = regexp:/etc/postfix/header_checks #header_checks = pcre:/etc/postfix/header_checks body_checks = regexp:/etc/postfix/body_checks # Если отправитель сделал больше 2-х ошибок (обычно это попытка отправки письма на несуществующий ящик) # после каждой команды делаем задержку 5 секунд. # это частично помогает от перебора (bruteforce) названий ящиков спамерами smtpd_soft_error_limit = 2 smtpd_error_sleep_time = ${stress?0}${stress:10s} smtpd_hard_error_limit = ${stress?3}${stress:20} # Copy mails recipient_bcc_maps = hash:/etc/postfix/recipient_bcc address_verify_sender = <> smtp_connect_timeout = 20s # 30.11.2022 disabled for Levon resolve_numeric_domain = yes # 30.11.2022 disabled for Levon strict_rfc821_envelopes = yes # dns and lookup smtp_host_lookup = native, dns queue_run_delay = 15m maximal_queue_lifetime = 300m minimal_backoff_time = 20m maximal_backoff_time = 40m smtpd_recipient_limit = 60 # Количество одновременных доставок возможно первоначально. (по умолчанию 5 ) initial_destination_concurrency = 3000 # The default maximal number of parallel deliveries to the same destination (default: 20) #default_destination_concurrency_limit = 10000 # Сколько одновременных доставок. (по умолчанию: 100) smtp_destination_concurrency_limit = 10000 # Период времени, в течение которого рассчитываются показатели. (default: 60s) #anvil_rate_time_unit = 60s # Cколько клиенту можно отправлять сообщений за anvil_rate_time_unit. По умолчанию 0, то есть, ограничений нет. #smtpd_client_message_rate_limit = 10000 # Параметр указывает количество получателей для одного авторизованного пользователя postfix. т.е. сколько адресов будет написано в поле «Кому». #smtpd_client_recipient_rate_limit = 10000 # Колическо одновременных соединений (default: 50) smtpd_client_connection_count_limit = 1000 # for opendkim milter_default_action = accept #milter_protocol = 2 smtpd_milters = inet:127.0.0.1:10024 non_smtpd_milters = inet:127.0.0.1:10024 default_process_limit = 200 disable_vrfy_command = yes
Дополнительно:
mydestination верните как было, ибо:
Do not specify the names of virtual domains - those domains are specified elsewhere. See VIRTUAL_README for more information.
Ошибка «user unknown» вполне красноречива, так что смотрите на эти строки, а конкретнее на содержимое перечисленных там файлов:
virtual_mailbox_maps = ldap:/etc/postfix/ldap_virt_mailbox.cf hash:/etc/postfix/virtualmaps virtual_alias_maps = ldap:/etc/postfix/ldap_aliases.cf ldap:/etc/postfix/ldap_multicast_aliases.cf regexp:/etc/postfix/aliases.filter |
virtual_mailbox_maps = ldap:/etc/postfix/ldap_virt_mailbox.cf hash:/etc/postfix/virtualmaps virtual_alias_maps = ldap:/etc/postfix/ldap_aliases.cf ldap:/etc/postfix/ldap_multicast_aliases.cf regexp:/etc/postfix/aliases.filter
#mydestination = example.ru, gr.example.ru
Если вернуть как указано выше, то письма приходят на gr.example.ru, а вот на example.ru перестают, сопровождая это ошибкой:
moscow@example.ru SMTP error from remote mail server after RCPT TO:<moscow@example.ru>: host mail.example.ru [Ip address]: 550 5.1.1 <moscow@example.ru>: Recipient address rejected: User unknown in local recipient table |
moscow@example.ru SMTP error from remote mail server after RCPT TO:<moscow@example.ru>: host mail.example.ru [Ip address]: 550 5.1.1 <moscow@example.ru>: Recipient address rejected: User unknown in local recipient table
Аааа вот я олух ))))
hash:/etc/postfix/virtualmaps
Неправильно указал имя файла, но проверить могу только в конце рабочего дня
По умолчанию, у нас отсутствовала строка mydestination ранее и все работало хорошо с одним доменом example.ru, но теперь потребовалось добавить второй домен gr.example.ru.
virtual_mailbox_maps = ldap:/etc/postfix/ldap_virt_mailbox.cf, hash:/etc/postfix/virtemail |
virtual_mailbox_maps = ldap:/etc/postfix/ldap_virt_mailbox.cf, hash:/etc/postfix/virtemail
virtemail это правильное имя файла
с содержимым:
piter@gr.example.ru gr.example.ru/piter/
virtual_mailbox_domains = example.ru, gr.example.ru |
virtual_mailbox_domains = example.ru, gr.example.ru
То реакция будет:
Сообщение не было получено одним или несколькими получателями. Тема: 123 Отправлено: 19.03.2024 17:17 Невозможно достичь следующих получателей: 'piter@gr.example.ru' 19.03.2024 17:17 Ошибка сервера: '550 5.1.1 <piter@gr.example.ru>: Recipient address rejected: User unknown in virtual mailbox table' |
Сообщение не было получено одним или несколькими получателями. Тема: 123 Отправлено: 19.03.2024 17:17 Невозможно достичь следующих получателей: 'piter@gr.example.ru' 19.03.2024 17:17 Ошибка сервера: '550 5.1.1 <piter@gr.example.ru>: Recipient address rejected: User unknown in virtual mailbox table'
Проверил вот такой конфиг:
virtual_mailbox_maps = ldap:/etc/postfix/ldap_virt_mailbox.cf, hash:/etc/postfix/virtemail virtual_alias_maps = ldap:/etc/postfix/ldap_aliases.cf, ldap:/etc/postfix/ldap_multicast_aliases.cf, regexp:/etc/postfix/aliases.filter virtual_mailbox_domains = example.ru, gr.example.ru |
virtual_mailbox_maps = ldap:/etc/postfix/ldap_virt_mailbox.cf, hash:/etc/postfix/virtemail virtual_alias_maps = ldap:/etc/postfix/ldap_aliases.cf, ldap:/etc/postfix/ldap_multicast_aliases.cf, regexp:/etc/postfix/aliases.filter virtual_mailbox_domains = example.ru, gr.example.ru
virtemail:
piter@gr.example.ru gr.example.ru/piter
Пришла отбивка
Reporting-MTA: dns; mx1.example.ru X-Postfix-Queue-ID: 89AB820199BD X-Postfix-Sender: rfc822; moscow@example.ru Arrival-Date: Wed, 20 Mar 2024 17:08:11 +0300 (MSK) Final-Recipient: rfc822; piter@gr.example.ru Original-Recipient: rfc822;piter@gr.example.ru Action: failed Status: 5.1.1 Diagnostic-Code: x-unix; user unknown |
Reporting-MTA: dns; mx1.example.ru X-Postfix-Queue-ID: 89AB820199BD X-Postfix-Sender: rfc822; moscow@example.ru Arrival-Date: Wed, 20 Mar 2024 17:08:11 +0300 (MSK) Final-Recipient: rfc822; piter@gr.example.ru Original-Recipient: rfc822;piter@gr.example.ru Action: failed Status: 5.1.1 Diagnostic-Code: x-unix; user unknown
#mydestination = example.ru, gr.example.ru
Куда дальше копать?
postmap -q "piter@gr.example.ru" /etc/postfix/virtemail |
postmap -q "piter@gr.example.ru" /etc/postfix/virtemail
Опишите проблему, и специалист поможет с настройкой, исправлением ошибки или доработкой сайта. Подберём понятный план работ без лишней переписки.
Пока нет других ответов. Будьте первым, кто поможет автору.
Ответить на вопрос
Для настройки почтового сервера с postfix для работы с двумя доменами, необходимо внести некоторые изменения в конфигурационные файлы postfix.
1. Откройте файл конфигурации postfix (/etc/postfix/main.cf) и добавьте следующие строки:
mydestination = example.com, example2.com virtual_alias_domains = example2.com virtual_alias_maps = hash:/etc/postfix/virtual
2. Создайте файл /etc/postfix/virtual и добавьте в него следующие записи:
@example2.com user1@example.com @example2.com user2@example.com
3. После внесения изменений перезапустите почтовый сервер postfix:
sudo systemctl restart postfix
Теперь postfix настроен для работы с двумя доменами example.com и example2.com. Все письма, отправленные на домен example2.com, будут перенаправлены на соответствующие адреса на домене example.com, указанные в файле /etc/postfix/virtual.
Убедитесь, что вы правильно настроили DNS-записи для обоих доменов, чтобы письма могли корректно доставляться.