为什么openssl只能使用内部IP?

我想debugging一个SSL连接,所以我跟着这个问题的答案,并想运行第一个testing:

# openssl s_client -connect SERVER_IP:PORT -state -debug 

并得到以下输出:

 socket: Connection refused connect:errno=111 

我查了一下,发现它与SSL无关,这意味着服务器没有运行,或者端口被防火墙阻塞。 我login到服务器,并检查,实际上它正在运行,并且端口是开放的监听所有的IP地址:

 # netstat -plan | grep PORT tcp 0 0 0.0.0.0:PORT 0.0.0.0:* LISTEN PID/java 

下面是有趣的部分:当我使用我的服务器的内部IP来运行上面的openssl命令时,我得到了预期的输出。

无论我尝试从客户端还是从服务器本身连接到服务器,行为都是相同的。

我添加了端口到iptables。 以下是他们现在的样子:

 # iptables -L -v | grep PORT 40 4252 ACCEPT tcp -- any any anywhere anywhere tcp dpt:PORT 0 0 ACCEPT tcp -- any any anywhere anywhere state NEW tcp dpt:PORT 

为什么我无法使用外部IP连接服务器,但是它与内部IP协同工作?

编辑:我所有的iptables规则都有ACCEPT关键字 – 命令iptables -L -v | grep REJECT iptables -L -v | grep REJECT没有输出。