使用pgAdmin访问远程Postgres服务器

时间:2011-09-02 16:09:24

标签: postgresql pgadmin

我的XP机器上运行了pgAdmin。有一台Centos机器在网络上运行Postgres服务器。 Postgres服务器pg_hba.conf文件包含以下行

TYPE      DATABASE    USER      CIDR-ADDRESS       METHOD
host      all         all       10.0.0.68/32       trust
local     mydb        myuser                       password
local     all         postgres                     ident
host      mydb        myuser    10.0.0.68/32       password
host      all         postgres  10.0.0.68/32       trust

我的postgresql.conf文件包含以下行:

listen_address = 'localhost, 10.0.20.10'

nmap -sS 10.0.20.10显示:

PORT      STATE     SERVICE
5432/tcp  open      postgresql

我可以ssh到服务器上的bash shell,但我无法连接pgAdmin。我得到以下内容:

  

无法连接到服务器:没有到主机的路由(0x00002751 / 10065)是   服务器在主机“10.0.20.10”上运行并接受TCP / IP连接   在5432港口?

我不知道问题是什么。

2 个答案:

答案 0 :(得分:2)

@Aidan自己找到了解决方案:

这是一个防火墙问题。

service iptables stop

启用了连接。我只是写一条规则来允许连接。

答案 1 :(得分:2)

假设服务器的IP地址为10.0.20.10,那么您可以将这些iptable规则添加为评论中提出的@Dark Star1:

iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 10.0.20.10 --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s 10.0.20.10 --sport 5432 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
相关问题