为什么FTP服务器给出的端口和客户端不同呢?
ck436 2010-01-22 09:46:16 我在内网建的FTP,用的是FireZilla server,并在路由器上对60001到61000上的端口范围做了映射,
并将服务器的被动模式端口范围设为60001到61000,被动模式IP设为外网IP,
当在客户端对服务器进行主动链接时是没问题的,但如果改为被动链接,就会出现两侧端口号不一致的现象,且不能列出目录,
这是为什么呢?
服务器端:
(000009) 2010/1/22 21:43:31 - anonymous (202.204.196.111)> 211 End
(000009) 2010/1/22 21:43:31 - anonymous (202.204.196.111)> PWD
(000009) 2010/1/22 21:43:31 - anonymous (202.204.196.111)> 257 "/" is current directory.
(000009) 2010/1/22 21:43:31 - anonymous (202.204.196.111)> TYPE I
(000009) 2010/1/22 21:43:31 - anonymous (202.204.196.111)> 200 Type set to I
(000009) 2010/1/22 21:43:31 - anonymous (202.204.196.111)> PASV
(000009) 2010/1/22 21:43:31 - anonymous (202.204.196.111)> 227 Entering Passive Mode (202,204,196,111,234,103)
(000009) 2010/1/22 21:43:31 - anonymous (202.204.196.111)> MLSD
(000009) 2010/1/22 21:43:41 - anonymous (202.204.196.111)> 425 Can't open data connection.
客户端:
响应: 211 End
状态: 已连接
状态: 读取目录列表...
命令: PWD
响应: 257 "/" is current directory.
命令: TYPE I
响应: 200 Type set to I
命令: PASV
响应: 227 Entering Passive Mode (202,204,196,111,129,132)
命令: MLSD
=======================
后来我把被动模式IP设为默认,就可以使用被动模式联上了,
我总觉得应该将被动模式改为外网IP才能联上,而改为默认应该不能联上才对,
为什么恰恰相反呢?实在搞不懂?
这是将被动模式IP设为默认之后的连接情况:
这是服务器端的信息:
(000007) 2010/1/22 21:34:32 - anonymous (202.204.196.111)> 211 End
(000007) 2010/1/22 21:34:32 - anonymous (202.204.196.111)> PWD
(000007) 2010/1/22 21:34:32 - anonymous (202.204.196.111)> 257 "/" is current directory.
(000007) 2010/1/22 21:34:32 - anonymous (202.204.196.111)> TYPE I
(000007) 2010/1/22 21:34:32 - anonymous (202.204.196.111)> 200 Type set to I
(000007) 2010/1/22 21:34:32 - anonymous (202.204.196.111)> PASV
(000007) 2010/1/22 21:34:32 - anonymous (202.204.196.111)> 227 Entering Passive Mode (192.168.86,234,102)
(000007) 2010/1/22 21:34:32 - anonymous (202.204.196.111)> MLSD
(000007) 2010/1/22 21:34:32 - anonymous (202.204.196.111)> 150 Connection accepted
(000007) 2010/1/22 21:34:32 - anonymous (202.204.196.111)> 226 Transfer OK
(000007) 2010/1/22 21:35:03 - anonymous (202.204.196.111)> NOOP
(000007) 2010/1/22 21:35:03 - anonymous (202.204.196.111)> 200 OK
(000007) 2010/1/22 21:35:33 - anonymous (202.204.196.111)> PWD
(000007) 2010/1/22 21:35:33 - anonymous (202.204.196.111)> 257 "/" is current directory.
我把服务器端的端号算了算,是在端口范围之内的(234*256+102=60006)
这是客户端的信息:
状态: 读取目录列表...
命令: PWD
响应: 257 "/" is current directory.
命令: TYPE I
响应: 200 Type set to I
命令: PASV
响应: 227 Entering Passive Mode (202,204,196,111,122,192)
命令: MLSD
响应: 150 Connection accepted
响应: 226 Transfer OK
状态: 列目录成功