一、实验原理介绍
设备支持多种文件管理方式,用户根据任务和安全性要求选择合适的文件管理方式。用户可以通过直接登录系统、FTP(File Transfer Protocol)、TFTP(Trivial File TransferProtocol)和 SFTP(Secure File Transfer Protocol)方式进行文件操作,实现对文件的管理。
设备在进行文件管理的过程中,可以分别充当服务器和客户端的角色:
- 设备作为服务器:可以从客户端访问设备,实现对本设备文件的管理,以及与客户端间的文件传输操作。
- 设备作为客户端访问其他设备(服务器):可以实现管理其他设备上的文件,以及与其他设备间进行文件传输操作。
二、实验目的
- 理解建立 FTP 连接的过程掌握
- FTP 服务器参数的配置掌握与
- FTP 服务器传输文件的方法
三、实验拓扑
R1 模拟FTP Client, R2 作为 FTP Server。
四、实验背景
R1 需要对 R2 的配置文件进行管理。
五、实验任务配置
(一)配置思路
1. 配置 FTP 服务器功能及参数 FTP Server 功能
2. 配置本地 FTP 用户
3.FTP Client登录FTP Server
4.FTP Client进行文件操作
(二)实验配置步骤
R1
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.1.1.1 24
May 9 2024 22:09:46-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1-GigabitEthernet0/0/1]quit
[R1]quit
<R1>save test.cfg
Are you sure to save the configuration to test.cfg? (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
R2
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 10.1.1.2 24
May 9 2024 22:11:00-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R2-GigabitEthernet0/0/1]quit
[R2]quit
<R2>save test2.cfg
Are you sure to save the configuration to test2.cfg? (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
# 查看当前的文件列表
<R1>dir
Directory of flash:/Idx Attr Size(Byte) Date Time(LMT) FileName
0 -rw- 845 May 09 2024 14:10:25 test.cfg
1 drw- - May 09 2024 14:06:48 dhcp
2 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
3 -rw- 2,263 May 09 2024 14:06:44 statemach.efs
4 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip
5 -rw- 249 May 09 2024 14:10:25 private-data.txt1,090,732 KB total (784,456 KB free)
<R2>dir
Directory of flash:/Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - May 09 2024 14:06:51 dhcp
1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
2 -rw- 2,263 May 09 2024 14:06:46 statemach.efs
3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip
4 -rw- 249 May 09 2024 14:11:18 private-data.txt
5 -rw- 845 May 09 2024 14:11:46 test2.cfg
6 -rw- 554 May 09 2024 14:11:18 vrpcfg.zip1,090,732 KB total (784,452 KB free)
可见配置文件已经保存成功
步骤 2 在R2 上配置 FTP 服务器功能及参数
[R2]ftp server enable
Info: Succeeded in starting the FTP server
ftp server enable命令用来开启设备的FTP服务器功能,允许FTP用户登录。缺省情况下FTP服务器功能处于关闭状态。
其他可选的配置参数还包括:指定FTP服务器端口号、指定FTP服务器的源地址和配置FTP连接空闲时间等。
步骤 3 配置本地 FTP 用户
[R2]aaa
[R2-aaa]local-user FTP_Server password cipher abcd1234// 华为的高版本配置范例:local-user xxx password irreversible-cipher xxx
Info: Add a new user.
[R2-aaa]local-user FTP_Server service-type ftp
[R2-aaa]local-user FTP_Server privilege level 15
配置FTP用户的级别,必须将用户级别配置在3级及3级以上,否则FTP连接将无法成功。
[R2-aaa]local-user FTP_Server ftp-directory flash:/
配置FTP用户的授权目录,必须指定该目录,否则FTP用户无法成功登陆。
步骤4 FTP Client 登陆 FTP Server
此时已经成功登陆到R2的文件系统。
步骤5 对 R2 文件系统做相应的操作
# 设置传输模式
设备支持的文件传输的数据类型包括ASCII和Binary模式。ASCII用于传输纯文本文件,Binary用于传输系统软件、图形图像、声音影像、压缩文件、数据库等程序文件。由于我们需要下载的配置文件为纯文本文件,所以需要设置为ASCII模式。缺省情况下,文件传输方式为ASCII模式,此处的操作仅为示范。
#下载配置文件
#文件目录已经能够看到下载的文件
#删除文件
#上传配置文件
#断开FTP连接
结果验证
查看当前R1和R2的文件目录:
配置参考
R1配置
#
sysname R1
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load portalpage.zip
#
drop illegal-mac alarm
#
set cpu-usage threshold 80 restore 75
#
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
#
firewall zone Local
priority 15
#
interface GigabitEthernet0/0/0
#
interface GigabitEthernet0/0/1
ip address 10.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return
R2配置
#
sysname R2
ftp server enable
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load portalpage.zip
#
drop illegal-mac alarm
#
set cpu-usage threshold 80 restore 75
#
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 ftp_server password cipher %$%$~)\<=5xN.'e9d7He-ip<#>tw%$%$
local-user ftp_server privilege level 15
local-user ftp_server ftp-directory flash:/
local-user ftp_server service-type ftp
#
firewall zone Local
priority 15
#
interface GigabitEthernet0/0/0
#
interface GigabitEthernet0/0/1
ip address 10.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return