ufw 不允许连接到端口 5432

ufw 不允许连接到端口 5432

我已经从 PGDG ppa 在 Ubuntu Trusty 上安装了 Postgresql 9.4。我创建了一个数据库并将其设置listen-addresses为“*”。我已在 pg_hba.conf 文件中添加了一个条目。我可以毫无问题地在本地连接。这是我的 pg_hba.conf 中的条目:

host all tarka 192.168.0.0/24 md5

问题是该端口似乎被 UFW 阻止了。我尝试了 ufw 命令的几种变体来允许 postgres,例如

sudo ufw allow postgresql/tcp

sudo ufw allow 5432/tcp

以及最近

sudo ufw allow from 192.168.0.0/24 to any port 5432

我每次都重新启动ufw。

目前的状态是这样的:

sudo ufw status verbose
Status: active
Logging: on (low)
Default: allow (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
22                         ALLOW IN    Anywhere
5432                       ALLOW IN    192.168.0.0/24
22 (v6)                    ALLOW IN    Anywhere (v6)

中的条目iptables似乎有效:

Chain ufw-user-input (1 references)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh
ACCEPT     udp  --  anywhere             anywhere             udp dpt:ssh
ACCEPT     tcp  --  192.168.0.0/24       anywhere             tcp dpt:postgresql
ACCEPT     udp  --  192.168.0.0/24       anywhere             udp dpt:postgresql

尽管如此,当我尝试从远程计算机连接时,ufw 会记录:

Sep  2 13:55:28 estuary kernel: [242754.395342] [UFW BLOCK] IN=eth0 OUT= MAC=94:de:80:27:4a:7e:b4:75:0e:97:21:29:08:00 SRC=192.168.0.13 DST=192.168.0.12 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=43525 DF PROTO=TCP SPT=36382 DPT=21 WINDOW=29200 RES=0x00 SYN URGP=0 

事实上,我什至无法通过禁用 ufw 来连接。在所有情况下,nmap报告端口 5432 均已关闭:

nmap estuary -p5432

Starting Nmap 6.40 ( http://nmap.org ) at 2015-09-02 16:43 PDT
Nmap scan report for estuary (192.168.0.12)
Host is up (0.0059s latency).
PORT     STATE  SERVICE
5432/tcp closed postgresql

此外,我nginx作为网络服务器运行,并且可以从另一台计算机完全访问它。

我怎样才能让 ufw(或任何实际执行此操作的东西)停止阻塞端口 5432?

编辑按照要求:

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 estuary:domain          *:*                     LISTEN     
tcp        0      0 *:51413                 *:*                     LISTEN     
tcp        0      0 *:ssh                   *:*                     LISTEN     
tcp        0      0 localhost:ipp           *:*                     LISTEN     
tcp        0      0 localhost:postgresql    *:*                     LISTEN     
tcp        0      0 *:smtp                  *:*                     LISTEN     
tcp        0      0 localhost:6010          *:*                     LISTEN     
tcp        0      0 *:49152                 *:*                     LISTEN     
tcp        0      0 *:9091                  *:*                     LISTEN     
tcp        0      0 *:5900                  *:*                     LISTEN     
tcp        0      0 *:http                  *:*                     LISTEN     
tcp        0      0 *:http-alt              *:*                     LISTEN     
tcp        0      0 192.168.0.12:ssh        cutter:46943            ESTABLISHED
tcp        1      0 192.168.0.12:46461      104.28.7.98:http        CLOSE_WAIT 
tcp        1      0 192.168.0.12:59407      89.234.156.205:http     CLOSE_WAIT 
tcp        0      0 localhost:38145         localhost:6010          ESTABLISHED
tcp        1      1 192.168.0.12:59404      89.234.156.205:http     LAST_ACK   
tcp        0      0 localhost:6010          localhost:38144         ESTABLISHED
tcp        0      0 localhost:6010          localhost:38145         ESTABLISHED
tcp        1      0 192.168.0.12:45068      89.218.2.238.stati:http CLOSE_WAIT 
tcp        0      0 192.168.0.12:9091       cutter:46825            ESTABLISHED
tcp        0      0 localhost:38144         localhost:6010          ESTABLISHED
tcp6       0      0 [::]:51413              [::]:*                  LISTEN     
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN     
tcp6       0      0 ip6-localhost:ipp       [::]:*                  LISTEN     
tcp6       0      0 [::]:smtp               [::]:*                  LISTEN     
tcp6       0      0 ip6-localhost:6010      [::]:*                  LISTEN     
tcp6       0      0 [::]:5900               [::]:*                  LISTEN     
tcp6       0      0 [::]:http               [::]:*                  LISTEN  

我的客户端(切割机)通过无线连接。

答案1

只是注意到在你的问题中你有带有连字符的“listen-addresses” - 文档有一个下划线(“listen_addresses”)

相关内容