我正在尝试在防火墙后面配置我的 pureftpd 以充当被动 ftp/TLS 服务器。代理机器:
- 服务器:192.168.3.220(内部网络,默认路由到路由器192.168.3.1) 配置:pureftpd with PassivePorts 64000 64300,MasqueradeAddress ww.xx.yy.zz(这个在路由器上配置)
- 路由器:内部:192.168.3.1,DNAT 规则(PREROUTING 链)ww.xx.yy.zz tcp/21,64000:64300 NAT 到地址 192.168.3.220,FORWARD 链双向接受这些数据包。
- Client1:固定公网IP的外部服务器
- Client2:某处经过 NAT 的机器 - 在 192.168.5.x 网络上
场景1:
- Client1: connect OK, login OK, command 'ls':
gets OK, after PASV:
---> PASV
GNUTLS: REC[0x28ecce0]: Sending Packet[9] Application Data(23) with length: 6
GNUTLS: REC[0x28ecce0]: Sent Packet[10] Application Data(23) with length: 37
GNUTLS: ASSERT: gnutls_buffers.c:322
GNUTLS: ASSERT: gnutls_buffers.c:322
GNUTLS: REC[0x28ecce0]: Expected Packet[9] Application Data(23) with length: 65536
GNUTLS: REC[0x28ecce0]: Received Packet[9] Application Data(23) with length: 64
GNUTLS: REC[0x28ecce0]: Decrypted Packet[9] Application Data(23) with length: 31
<--- 200 Protection set to Private
---> LIST
---> ABOR
有趣的事情:来自服务器的 227,我在 pureftpd 的偏执日志中看到,我在客户端上没有看到 - 只有 200 保护设置为 Private ...等待 cca 30 秒并使用 ACTIVE(!!) 模式重新连接 -> ls
场景2:
- using Client2 (sorry for czech locales):
---> USER xxxxxx
<--- 331 Password required for xxxxxx
---> PASS XXXX
<--- 230 User xxxxxx logged in
---> PWD
<--- 230 Ls oi a:2013-01-03 21:19:00
---> PBSZ 0
<--- 257 "/" is the current directory
---> PROT P
<--- 200 PBSZ 0 successful
---> PASV
<--- 200 Protection set to Private
---> LIST
---> ABOR
---- Přerušený datový socket bude uzavřen (means closing data socket)
---- Řídicí socket bude uzavřen (means closing control socket)
---- Pasivní režim bude vypnut (means Passive will be turned off)
---- dns cache hit
---- Navazuje se spojení na ftp1.xxxxxxxxx.cz (ww.xx.yy.zz) port 21
<--- 220 ww.xx.yy.zz FTP server ready
...
---> USER xxxxxx
<--- 331 Password required for xxxxxx
---> PASS XXXX
<--- 230 User xxxxxx logged in
---> PWD
<--- 230 Ls oi a:2013-01-03 21:19:22
---> PBSZ 0
<--- 257 "/" is the current directory
---> PROT P
<--- 200 PBSZ 0 successful
---> PORT 192,168,5,xx,185,136
<--- 200 Protection set to Private
---> LIST
<--- 500 Illegal PORT command
---- Closing data socket
---> QUIT
ls: Nepřekonatelná chyba: 500 Illegal PORT command
<--- 425 Unable to build data connection: Connection refused
NAT 机器上的 iptables 不会增加我在端口 64000:64300 上的记帐计数器,所以我希望根本没有被动连接。