三三世界-百宝箱

文章 分类 标签
130 9 247

公告

暂无站点公告

PureFTP被动端口设置

三三 2021-11-11 1567 0条评论 环境搭建 PureFTP错误提示被动端口

首页 / 正文

问题描述:

PureFTP安装完毕,添加了用户以后,无法列出目录。或者始终无法连接FTP。提示一些错误,如下:

[18:00:12] [L] 504 Unknown command
[18:00:12] [L] PWD
[18:00:12] [L] 257 "/" is your current location
[18:00:12] [L] CWD /
[18:00:12] [L] 250 OK. Current directory is /
[18:00:12] [L] PWD
[18:00:12] [L] 257 "/" is your current location
[18:00:12] [L] PRET LIST
[18:00:12] [L] 200 Ready to proceed
[18:00:12] [L] PASV
[18:00:12] [L] 227 Entering Passive Mode (42,192,46,139,117,66)
[18:00:12] [L] 正在打开数据连接 IP: 42.192.46.139 端口: 30018
[18:00:33] [L] 数据套接字错误: 连接已超时
[18:00:34] [L] 列表 错误
[18:00:34] [L] 以 PASV 模式连接失败,正在尝试 PORT 模式。
[18:00:34] [L] 正在侦听端口: 54562,正在等待连接。
[18:00:34] [L] PORT 192,168,1,3,213,34
[18:00:34] [L] 200 PORT command successful
[18:00:34] [L] MLSD

解决办法分为基本部分:

1、在pureftp的设置文件,修改被动端口部分,开启被动端口,并修改端口区间。文件位置一般为:/usr/local/pureftpd/etc/pure-ftpd.conf
如果自己选择了安装目录,请结合相关目录找到conf文件,进行修改。

# PassivePortRange          20000 20050

去掉前面的#,端口目前的区间是20000 - 20050,根据自己的情况进行修改即可。不建议使用太大范围的端口。
原因是一方面,将来如果开启防火墙,需要把这个区间的端口都打开,增加一定风险。
另一方面是如果您使用的是阿里云或者腾讯云,也需要将对应部分的端口打开。

注意:修改完毕后,重启pureftp使修改生效:/etc/init.d/pureftpd restart

2、在服务器将对应端口部分加入防火墙。
如果是使用iptable的版本,命令为:

iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 30000:31000 -j DNAT --to 192.168.0.0

然后iptables-save > /etc/iptables保存规则。
如果是centos,直接执行:iptables-save即可。
注意:192.168.0.0 是您的服务器IP地址。
查看iptable已经开放的端口参考:

iptables -L -n   /查看已开放端口
nano /etc/sysconfig/iptables  //编辑现有端口,也可以使用vi
systemctl restart iptables.service    //centos7 重启iptables
systemctl enable iptables.service     //centos7 开机启动iptables

如果是使用的是firewall,那使用命令:

firewall-cmd --zone=public --add-port=20000-20050/tcp --permanent

完毕之后,运行命令重启firewall

firewall-cmd --reload # 配置立即生效

这样就完成了自己服务器层面的端口开放。
如果提示firewall-com没有启动之类的参考:CentOS7防火墙设置

3、如果用的是普通的服务器或者云,到此即可完毕了。如果使用的是阿里云或者腾讯云类似的ECS服务。那么需要到指定云服务器或者服务器的防火墙规则里开放对应的端口。
如:21,20000-20050.
注意,在第三方防火墙设置的时候也可以使用端口区域。一次就可以设置完毕。

上述三个步骤完成以后,再连接FTP就会正常了。

如果连接正常后,删除文件或者写入失败没有权限,那么参考文章:PureFtp无法删除或覆盖文件以及文件夹Permission denied

评论(0)

当前没有评论,还不快来留下第一个脚印吧


Copyright 2021 三三世界-百宝箱. All Rights Reserved.

最新评论

  • 三三

    @Doug Shume it's ok for me , you can post here.

  • refugiaguenther

    Saved as a favorite, I like your website!

  • josefa

    If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.

  • Penzu

    Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!

  • Yupoo Fendi

    Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.

  • Doug Shume

    Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.

  • SuperWind

    zh.us.to 有效
    kms.03k.org 有效
    kms.chinancce.com
    kms.shuax.com 有效
    kms.dwhd.org 有效
    kms.luody.info 有效
    kms.digiboy.ir 有效
    kms.lotro.cc 有效
    www.zgbs.cc 有效
    cy2617.jios.org 有效

  • 三三

    @         权限问题,试试sudo 再加命令。

  •         

    你好提示Permission denied 怎么办啊

日历

2024年05月

   1234
567891011
12131415161718
19202122232425
262728293031 

文章目录

上一张 下一张