通过FTP实现上传和下载

本实验基于华为eNSP模拟器,通过配置路由器作为FTP服务端

  1. 搭建拓扑
    在这里插入图片描述
    R1、R2配置IP地址、子网掩码
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R1
[R1]int e0/0/0
[R1-Ethernet0/0/0]ip add 192.168.1.1 24
[R1-Ethernet0/0/0]
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys	
[Huawei]sysname R2
[R2]int e0/0/0
[R2-Ethernet0/0/0]ip add 192.168.1.2 24
[R2-Ethernet0/0/0]

测试R1、R2连通性

[R1]ping 192.168.1.2
  PING 192.168.1.2: 56  data bytes, press CTRL_C to break
    Reply from 192.168.1.2: bytes=56 Sequence=1 ttl=255 time=60 ms
    Reply from 192.168.1.2: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 192.168.1.2: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 192.168.1.2: bytes=56 Sequence=4 ttl=255 time=40 ms
    Reply from 192.168.1.2: bytes=56 Sequence=5 ttl=255 time=50 ms

  --- 192.168.1.2 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/38/60 ms
  1. R1设置为服务端
    在R1上输入以下命令:
[R1]ftp server enable
Info: Succeeded in starting the FTP server.
[R1]set default ftp-directory flash:
[R1]aaa
[R1-aaa]local-user xiaoni privilege level 3 password cipher 123
Info: Add a new user.
[R1-aaa]local-user xiaoni service-type ftp
[R1-aaa]

R2作为客户端,通过FTP登录到R1

<R2>ftp 192.168.1.1
Trying 192.168.1.1 ...
Press CTRL+K to abort
Connected to 192.168.1.1.
220 FTP service ready.
User(192.168.1.1:(none)):xiaoni
331 Password required for xiaoni.
Enter password:
230 User logged in.

[ftp]
  1. 在客户端R2上实现对R1进行文件下载和上传

我们先看看R1上都有哪些文件,在用户视图< >下,通过dir查看R1硬件信息
在这里插入图片描述
在R1上复制一个文件,命名为r1.txt
在R2上复制一个文件,命名为r2.txt

<R1>copy private-data.txt r1.txt
Copy flash:/private-data.txt to flash:/r1.txt?[Y/N]:y

100%  complete
Info: Copied file flash:/private-data.txt to flash:/r1.txt...Done.

通过dir查看R1、R2硬件

<R1>dir
Directory of flash:/

  Idx  Attr     Size(Byte)  Date        Time       FileName 
    0  drw-              -  Aug 07 2015 13:51:14   src
    1  drw-              -  Oct 12 2021 16:56:35   pmdata
    2  drw-              -  Oct 12 2021 16:56:43   dhcp
    3  -rw-             28  Oct 12 2021 16:56:44   private-data.txt
    4  drw-              -  Oct 12 2021 17:11:48   mplstpoam
    5  -rw-             28  Oct 12 2021 17:21:29   r1.txt

32,004 KB total (31,993 KB free)
<R2>dir
Directory of flash:/

  Idx  Attr     Size(Byte)  Date        Time       FileName 
    0  drw-              -  Aug 07 2015 13:51:14   src
    1  drw-              -  Oct 12 2021 16:56:36   pmdata
    2  drw-              -  Oct 12 2021 16:56:43   dhcp
    3  -rw-             28  Oct 12 2021 16:56:44   private-data.txt
    4  drw-              -  Oct 12 2021 17:11:49   mplstpoam
    5  -rw-             28  Oct 12 2021 17:40:53   r2.txt

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

R2:下载R1上的r1.txt文件

[ftp]get r1.txt
200 Port command okay.
150 Opening ASCII mode data connection for r1.txt.

226 Transfer complete.
FTP: 28 byte(s) received in 0.260 second(s) 107.69byte(s)/sec.

在R2上通过dir查看硬件,测试是否存在r1.txt
在这里插入图片描述
R2:给R1上传r2.txt文档

[ftp]put r2.txt
200 Port command okay.
150 Opening ASCII mode data connection for r2.txt.

100%     
226 Transfer complete.
FTP: 28 byte(s) sent in 0.260 second(s) 107.69byte(s)/sec.

在R1上通过dir查看硬件,测试是否存在r2.txt
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值