VPS侦探论坛

 找回密码
 注册
查看: 4052|回复: 1

lnmp安装后,启用memcached成功,但是连接超时

[复制链接]
发表于 2017-4-7 13:49:39 | 显示全部楼层 |阅读模式

军哥,安装并启用memcached后,输入telnet 127.0.0.1 11211后,提示连接超时
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection timed out
关闭iptables之后,连接正常,考虑是端口问题。于是设置iptables
# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
DROP       udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:11211
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:11211
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:22
ACCEPT     all  --  127.0.0.1            127.0.0.1           
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80
ACCEPT     tcp  --  127.0.0.1            0.0.0.0/0            tcp dpt:11211
ACCEPT     udp  --  127.0.0.1            0.0.0.0/0            udp dpt:11211
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            0.0.0.0/0            tcp spt:22 state ESTABLISHED
ACCEPT     all  --  127.0.0.1            127.0.0.1           
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp spt:80 state ESTABLISHED
之后iptables -L出现:
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
DROP       udp  --  anywhere             anywhere             udp dpt:memcache
DROP       tcp  --  anywhere             anywhere             tcp dpt:memcache
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh
ACCEPT     all  --  localhost            localhost           
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     tcp  --  localhost            anywhere             tcp dpt:memcache
ACCEPT     udp  --  localhost            anywhere             udp dpt:memcache

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:ssh state ESTABLISHED
ACCEPT     all  --  localhost            localhost           
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:http state ESTABLISHED




我这样设置应该是正确的吧,但是还是无法连接到127.0.0.1 11211
我用的是lnmp1.3  centos7
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-4-7 14:19:15 | 显示全部楼层


1.3 的话memcached的规则应该是加到规则末尾的,而且是只有DROP,没有127.0.0.1 11211的accept,就是1.2的话也是127.0.0.1 11211的accept在前 DROP在后
可以按  https://www.vpser.net/security/linux-iptables.html 将INPUT里面的前两条删掉
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-27 09:28 , Processed in 0.026579 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表