FTP主被动模式实验

 

要求:

配置FTP   并观察 主动模式和被动模式差别 并抓包查看

 

 PORT模式 主动模式

【配置】

AR4  FTP服务器

 

 

[ar4]dis cu configuration aaa

[V200R003C00]

#

aaa

authentication-scheme default

authorization-scheme default

accounting-scheme default

domain default

domain default_admin

local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$

local-user admin service-type http

local-user qytang password cipher %$%$2Q&W>nDQ&Rm8>CK:w|BBb(3n%$%$                 //配置用户qytang密码

local-user qytang privilege level 15                                                                                            //配置用户qytang认证后登录的等级

local-user qytang ftp-directory flash:                                                                                       //配置用户qytangFTP目录

local-user qytang service-type ftp                                                                                            //配置用户qytang服务类型

[ar4]ftp server enable                                                                                                            //开启FTP服务   华为默认不开启 包括telnet

Info: The FTP server is already enabled

 

 

[ar4-GigabitEthernet0/0/0]dis this

[V200R003C00]

#

interface GigabitEthernet0/0/0

ip address 10.1.1.1 255.255.255.0                                     //配置接口IP地址

 

 

 

 

【AR5】

[AR5-GigabitEthernet0/0/0]dis this

[V200R003C00]

#

interface GigabitEthernet0/0/0

ip address 10.1.1.2 255.255.255.0

 

【测试】

[AR5]ping 10.1.1.1               //AR5pingAR4 能ping通

  PING 10.1.1.1: 56  data bytes, press CTRL_C to break

    Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=255 time=40 ms

    Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=255 time=20 ms

    Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=255 time=10 ms

    Reply from 10.1.1.1: bytes=56 Sequence=4 ttl=255 time=20 ms

    Reply from 10.1.1.1: bytes=56 Sequence=5 ttl=255 time=30 ms

  --- 10.1.1.1 ping statistics ---

    5 packet(s) transmitted

    5 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 10/24/40 ms

 

 

 

FTP的模式:【主动模式】 PORT模式

<AR5>ftp 10.1.1.1

Trying 10.1.1.1 ...

Press CTRL+K to abort

Connected to 10.1.1.1.

220 FTP service ready.

User(10.1.1.1:(none)):qytang

331 Password required for qytang.

Enter password:*********

230 User logged in.

 

[ar4]dis tcp status

TCPCB    Tid/Soid Local Add:port        Foreign Add:port      VPNID  State

b4b00ba0 210/1    0.0.0.0:21            0.0.0.0:0             23553  Listening

b4affef8 6  /1    0.0.0.0:23            0.0.0.0:0             23553  Listening

b4b00f6c 210/3    10.1.1.1:21           10.1.1.2:49312        0      Established                 //通过服务器的21断开建立控制连接

 

 

 

<ar4>save ender.zip

Are you sure to save the configuration to ender.zip? (y/n)[n]:y

flash:/ender.zip exists, overwrite? (y/n)[n]:y

  It will take several minutes to save configuration file, please wait.......

  Configuration file had been saved successfully

  Note: The configuration file will take effect after being activated

 

[AR5-ftp]get ender.zip

Warning: The file ender.zip already exists. Overwrite it? (y/n)[n]:y

200 Port command okay.

150 Opening ASCII mode data connection for ender.zip.

226 Transfer complete.

FTP: 638 byte(s) received in 0.310 second(s) 2.05Kbyte(s)/sec.

 

 

 

【验证】

<ar4>dis tcp status

TCPCB    Tid/Soid Local Add:port        Foreign Add:port      VPNID  State

b4b00ba0 210/1    0.0.0.0:21            0.0.0.0:0             23553  Listening

b4affef8 6  /1    0.0.0.0:23            0.0.0.0:0             23553  Listening

b4b00ce4 213/1    10.1.1.1:20           10.1.1.2:51190        0      Time_Wait                     //主动模式通过服务器的20端口通信数据信息   由服务器20端口主动发起

b4b00f6c 210/4    10.1.1.1:21           10.1.1.2:49754        0      Established


 

 

Port  10.1.1.2  199 246    计算公式:199*256+246=51190

客户端通过port( 10.1.1.2  199 246 ) 发送给服务器  告诉服务器客户端使用的端口     

服务器使用20端口 主动与客户端 建立数据连接   

 

传输数据时  服务器20端口 主动与客户端计算的端口 也是建立三次握手 

然后开始传送数据

 

服务器 20端口--------->主动建立连接--------->客户端 51190端口

 

最后服务器发起四次断开(数据层面)

 

 

 

 

 

 


 

 

passive模式【被动接口】

[AR5-ftp]passive

Info: Succeeded in switching passive on.

[AR5-ftp]get ender.zip

Warning: The file ender.zip already exists. Overwrite it? (y/n)[n]:y

227 Entering Passive Mode (10,1,1,1,195,99).

125 ASCII mode data connection already open, transfer starting for ender.zip.

226 Transfer complete.

FTP: 638 byte(s) received in 0.200 second(s) 3.19Kbyte(s)/sec.

 

<ar4>dis tcp status    

TCPCB    Tid/Soid Local Add:port        Foreign Add:port      VPNID  State

b4b00ba0 210/1    0.0.0.0:21            0.0.0.0:0             23553  Listening

b4affef8 6  /1    0.0.0.0:23            0.0.0.0:0             23553  Listening

b4b00f6c 210/5    10.1.1.1:21           10.1.1.2:49443        0      Established

b4b00a5c 214/2    10.1.1.1:50019        10.1.1.2:49961        23553  Time_Wait           //  passive 模式下  服务器采用计算的端口(大于1024)  与客户端的随机端口建立数据连接   客户端主动发起的

 

 

 

 

【FTP模式】passive模式  被动模式

 

 

 

 

 

step1)

客户端 通过服务器 21端口  发送 PASV 

服务器回应 回包客户端 10.1.1.1 195 99  通过计算得出服务 器数据传输端口 256*195+99=50019  服务器采用的数据端口为50019 

 

step2)然后客户端通过随机端口  主动发起服务器数据端口50019  控制的三次握手

step3)开始传送数据 

 

step4)结束时 服务端发起四次断开 

 

posted @ 2020-08-27 11:02  yy50567893  阅读(214)  评论(0编辑  收藏  举报