ensp FTP业务的配置

  • Post author:
  • Post category:其他




实验: 配置FTP业务

(提醒:做的时候看清楚语句前面是R1还是R2!!!)

(斜体段落表示你输入上方的语句,然后获得的反馈)

配置FTP业务实验拓扑图(如下)

在这里插入图片描述

步骤一 实验环境准备

<

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.0.12.1 24

<

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.0.12.2 24

测试R1和R2之间的连通性。


[R1]ping 10.0.12.2



PING 10.0.12.2: 56 data bytes, press CTRL_C to break

Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=10 ms

Reply from 10.0.12.2: bytes=56 Sequence=2 ttl=255 time=1 ms

Reply from 10.0.12.2: bytes=56 Sequence=3 ttl=255 time=1 ms

Reply from 10.0.12.2: bytes=56 Sequence=4 ttl=255 time=10 ms

Reply from 10.0.12.2: bytes=56 Sequence=5 ttl=255 time=1 ms

— 10.0.12.2 ping statistics —

5 packet(s) transmitted

5 packet(s) received

0.00% packet loss

round-trip min/avg/max = 1/4/10 ms

步骤二 在路由器上启用FTP业务。

默认情况下,路由器的FTP功能并未启用。使用FTP业务之前,必须先启用FTP功能。配置R1为FTP服务器,R2为客户端。


[R1]ftp server enable



Info: Succeeded in starting the FTP server



[R1]set default ftp-directory flash:/

通过在AAA中设置用户名和密码,授权FTP合法用户连接到FTP服务器。这样,非法用户就无法连接FTP服务器,降低了安全风险。


[R1]aaa

[R1-aaa]local-user huawei password cipher huawei123

(其中用户名:huawei 密码:huawei123 可以自己创建一个,但是别忘记!!!)


Info: Add a new user.



[R1-aaa]local-user huawei service-type ftp



Info: The cipher password has been changed to an irreversible-cipher password.

Warning: The user access modes include Telnet, FTP or HTTP, and so security risks exist.

Info: After you change the rights (including the password, access type, FTP directory, and level) of a local user, the rights of users already online do not change. The change takes effect to users who go online after the change.



[R1-aaa]local-user huawei privilege level 15



Info: After you change the rights (including the password, access type, FTP directory, and level) of a local user, the rights of users already online do not change. The change takes effect to users who go online after the change.



[R1-aaa]local-user huawei ftp-directory flash:



Info: After you change the rights (including the password, access type, FTP directory, and level) of a local user, the rights of users already online do not change. The change takes effect to users who go online after the change.


[R1]display ftp-server



FTP server is running

Max user number 5

User count 0

Timeout value(in minute) 30

Listening port 21

Acl number 0

FTP server’s source address 0.0.0.0


配置完成后,可以看到R1为FTP服务器,默认情况下监听TCP 21号端口。

步骤三 建立FTP客户端与服务器的连接。

建立从客户端(

R2

)到FTP服务器(R1)的连接。


<

R2

>ftp 10.0.12.1



Trying 10.0.12.1 …

Press CTRL+K to abort

Connected to 10.0.12.1.

220 FTP service ready.



User(10.0.12.1:(none)):huawei(

输入之前创建的用户名





331 Password required for huawei.



Enter password:(

输入之前创建的密码





230 User logged in.



[R2-ftp](这样表示成功登陆FTP服务器)


下载文件前或者上传文件后,执行 dir 命令查看文件的详细信息。



[R2-ftp]dir


*200 Port command okay.

150 Opening ASCII mode data connection for

.

drwxrwxrwx 1 noone nogroup 0 May 03 18:03 .

-rwxrwxrwx 1 noone nogroup 114552448 Jan 19 2012 AR2220E-V200R006C10SPC300.cc

-rwxrwxrwx 1 noone nogroup 159858 May 03 17:59 mon_file.txt

-rwxrwxrwx 1 noone nogroup 304700 Mar 03 11:11 sacrule.dat

-rwxrwxrwx 1 noone nogroup 783 Mar 03 11:12 default_local.cer

-rwxrwxrwx 1 noone nogroup 0 Dec 20 2015 brdxpon_snmp_cfg.efs

-rwxrwxrwx 1 noone nogroup 777 May 03 18:03 vrpcfg.zip

drwxrwxrwx 1 noone nogroup 0 Mar 10 11:14 update

drwxrwxrwx 1 noone nogroup 0 May 03 18:03 localuser

drwxrwxrwx 1 noone nogroup 0 Mar 17 10:45 dhcp

-rwxrwxrwx 1 noone nogroup 460 May 03 18:03 private-data.txt

-rwxrwxrwx 1 noone nogroup 126352896 Mar 10 11:09 AR2220E-V200R007C00SPC600.cc

drwxrwxrwx 1 noone nogroup 0 Mar 10 11:15 shelldir

-rwxrwxrwx 1 noone nogroup 11606 May 03 18:00 mon_lpu_file.txt

drwxrwxrwx 1 noone nogroup 0 Mar 18 14:45 huawei

-rwxrwxrwx 1 noone nogroup 120 Mar 18 15:02 text.txt

226 Transfer complete.

配置文件的传输模式。


[R2-ftp]binary



200 Type set to I.

在FTP服务器上下载文件。


[R2-ftp]get vrpcfg.zip vrpnew.zip



200 Port command okay.

150 Opening BINARY mode data connection for vrpcfg.zip.

226 Transfer complete.

从FTP服务器上下载文件后,执行bye命令关闭连接。


[R2-ftp]bye



221 Server closing.


<

R2

>dir



Directory of flash:/

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

0 -rw- 114,552,448 Jan 19 2012 15:32:52 AR2220E-V200R006C10SPC300.cc

1 -rw- 270,176 Apr 30 2016 03:17:08 mon_file.txt

2 -rw- 304,700 Mar 03 2016 11:11:44 sacrule.dat

3 -rw- 783 Mar 03 2016 11:12:22 default_local.cer

4 -rw- 0 Dec 20 2015 00:06:14 brdxpon_snmp_cfg.efs

5 -rw- 775 Apr 29 2016 17:51:48 vrpcfg.zip

6 drw- – Mar 10 2016 11:28:46 update

7 drw- – Apr 23 2016 17:33:38 localuser

8 drw- – Mar 21 2016 20:59:46 dhcp

9 -rw- 394 Apr 29 2016 17:51:50 private-data.txt

10 -rw- 126,352,896 Mar 10 2016 11:14:40 AR2220E-V200R007C00SPC600.cc

11 drw- – Mar 10 2016 11:29:20 shelldir

12 -rw- 23,950 Apr 27 2016 16:06:06 mon_lpu_file.txt

13 -rw- 120 Mar 24 2016 11:45:44 huawei.zip

14 -rw- 777 May 10 2016 14:23:43 vrpnew.zip

可以通过put命令把一个文件上传到FTP服务器,上传的同时也可以为该文件配置新的文件名。


[R2-ftp]put vrpnew.zip vrpnew2.zip

(第一个是源文件名,第二个是新文件名!!!)


200 Port command okay.

150 Opening BINARY mode data connection for vrpnew2.zip.

226 Transfer complete.

上传文件后,执行dir命令查看文件是否存在于FTP服务器上。


<

R1

>dir



Directory of flash:/

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

0 -rw- 286,620 Mar 14 2016 09:22:20 sacrule.dat

1 -rw- 512,000 Mar 28 2016 14:39:16 mon_file.txt

2 -rw- 1,738,816 Mar 17 2016 12:05:36 web.zip

3 -rw- 48,128 Mar 10 2016 14:16:56 ar2220E_v200r001sph001.pat

4 -rw- 120 Mar 28 2016 10:09:50 iascfg.zip

5 -rw- 699 Mar 28 2016 17:52:38 vrpcfg.zip

6 -rw- 93,871,872 Mar 14 2016 09:13:26 ar2220E-V200R007C00SPC600.cc

7 -rw- 512,000 Mar 28 2016 14:40:20 mon_lpu_file.txt

8 -rw- 699 Mar 02 2016 15:44:16 vrpnew2.zip

分别在R1和R2上

删除

创建的vrpnew.zip和vrpnew2.zip文件。


<

R1

>delete flash:/vrpnew2.zip


*Delete flash:/vrpnew2.zip? (y/n)[n]:*

y



Info: Deleting file flash:/vrpnew2.zip…succeed.


<

R2

>delete flash:/vrpnew.zip


*Delete flash:/vrpnew.zip? (y/n)[n]:*

y



Info: Deleting file flash:/vrpnew.zip…succeed.


注意:删除配置文件时,请慎重执行,避免删除R1和R2上的整个flash:/目录。

配置文件



版权声明:本文为weixin_47498728原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。