免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 5864 | 回复: 25
打印 上一主题 下一主题

[服务应用] 配置vsftpd被动模式出错 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-07-17 12:04 |只看该作者 |倒序浏览
系统是Debian,
我在/etc/vsftpd.conf中加入下面几句,vsftpd就不能启动了。

pasv_enable=YES
pasv_min_port=60000
pasv _max_port=60045
setproctitle_enable=YES

把这几句删除之后,vsftpd才能正常启动。

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
2 [报告]
发表于 2013-07-17 12:07 |只看该作者
服务启动不了,先检查下系统日志里面有没有提示

论坛徽章:
0
3 [报告]
发表于 2013-07-17 12:15 |只看该作者
chenyx 发表于 2013-07-17 12:07
服务启动不了,先检查下系统日志里面有没有提示


刚刚发现,在vsftpd.conf里面把上面几句删掉,然后把connect_from_port_20=YES这句屏蔽掉,在iptables中没有打开20端口,居然可能访问ftp
用netstat查看,我有两个客户端连接上了ftp服务器,但传输端口不连续:
~# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh state NEW,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere             tcp dpts:60000:60045
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ftp
ACCEPT     all  --  anywhere             anywhere             state NEW,RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        


~# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:55383           0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN     
tcp        0      0 192.168.197.254:21      192.168.197.6:1928      ESTABLISHED
tcp        0      0 192.168.197.254:34887   192.168.197.6:5010      ESTABLISHED
tcp        0      0 192.168.197.254:21      192.168.197.6:1946      ESTABLISHED
tcp        0      0 192.168.197.254:41084   192.168.197.6:5006      TIME_WAIT  
tcp        0      0 192.168.197.254:34385   192.168.197.6:5008      TIME_WAIT  
tcp        0      0 192.168.197.254:60712   192.168.197.6:5004      TIME_WAIT  
tcp        0      0 192.168.197.254:22      192.168.197.5:55820     ESTABLISHED
tcp        0      0 192.168.197.254:34284   192.168.197.6:5005      TIME_WAIT  
tcp        0      0 192.168.197.254:57905   192.168.197.6:5013      TIME_WAIT  
tcp        0      0 192.168.197.254:59569   192.168.197.6:5007      TIME_WAIT  

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
4 [报告]
发表于 2013-07-17 12:21 |只看该作者
默认pasv_min/max_port的值是0,也就是可以使用任何的端口

论坛徽章:
0
5 [报告]
发表于 2013-07-17 14:46 |只看该作者
chenyx 发表于 2013-07-17 12:21
默认pasv_min/max_port的值是0,也就是可以使用任何的端口


问题是我没有开放41084,34385这些端口啊

并且我这样写:
iptables -A INPUT -p tcp --dport 60000:60050 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
就连不上去:
~$ ftp 192.168.197.254
Connected to 192.168.197.254.
220 (vsFTPd 2.3.5)
Name (192.168.197.254:ch): ipt
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful. Consider using PASV.
425 Failed to establish connection.
ftp>


还有,在vsftpd中加入pasv_min/max_port后,vsftpd就启动不了,查日志,也没有提示

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
6 [报告]
发表于 2013-07-17 14:59 |只看该作者
ACCEPT 愀氀氀--愀渀礀眀栀攀爀攀     anywhere     state NEW,RELATED,ESTABLISHED

问题在于你的这个语句里面的NEW.你去掉,应该是连不上的.

论坛徽章:
0
7 [报告]
发表于 2013-07-17 15:17 |只看该作者
chenyx 发表于 2013-07-17 14:59
问题在于你的这个语句里面的NEW.你去掉,应该是连不上的.


NEW一直在啊,没有去掉

我现在在vsftpd.conf里把pasv_max_port写在pasv_min_port前面,vsftpd启动正常了,但ftp还是连不上去。

vsftpd.conf里

注释掉:
#connect_from_port_20=YES

加上:
pasv_enable=YES
pasv_max_port=60050
pasv_min_port=60000


# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh state NEW,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere             tcp dpts:60000:60050 state NEW,RELATED,ESTABLISHED

~$ ftp 192.168.197.254
Connected to 192.168.197.254.
220 (vsFTPd 2.3.5)
Name (192.168.197.254:ch): ipt
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200 PORT command successful. Consider using PASV.

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
8 [报告]
发表于 2013-07-17 15:22 |只看该作者
你看看ip_conntrack_ftp模块加载正常不?加载下看看

论坛徽章:
0
9 [报告]
发表于 2013-07-17 15:24 |只看该作者
我发现这样写就能正常连接ftp

root@IPt:/etc# iptables -A INPUT -p tcp --dport 60000:60050 -j ACCEPT
root@IPt:/etc# iptables -A INPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
root@IPt:/etc# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh state NEW,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere             tcp dpts:60000:60050
ACCEPT     all  --  anywhere             anywhere             state NEW,RELATED,ESTABLISHED

论坛徽章:
0
10 [报告]
发表于 2013-07-17 15:25 |只看该作者
本帖最后由 73年生人 于 2013-07-17 15:26 编辑
chenyx 发表于 2013-07-17 15:22
你看看ip_conntrack_ftp模块加载正常不?加载下看看


root@IPt:/etc# lsmod
Module                  Size  Used by
nf_nat_ftp             12460  0
nf_conntrack_ftp       12605  1 nf_nat_ftp


我发现这样写就能正常连接ftp

root@IPt:/etc# iptables -A INPUT -p tcp --dport 60000:60050 -j ACCEPT
root@IPt:/etc# iptables -A INPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
root@IPt:/etc# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh state NEW,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere             tcp dpts:60000:60050
ACCEPT     all  --  anywhere             anywhere             state NEW,RELATED,ESTABLISHED


这是什么原因?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP