我已经设置了一个 postfix 服务器,当作为 localhost 访问时,它可以正常工作。但是我无法从外部访问它。
相关配置如下:
/etc/postfix/main.cf 包含(并且 postfix 已重新加载):
myhostname = <myserver.with.fully.qualified.domain.name> # not localhost
inet_interfaces = all
inet_protocols = ipv4
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
alias_maps = hash:/etc/aliases
virtual_alias_maps = hash:/etc/postfix/virtual
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = <myserver.with.fully.qualified.domain.name> localhost.localdomain localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
inet_interfaces = all
inet_protocols = ipv4
~$ sudo iptables -L --行号
Chain INPUT (policy DROP)
num target prot opt source destination
1 ACCEPT all -- anywhere anywhere
2 ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
3 ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
4 ACCEPT tcp -- anywhere anywhere tcp dpt:http
5 ACCEPT tcp -- anywhere anywhere tcp dpt:https
6 ACCEPT icmp -- anywhere anywhere icmp echo-request
7 ACCEPT udp -- anywhere anywhere udp spt:ntp state ESTABLISHED
8 ACCEPT tcp -- anywhere anywhere tcp dpt:imap2 state NEW,ESTABLISHED
9 ACCEPT tcp -- anywhere anywhere tcp dpt:imaps state NEW,ESTABLISHED
10 ACCEPT tcp -- anywhere anywhere tcp dpt:smtp ctstate NEW,ESTABLISHED
~$ sudo netstat -tap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 *:http *:* LISTEN 8067/nginx
tcp 0 0 *:ssh *:* LISTEN 18536/sshd
tcp 0 0 *:smtp *:* LISTEN 5913/master
tcp 0 0 *:https *:* LISTEN 8067/nginx
tcp 0 0 localhost.localdo:mysql *:* LISTEN 29579/mysqld
tcp6 0 0 [::]:imap2 [::]:* LISTEN 4752/couriertcpd
tcp6 0 0 [::]:ssh [::]:* LISTEN 18536/sshd
tcp6 0 0 [::]:imaps [::]:* LISTEN 4803/couriertcpd
同时——来自不同的服务器:
$ nmap <myIP>
Starting Nmap 6.40 ( http://nmap.org ) at 2016-04-28 19:44 CEST
Nmap scan report for myServer (<myIP>)
Host is up (0.018s latency).
Not shown: 995 filtered ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
143/tcp open imap
443/tcp open https
993/tcp open imaps
Nmap done: 1 IP address (1 host up) scanned in 11.70 seconds
因此 SMTP 显然没有打开
我错过了什么?
谢谢!
答案1
请确保您的托管服务提供商或您运行远程检查的 ISP/网络运营商没有阻止 SMTP 端口 (TCP 25) nmap
。