デフォルトの設定から変えるのは
- inet_interfaces で外部からの接続を許可して
- mynetworks で内部のIPアドレス設定して
- relayhost Relay元サーバは relayhost でRelay先指定して
- smtpd_relay_restrictions = permit_mynetworks, で mynetworksを許可する。
グローバルIPアドレスを持っているサーバがひとつしかない時とか
たまに使うのでメモ。
main.cf
--- a/main.cf
+++ b/main.cf
@@ -113,10 +113,12 @@ mail_owner = postfix
#inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
-inet_interfaces = localhost
+#inet_interfaces = localhost
+inet_interfaces = all
# Enable IPv4, and IPv6 if supported
-inet_protocols = all
+# inet_protocols = all
+inet_protocols = ipv4
# The proxy_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on by way of a
@@ -264,6 +266,7 @@ unknown_local_recipient_reject_code = 550
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
+mynetworks = 192.168.0.0/24, 127.0.0.0/8
# The relay_domains parameter restricts what destinations this system will
# relay mail to. See the smtpd_recipient_restrictions description in
@@ -315,6 +318,7 @@ unknown_local_recipient_reject_code = 550
#relayhost = [mailserver.isp.tld]
#relayhost = uucphost
#relayhost = [an.ip.add.ress]
+#relayhost = [192.168.0.100]
# REJECTING UNKNOWN RELAY USERS
#
@@ -674,3 +678,10 @@ sample_directory = /usr/share/doc/postfix-2.6.6/samples
# readme_directory: The location of the Postfix README files.
#
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
+
+smtpd_relay_restrictions = permit_mynetworks,
+ permit_sasl_authenticated,
+ reject_unauth_destination,
+ reject_unknown_hostname,
+ reject_unauth_destination