大网数据广告活动
服务器运维问答

How to learn Remote FTP Server 's Passive Port Range

· 52CE 我爱测

Is there any way to learn the port range of "Passive" FTP Server which is not in my authority. It is possible to set the range within configuration file. For example within vsftpd.conf : pasv_min_port=25000 pasv_max_port=25500 #p…

问题原文

原帖链接 · Aesnak · CC BY-SA 3.0

Is there any way to learn the port range of "Passive" FTP Server which is not in my authority. It is possible to set the range within configuration file. For example within vsftpd.conf :

pasv_min_port=25000
pasv_max_port=25500
#pasv_min_port=0
#pasv_max_port=0 (any port)

Since I want to apply a very restricted OUTPUT firewall (iptables) on my Linux Terminal Server, i need to know remote server's port range. Is FTP supports expose of port-range information, that clients can use of?

I am also open for any other possible solutions except the following one where i assume the server IP address as 10.1.1.1 :

-A OUTPUT -d 10.1.1.1 -j ACCEPT

Thanks for your interest...

Regards

EDIT

Thanks for @aaron-copley, @martin-prikryl, @user3590719

Answer for main question, FTP doesn't expose passive port range to the clients.

Solution of need is loading netfilter connection tracking module for FTP.

ip_conntrack_ftp (Module alias for CentOS/Red Hat : nf_conntrack_ftp)

Working example config for Red Hat 7:

/etc/sysconfig/iptables-config

IPTABLES_MODULES="nf_conntrack_ftp"

iptables rules

-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -d 10.1.1.1/32 -p tcp -m tcp --dport 21 -j ACCEPT
-A OUTPUT -j DROP

Finally, manualy load module or restart iptables.service.

已采纳解答

原帖链接 · Martin Prikryl · CC BY-SA 3.0

The passive port range is not publicly announced by an FTP server.

All you can do is to automate parallel transfers of many files to/from the server and deduce the range from the ports used for these transfers.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-01-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。