CentOS 6:不允许连接到端口 5432



我在Windows盒子上有一个CentOS 6作为VM。我可以使用 Putty 连接到机器(在端口 22 上),但无法通过客户端应用程序 (pgAdmin) 或通过 telnet mytargetvmip 5432 连接到 postgresql(我确实修改了 pg_hba.conf 文件)。

这是我所做的:我更改了 ip 表文件,然后执行了service iptables restart命令,但没有好处。

请注意,在给定的iptables文件中,我也在提交之前尝试过iptables -I INPUT 1 -m tcp -p tcp --dport 5432 -j ACCEPT但没有运气。我希望能够通过任何远程 IP 进行连接。

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT
 COMMIT

谢谢。

关系,除了 pg_hba.conf 文件外,我还必须修改 postgresql.conf 文件以取消注释并使listen_address "*"。之后,我从iptables文件中删除了端口5432的条目,然后删除了以下命令:

iptables -I INPUT 1 -m tcp -p tcp --dport 5432 -j ACCEPT 
service iptables save 
service iptables restart 

一切正常。呵呵

相关内容

最新更新