命令记不住

登陆

网络设备实施 FTP 协议

网络设备实施FTP协议

1.FTP文件传输协议简介

FTP是TCP/IP协议族中的一种应用层协议,称为文件传输协议,FTP的主要功能是向用户提供本地和远程主机之间的文件传输,FTP采用两个TCP连接:控制连接和数据连接,其中控制连接用于控制端口,传输控制命令;数据连接用于连接数据端口,传输数据;在控制连接建立后,数据连接通过控制端口的命令建立起连接,进行数据的传输,FTP数据连接的建立有两种;主动模式和被动模式,两者的区别在于数据连接是由服务器发起还是由客户端发起

  • 主动模式:客户端向服务器的21端口发起请求,然后服务器主动发起数据连接
  • 被动模式:客户端向服务器的21端口发起请求,然后服务器开放范围端口让客户端去连接

2.实施FTP协议

1.配置FTP协议案例拓扑

在本例中作为FTP服务器和客户端的设备使用华为的路由器和交换机,并且采用了两台直连设备,在现网中,读者可以使用一些FTP软件,网络并不需要直连,但要满足FTP服务器和FTP客户端可以通信,AR1(192.168.0.1/30)作为FTP协议的服务器端,交换机1(VLAN地址为192.168.0.2/30)作为FTP协议的客户端

2.FTP协议的组网需求

设备需要进行文件操作,将路由器作为FTO服务器,从终端交换机将系统软件从路由器下载到本设备,该功能普遍的用于VRP的备份、升级等操作

3.配置FTP协议步骤详解

  • 保证网络通信
  • 开启FTP服务
  • aaa下设备正确的用户名和密码以及该用户的权限、服务类型和共享的FTP目录
  • 使用正确的测试方式

4.配置路由器基本的网络和FTP服务

1.首先保证设备之间的网络可以通信
AR1

[AR1]sysname AR-01
[AR-01]interface G0/0/1             #进入GigabitEthernet0/0/0接口视图
[AR-01-GigabitEthernet0/0/1]ip address 192.168.0.2 30 #为该接口配置地址  掩码为30
Feb 15 2020 17:13:29-08:00 AR-01 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. 
[AR-01-GigabitEthernet0/0/1]

LSW1

[LSW1]interface vlan 1
[LSW1-Vlanif1]ip address 192.168.0.1 30

测试是否可以相互ping通

2.FTP协议实施

[AR-01]ftp server enable            #在路由器上开启FTP服务
Info: Succeeded in starting the FTP server
[AR-01]aaa                          #进入aaa
[AR-01-aaa]local-user ender password cipher 123456   #增加一个ftp用户
Info: Add a new user.
[AR-01-aaa]local-user ender service-type ?  
  8021x     802.1x user
  bind      Bind authentication user
  ftp       FTP user
  http      Http user
  ppp       PPP user
  ssh       SSH user
  sslvpn    Sslvpn user
  telnet    Telnet  user
  terminal  Terminal user
  web       Web authentication user
  x25-pad   X25-pad user
[AR-01-aaa]local-user ender service-type ftp        #设置用户ender的服务类型为ftp
[AR-01-aaa]local-user ender privilege  level 15     #设置用户ender权限为最高权限
[AR-01-aaa]local-user ender ftp-directory flash:    #设置用户ender可操作的目录为flash所有目录
[AR-01-aaa]q
[AR-01]q
<AR-01>save                                         #返回到用户视图进行保存设置
  The current configuration will be written to the device. 
  Are you sure to continue? (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
<AR-01>dir                                      #查看文件
Directory of flash:/

  Idx  Attr     Size(Byte)  Date        Time(LMT)  FileName 
    0  drw-              -  Feb 15 2020 08:49:21   dhcp
    1  -rw-        121,802  May 26 2014 09:20:58   portalpage.zip
    2  -rw-          2,263  Feb 15 2020 08:48:59   statemach.efs
    3  -rw-        828,482  May 26 2014 09:20:58   sslvpn.zip
    4  -rw-            249  Feb 15 2020 09:24:50   private-data.txt
    5  -rw-            644  Feb 15 2020 09:24:50   vrpcfg.zip

1,090,732 KB total (784,448 KB free)
<AR-01>

3.配置ftp协议客户端
本例采用华为网络设备作为FTP协议的客户端
查看客户端LSW1的配置

[LSW1]interface Vlanif 1
[LSW1-Vlanif1]display this 
#
interface Vlanif1
 ip address 192.168.0.1 255.255.255.252
#
return
[LSW1-Vlanif1]

测试FTP连接以及实施文件拷贝

<LSW1>ftp 192.168.0.2               #用户视图
Trying 192.168.0.2 ...
Press CTRL+K to abort
Connected to 192.168.0.2.
220 FTP service ready.
User(192.168.0.2:(none)):ender      #登录用户
331 Password required for ender.
Enter password:                     #用户密码
230 User logged in.

[ftp]dir                            #查看FTP服务器
200 Port command okay.
150 Opening ASCII mode data connection for *.
drwxrwxrwx   1 noone    nogroup         0 Feb 15 08:49 dhcp
-rwxrwxrwx   1 noone    nogroup    121802 May 26  2014 portalpage.zip
-rwxrwxrwx   1 noone    nogroup      2263 Feb 15 08:48 statemach.efs
-rwxrwxrwx   1 noone    nogroup    828482 May 26  2014 sslvpn.zip
-rwxrwxrwx   1 noone    nogroup       249 Feb 15 09:24 private-data.txt
drwxrwxrwx   1 noone    nogroup         0 Feb 15 09:24 .
-rwxrwxrwx   1 noone    nogroup       644 Feb 15 09:24 vrpcfg.zip
226 Transfer complete.

[ftp]get portalpage.zip             #使用get命令下载文件
200 Port command okay.
150 Opening ASCII mode data connection for portalpage.zip.
226 Transfer complete.
FTP: 121802 byte(s) received in 2.680 second(s) 45.44Kbyte(s)/sec.
[ftp]

[ftp]q
221 Server closing.

<LSW1>dir                           #确认下载成功
Directory of flash:/

  Idx  Attr     Size(Byte)  Date        Time       FileName 
    0  drw-              -  Aug 06 2015 21:26:42   src
    1  drw-              -  Feb 15 2020 16:48:38   compatible
    2  -rw-        121,802  Feb 15 2020 17:35:12   portalpage.zip

32,004 KB total (31,852 KB free)

实施完成

推荐阅读