我有一个运行在kimsufi VPS上的postfix服务器,我在上面安装了roundcube,并且一切正常。 问题是,当我尝试从另一台服务器连接,我有一个超时:
telnet whys.fr 25 Trying 5.196.66.189... telnet: Unable to connect to remote host: Connection timed out
这里是我的netstat输出:
netstat -ntpul | grep 25 tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 17643/master tcp6 0 0 :::25 :::* LISTEN 17643/master
而目前的iptables规则是:
Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:smtp ACCEPT tcp -- anywhere anywhere tcp dpt:smtp fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain fail2ban-ssh (1 references) target prot opt source destination RETURN all -- anywhere anywhere
从本地telnet工作得很好:
telnet localhost 25 Trying 127.0.0.1... Connected to localhost.localdomain. Escape character is '^]'. 220 whys.fr ESMTP Postfix (Debian/GNU) ehlo whys.fr 250-whys.fr 250-PIPELINING 250-SIZE 10240000 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN quit 221 2.0.0 Bye Connection closed by foreign host.
服务器托pipe在OVH的数据中心,并且端口25未被阻止:
nmap -p 25 whys.fr Starting Nmap 6.47 ( http://nmap.org ) at 2015-02-20 15:16 CET Nmap scan report for whys.fr (5.196.66.189) Host is up (0.019s latency). rDNS record for 5.196.66.189: ns330237.ip-5-196-66.eu PORT STATE SERVICE 25/tcp filtered smtp Nmap done: 1 IP address (1 host up) scanned in 0.72 seconds
我也检查邮件垃圾邮件清单,看看我的IP是否在其中之一,而事实并非如此。
我怎样才能接受外部的telnet 25? 我现在不知道,在SF上已经看到了它的所有问题,并且在互联网的其他部分也看到了很多问题。
根据nmap文档:
filtered Nmap cannot determine whether the port is open because packet filtering prevents its probes from reaching the port. The filtering could be from a dedicated firewall device, router rules, or host-based firewall software. These ports frustrate attackers because they provide so little information. Sometimes they respond with ICMP error messages such as type 3 code 13 (destination unreachable: communication administratively prohibited), but filters that simply drop probes without responding are far more common. This forces Nmap to retry several times just in case the probe was dropped due to network congestion rather than filtering. This slows down the scan dramatically.
所以看起来你的端口只是被某个防火墙封锁。 也许你的本地ISP? 因为当我尝试连接到它,我得到一个连接:
$ telnet whys.fr 25 Trying 5.196.66.189... Connected to whys.fr. Escape character is '^]'. 220 whys.fr ESMTP Postfix (Debian/GNU)
可悲的是,ISP阻止直接连接到自己networking外部的端口25并不罕见,以防止客户端机器上的僵尸程序直接发送垃圾邮件。
在继续进行之前,我要做的第一件事就是使用netcat这样的工具来端口25的端口。
该工具是大多数Linux发行版的标准。 例如在CentOS上,我会停止postfix来释放端口25.然后,我会像这样启动netcat:
# nc -l 25
然后在远程客户端上,我会像这样启动它:
# nc {ip of remote server} 25
然后任何你input的任何一端应该反映/屏幕上可见。 如果没有,那么你的港口正在被阻塞。