5.1实验一:FTP基础配置实验

小编:小丢 更新时间:2022-05-06
5.1实验一:FTP基础配置实验

一、组网需求

R1模拟FTP Client,R2作为FTP Server,R1需要对R2的配置文件进行管理。

设备支持多种文件管理方式,用户根据任务和安全性要求选择合适的文件管理方式。

用户可以通过直接登录系统、FTP(File Transfer Protocol)、TFTP(Trivial File Transfer Protocol)和SFTP(Secure File Transfer Protocol)方式进行文件操作,实现对文件的管理。

设备在进行文件管理的过程中,可以分别充当服务器和客户端的角色:

• 设备作为服务器:可以从客户端访问设备,实现对本设备文件的管理,以及与客户端间的文件传输操作。

• 设备作为客户端访问其他设备(服务器):可以实现管理其他设备上的文件,以及与其他设备间进行文件传输操作。

二、eNSP实验视频:

视频加载中...

三、配置思路

1. 配置FTP服务器功能及参数FTP Server功能

2. 配置本地FTP用户

3. FTP Client登录FTP Server

4. FTP Client进行文件操作

四、配置步骤

步骤 1 设备基础配置

# 完成路由器的命名、物理接口的IP地址配置

R1:GE0/0/0:10.0.12.1/24

R2:GE0/0/0:10.0.12.2/24

步骤 2 设备基础配置

# 设备命名

略。


# 配置设备IP地址

[R1]interface GigabitEthernet 0/0/0

[R1-GigabitEthernet0/0/0]ip address 10.0.12.1 24


[R2]interface GigabitEthernet 0/0/0

[R2-GigabitEthernet0/0/0]ip address 10.0.12.2 24

[R2-GigabitEthernet0/0/0]quit


# 保存配置文件(用与后续验证实验效果)

save test1.cfg

Are you sure to save the configuration to test1.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


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


# 查看当前的文件列表

dir

Directory of flash:/


Idx Attr Size(Byte) Date Time(LMT) FileName

0 -rw- 126,538,240 Jul 04 2016 17:57:22 ar651c- v300r019c00Sspc100.cc

1 -rw- 23,963 Feb 21 2020 09:22:53 mon_file.txt

2 -rw- 721 Feb 21 2020 10:14:33 vrpcfg.zip

3 drw- - Jul 04 2016 18:51:04 CPM_ENCRYPTED_FOLDER

4 -rw- 783 Jul 10 2018 14:46:16 default_local.cer

5 -rw- 0 Sep 11 2017 00:00:54 brdxpon_snmp_cfg.efs

6 drw- - Sep 11 2017 00:01:22 update

7 drw- - Sep 11 2017 00:01:48 shelldir

8 drw- - Feb 20 2020 21:33:16 localuser

9 drw- - Sep 15 2017 04:35:52 dhcp

10 -rw- 509 Feb 21 2020 10:18:31 private-data.txt

11 -rw- 2,686 Dec 19 2019 15:05:18 mon_lpu_file.txt

12 -rw- 3,072 Dec 18 2019 18:15:54 Boot_LogFile

13 -rw- 1,390 Feb 21 2020 10:18:30 test1.cfg


510,484 KB total available (386,448 KB free)


dir

Directory of flash:/


Idx Attr Size(Byte) Date Time(LMT) FileName

0 -rw- 126,538,240 Jul 04 2016 17:57:22 ar651c- v300r019c00Sspc100.cc

1 -rw- 11,405 Feb 21 2020 09:21:53 mon_file.txt

2 -rw- 809 Feb 21 2020 10:14:10 vrpcfg.zip

3 drw- - Jul 04 2016 18:51:04 CPM_ENCRYPTED_FOLDER

4 -rw- 782 Jul 10 2018 14:48:14 default_local.cer

5 -rw- 0 Oct 13 2017 15:36:32 brdxpon_snmp_cfg.efs

6 drw- - Oct 13 2017 15:37:00 update

7 drw- - Oct 13 2017 15:37:24 shelldir

8 drw- - Feb 20 2020 20:51:34 localuser

9 drw- - Oct 14 2017 11:27:04 dhcp

10 -rw- 1,586 Feb 21 2020 10:16:51 test2.cfg

11 -rw- 445 Feb 21 2020 10:16:52 private-data.txt

12 -rw- 4,096 Aug 06 2019 11:19:08 Boot_LogFile


510,484 KB total available (386,464 KB free)

两台设备上的配置文件都已经保存成功。


步骤 3 在R2上配置FTP服务器功能及参数

[R2]ftp server enable

Info: Succeeded in starting the FTP server

ftp server enable命令用来开启设备的FTP服务器功能,允许FTP用户登录。缺省情况下,FTP服务器功能处于关闭状态。

其他可选的配置参数还包括:指定FTP服务器端口号、指定FTP服务器的源地址和配置FTP连接空闲时间等。


步骤 4 配置本地FTP用户

[R2]aaa

[R2-aaa]local-user test password irreversible-cipher Huawei@123

Info: Add a new user.

[R2-aaa]local-user test service-type ftp

[R2-aaa]local-user test privilege level 15

配置FTP用户的级别,必须将用户级别配置在3级及3级以上,否则FTP连接将无法成功。

[R2-aaa]local-user test ftp-directory flash:/

配置FTP用户的授权目录,必须指定该目录,否则FTP用户无法成功登陆。

步骤 5 FTP Client登陆FTP Server

# 登陆FTP Client

ftp 10.0.12.2

Trying 10.0.12.2 ...


Press CTRL+K to abort

Connected to 10.0.12.2.

220 FTP service ready.

User(10.0.12.2:(none)):test

331 Password required for test.

Enter password:

230 User logged in.


[R1-ftp]

此时已经成功登陆到R2的文件系统。


步骤 6 对R2文件系统做相应的操作

# 设置传输模式

[R1-ftp]ascii

200 Type set to A.

设备支持的文件传输的数据类型包括ASCII和Binary模式。

ASCII用于传输纯文本文件,Binary用于传输系统软件、图形图像、声音影像、压缩文件、数据库等程序文件。由于我们需要下载的配置文件为纯文本文件,所以需要设置为ASCII模式。缺省情况下,文件传输方式为ASCII模式,此处的操作仅为示范。


# 下载配置文件

[R1-ftp]get test2.cfg

200 Port command okay.

150 Opening ASCII mode data connection for test2.cfg.

226 Transfer complete.

FTP: 961 byte(s) received in 0.220 second(s) 4.36Kbyte(s)/sec.


# 删除配置文件

[R1-ftp]delete test2.cfg

Warning: The contents of file test2.cfg cannot be recycled. Continue? (y/n)[n]:y

250 DELE command successful.


# 上传配置文件

[R1-ftp]put test1.cfg

200 Port command okay.

150 Opening ASCII mode data connection for test1.cfg.

226 Transfer complete.

FTP: 875 byte(s) sent in 0.240 second(s) 3.64Kbyte(s)/sec.


# 断开FTP连接

[R1-ftp]bye

221 Server closing.


五、结果验证

查看当前R1和R2的文件目录:

dir

Directory of flash:/


Idx Attr Size(Byte) Date Time(LMT) FileName

0 -rw- 126,538,240 Jul 04 2016 17:57:22 ar651c- v300r019c00Sspc100.cc

1 -rw- 23,963 Feb 21 2020 09:22:53 mon_file.txt

2 -rw- 721 Feb 21 2020 10:14:33 vrpcfg.zip

3 drw- - Jul 04 2016 18:51:04 CPM_ENCRYPTED_FOLDER

4 -rw- 783 Jul 10 2018 14:46:16 default_local.cer

5 -rw- 0 Sep 11 2017 00:00:54 brdxpon_snmp_cfg.efs

6 drw- - Sep 11 2017 00:01:22 update

7 drw- - Sep 11 2017 00:01:48 shelldir

8 drw- - Feb 20 2020 21:33:16 localuser

9 drw- - Sep 15 2017 04:35:52 dhcp

10 -rw- 1,586 Feb 21 2020 10:26:10 test2.cfg

11 -rw- 509 Feb 21 2020 10:18:31 private-data.txt

12 -rw- 2,686 Dec 19 2019 15:05:18 mon_lpu_file.txt

13 -rw- 3,072 Dec 18 2019 18:15:54 Boot_LogFile

14 -rw- 1,390 Feb 21 2020 10:18:30 test1.cfg


510,484 KB total available (386,444 KB free)


dir

Directory of flash:/


Idx Attr Size(Byte) Date Time(LMT) FileName

0 -rw- 126,538,240 Jul 04 2016 17:57:22 ar651c- v300r019c00Sspc100.cc

1 -rw- 11,405 Feb 21 2020 09:21:53 mon_file.txt

2 -rw- 809 Feb 21 2020 10:14:10 vrpcfg.zip

3 drw- - Jul 04 2016 18:51:04 CPM_ENCRYPTED_FOLDER

4 -rw- 782 Jul 10 2018 14:48:14 default_local.cer

5 -rw- 0 Oct 13 2017 15:36:32 brdxpon_snmp_cfg.efs

6 drw- - Oct 13 2017 15:37:00 update

7 drw- - Oct 13 2017 15:37:24 shelldir

8 drw- - Feb 20 2020 20:51:34 localuser

9 drw- - Oct 14 2017 11:27:04 dhcp

10 -rw- 1,390 Feb 21 2020 10:25:42 test1.cfg

11 -rw- 445 Feb 21 2020 10:16:52 private-data.txt

12 -rw- 4,096 Aug 06 2019 11:19:08 Boot_LogFile


510,484 KB total available (386,464 KB free)

六、配置参考

R1的配置

#

sysname R1

#

interface GigabitEthernet0/0/0

ip address 10.0.12.1 255.255.255.0

#

return

R2的配置

#

sysname R2

#

aaa

local-user test password irreversible-cipher %^%#'XqV;f=C;/1!\sQ6LA+Ow8GBO;W%0HBf0`>p(`[SpV]J%Amom!na3:4RvFv@%^%#

local-user test privilege level 15

local-user test ftp-directory flash:/

local-user test service-type ftp

#

interface GigabitEthernet0/0/0

ip address 10.0.12.2 255.255.255.0

#

ftp server enable

#

user-interface vty 0 4

authentication-mode aaa

user privilege level 15

#

return