![无法让 Postfix 使用不同的公共 IP 进行 SMTP](https://linux22.com/image/743712/%E6%97%A0%E6%B3%95%E8%AE%A9%20Postfix%20%E4%BD%BF%E7%94%A8%E4%B8%8D%E5%90%8C%E7%9A%84%E5%85%AC%E5%85%B1%20IP%20%E8%BF%9B%E8%A1%8C%20SMTP.png)
DigitalOcean 上的 Ubuntu 18.04,Postfix 3.3.0
postconf-n:
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
content_filter = smtp-amavis:[127.0.0.1]:10024
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
mydestination = $myhostname
myhostname = mail.tohuw.net
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_bind_address = 174.138.126.177
smtp_tls_CAfile = /etc/postfix/fullchain.pem
smtp_tls_cert_file = /etc/postfix/fullchain.pem
smtp_tls_key_file = /etc/postfix/privkey.pem
smtp_tls_loglevel = 1
smtp_tls_mandatory_protocols = !SSLv2,!SSLv3
smtp_tls_note_starttls_offer = yes
smtp_tls_protocols = !SSLv2,!SSLv3
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_CAfile = /etc/postfix/fullchain.pem
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/postfix/fullchain.pem
smtpd_tls_key_file = /etc/postfix/privkey.pem
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3
smtpd_tls_protocols = !SSLv2,!SSLv3
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_tls_session_cache
tls_random_source = dev:/dev/urandom
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_mailbox_base = /var/mail/vhosts
virtual_mailbox_domains = tohuw.net
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
我已经设置smtp_bind_address = 174.138.126.177
并nslookup mail.tohuw.net
返回了预期的 IP。但在 mail.log 中我看到:
postfix/smtp[21941]: warning: smtp_connect_addr: bind 174.138.126.177: Cannot assign requested address
我猜我需要在网络层面配置一些东西,但是做什么呢?/etc/network/interfaces
只是:
auto lo
iface lo inet loopback
source /etc/network/interfaces.d/*
请注意,没有interfaces.d
目录。
答案1
默认情况下,您应该已经为服务器设置了 127.0.0.1,不要绑定它。将 main.cf 中的 mydestination 设置为:
myhostname = mail.tohuw.net
mydomain = tohuw.net
mydestination = $myhostname, localhost.$mydomain, localhost
将 myhostname 保留在 mydestination 之上
并在 /etc/hosts 中插入:
127.0.0.1 mail.tohuw.net,mail