FTP 主动模式与被动模式

目录

基础知识

  • FTP is a TCP based service exclusively. There is no UDP component to FTP.
  • FTP is an unusual service in that it utilizes two ports, a ‘data’ port and a ‘command’ port (also known as the control port). Traditionally these are port 21 for the command port and port 20 for the data port.
  • The data port is not always on port 20, depending on the mode(active mode and passive mode).

主动模式

主动模式客户端服务端交互过程
1. Server 监听 21 端口,Client 使用随机端口 N(1026) 主动连接 Server 21 端口,并将端口 N+1(1027) 发送给 Server, 告诉 Server Client 监听 N+1 端口,用作数据传输。
2. Server 给 Client 回 ACK 包。
3. Server 使用端口 20 主动连接 Client 的 N+1 端口。
4. Client 给 Server 回 ACK 包。

主动模式的问题 - 局域网和防火墙

  1. 一般客户端处于局域网中,开启监听的数据传输用的地址是内网地址,外网 FTP server 连接该地址;
  2. 即使客户端直接使用外网 IP, 防火墙的配置也是个问题,因为客户端开启的数据传输监听端口是随机的,防火墙只能按 IP 配置,如果 FTP server 是一个接入了多个 IP 的域名,那按 IP 配置也将行不通。(Nowadays, it is typical that the client is behind a firewall (e.g. built-in Windows firewall) or NAT router (e.g. ADSL modem), unable to accept incoming TCP connections. FTP Connection Modes (Active vs. Passive))

被动模式

被动模式客户端服务端交互过程
1. Server 监听 21 端口,Client 使用随机端口 N(1026) 主动连接 Server 21 端口,并告诉 Server 使用 PASV 模式。
2. Server 告诉 Client 使用随机端口 2024 作为数据传输端口。
3. Client 使用 N+1(1027) 端口连接 Server 2024 端口。
4. Server 给 Client ACK 包。

被动模式的问题

  1. 被动模式会使 Server 负载增
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值