无法连接到mongo shell似乎与iptables相关

时间:2015-09-26 07:29:31

标签: mongodb firewall iptables

刚刚在centos上安装了mongodb 6.尝试使用命令" mongo"连接到mongo sh。但收到此错误消息: 2015-09-26T07:07:35.309 + 0000 W NETWORK 5000毫秒后无法连接到127.0.0.1:27017,放弃了。 2015-09-26T07:07:35.316 + 0000 E QUERY错误:无法连接到服务器127.0.0.1:27017(127.0.0.1),连接尝试失败     在connect(src / mongo / shell / mongo.js:179:14)     在(连接):1:6在src / mongo / shell / mongo.js:179

然而,一旦我停止我的防火墙(iptables停止),我可以访问mongo shell 这是我的iptables:

Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:28017 
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080 
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:3306 
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:21 
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:443 
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80 
ACCEPT     tcp  --  192.168.1.0/24       0.0.0.0/0           tcp dpt:22 
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:22 
ACCEPT     tcp  --  127.0.0.1            0.0.0.0/0           tcp dpt:27017 state NEW,ESTABLISHED 
LOGGING    all  --  0.0.0.0/0            0.0.0.0/0           
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:51396 
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  0.0.0.0/0            127.0.0.1           tcp spt:27017 state ESTABLISHED 

Chain LOGGING (1 references)
target     prot opt source               destination         
LOG        all  --  0.0.0.0/0            0.0.0.0/0           limit: avg 2/min burst 5 LOG flags 0 level 4 prefix `IPTables-Dropped: ' 
DROP       all  --  0.0.0.0/0            0.0.0.0/0   

搜索并尝试了不同的解决方案。 取下锁,修理;重置iptables,没有任何帮助。

这是iptables丢弃数据包的日志

Sep 26 06:59:38 xxx kernel:IPTables-Dropped:IN = lo OUT = MAC = 00:00:00:00:00:00:00:00:00:00:00:00:08: 00 SRC = 127.0.0.1 DST = 127.0.0.1 LEN = 60 TOS = 0x00 PREC = 0x00 TTL = 64 ID = 0 DF PROTO = TCP SPT = 27017 DPT = 51396 WINDOW = 32768 RES = 0x00 ACK SYN URGP = 0

Sep 26 07:04:47 xxx内核:IPTables-Dropped:IN = lo OUT = MAC = 00:00:00:00:00:00:00:00:00:00:00:00:08: 00 SRC = 127.0.0.1 DST = 127.0.0.1 LEN = 60 TOS = 0x00 PREC = 0x00 TTL = 64 ID = 0 DF PROTO = TCP SPT = 27017 DPT = 59830 WINDOW = 32768 RES = 0x00 ACK SYN URGP = 0

无法确定为何仍会阻止27017。

1 个答案:

答案 0 :(得分:0)

在防火墙中打开端口(27017)。