实验5-1配置FTP业务配置FTP业务学习目标理解建立FTP连接的过程掌握FTP服务器参数的配置掌握与FTP服务器传输文件的场景您是公司的网络管理员,需要在公司网络上配置FTP业务。您需要把一台路由器配置为FTP服务器,客户端可以通过TCP连接与FTP服务器之间传输文件。操作步骤步骤一实验环境准备如果本任务中您使用的是空配置设备,那么请从步骤1开始配置。如果使用的设备包含上一个实验的配置,请直接从步骤2开始配置。Huaweisystem-viewEntersystemview,returnuserviewwithCtrl+Z.[Huawei]sysnameR1[R1]interfaceGigabitEthernet0/0/1[R1-GigabitEthernet0/0/1]ipaddress10.0.12.124Huaweisystem-viewEntersystemview,returnuserviewwithCtrl+Z.[Huawei]sysnameR2[R2]interfaceGigabitEthernet0/0/1[R2-GigabitEthernet0/0/1]ipaddress10.0.12.224测试R1和R2之间的连通性。[R1]ping10.0.12.2PING10.0.12.2:56databytes,pressCTRL_CtobreakReplyfrom10.0.12.2:bytes=56Sequence=1ttl=255time=10msReplyfrom10.0.12.2:bytes=56Sequence=2ttl=255time=1msReplyfrom10.0.12.2:bytes=56Sequence=3ttl=255time=1msReplyfrom10.0.12.2:bytes=56Sequence=4ttl=255time=10msReplyfrom10.0.12.2:bytes=56Sequence=5ttl=255time=1ms---10.0.12.2pingstatistics---5packet(s)transmitted5packet(s)received0.00%packetlossround-tripmin/avg/max=1/4/10ms步骤二在路由器上启用FTP业务。默认情况下,路由器的FTP功能并未启用。使用FTP业务之前,必须先启用FTP功能。配置R1为FTP服务器,R2为客户端。[R1]ftpserverenableInfo:SucceededinstartingtheFTPserver[R1]setdefaultftp-directoryflash:/通过在AAA中设置用户名和密码,授权FTP合法用户连接到FTP服务器。这样,非法用户就无法连接FTP服务器,降低了安全风险。[R1]aaa[R1-aaa]local-userhuaweipasswordcipherhuawei123Info:Addanewuser.[R1-aaa]local-userhuaweiservice-typeftpInfo:Thecipherpasswordhasbeenchangedtoanirreversible-cipherpassword.Warning:TheuseraccessmodesincludeTelnet,FTPorHTTP,andsosecurityrisksexist.Info:Afteryouchangetherights(includingthepassword,accesstype,FTPdirectory,andlevel)ofalocaluser,therightsofusersalreadyonlinedonotchange.Thechangetakeseffecttouserswhogoonlineafterthechange.[R1-aaa]local-userhuaweiprivilegelevel15Info:Afteryouchangetherights(includingthepassword,accesstype,FTPdirectory,andlevel)ofalocaluser,therightsofusersalreadyonlinedonotchange.Thechangetakeseffecttouserswhogoonlineafterthechange.[R1-aaa]local-userhuaweiftp-directoryflash:Info:Afteryouchangetherights(includingthepassword,accesstype,FTPdirectory,andlevel)ofalocaluser,therightsofusersalreadyonlinedonotchange.Thechangetakeseffecttouserswhogoonlineafterthechange.[R1]displayftp-serverFTPserverisrunningMaxusernumber5Usercount0Timeoutvalue(inminute)30Listeningport21Aclnumber0FTPserver'ssourceaddress0.0.0.0配置完成后,可以看到R1为FTP服务器,默认情况下监听TCP21号端口。步骤三建立FTP客户端与服务器的连接。建立从客户端(R2)到FTP服务器(R1)的连接。R2ftp10.0.12.1Trying10.0.12.1...PressCTRL+KtoabortConnectedto10.0.12.1.220FTPserviceready.User(10.0.12.1:(none)):huawei331Passwordrequiredforhuawei.Enterpassword:230Userloggedin.[R2-ftp]输入正确的用户名和密码后,可以成功登陆FTP服务器。下载文件前或者上传文件后,执行dir命令查看文件的详细信息。[R2-ftp]dir200Portcommandokay.150OpeningASCIImodedataconnectionfor*.drwxrwxrwx1noonenogroup0May0318:03.-rwxrwxrwx1noonenogroup114552448Jan192012AR2220E-V200R006C10SPC300.cc-rwxrwxrwx1noonenogroup159858May0317:59mon_file.txt-rwxrwxrwx1noonenogroup304700Mar0311:11sacrule.dat-rwxrwxrwx1noonenogroup783Mar0311:12default_local.cer-rwxrwxrwx1noonenogroup0Dec202015brdxpon_snmp_cfg.efs-rwxrwxrwx1noonenogroup777May0318:03vrpcfg.zipdrwxrwxrwx1noonenogroup0Mar1011:14updatedrwxrwxrwx1noonenogroup0May0318:03localuserdrwxrwxrwx1noonenogroup0Mar1710:45dhcp-rwxrwxrwx1noonenogroup460May0318:03private-data.txt-rwxrwxrwx1noonenogroup126352896Mar1011:09AR2220E-V200R007C00SPC600.ccdrwxrwxrwx1noonenogroup0Mar1011:15shelldir-rwxrwxrwx1noonenogroup11606May0318:00mon_lpu_file.txtdrwxrwxrwx1noonenogroup0Mar1814:45huawei-rwxrwxrwx1noonenogroup120Mar1815:02text.txt226Transfercomplete.FTP:1112byte(s)receivedin0.134second(s)8.29Kbyte(s)/sec.配置文件的传输模式。[R2-ftp]binary200TypesettoI.在FTP服务器上下载文件。[R2-ftp]getvrpcfg.zipvrpnew.zip200Portcommandokay.150OpeningBINARYmodedataconnectionforvrpcfg.zip.226Transfercomplete.FTP:120byte(s)receivedin0.678second(s)176.99byte(s)/sec.从FTP服务器上下载文件后,执行bye命令关闭连接。[R2-ftp]bye221Serverclosing.R2dirDirectoryofflash:/IdxAttrSize(Byte)DateTime(LMT)FileName0-rw-114,552,448Jan19201215:32:52AR2220E-V200R006C10SPC300.cc1-rw-270,176Apr30201603:17:08mon_file.txt2-rw-304,700Mar03201611:11:44sacrule.dat3-rw-783Mar03201611:12:22default_local.cer4-rw-0Dec20201500:06:14brdxpon_snmp_cfg.efs5-rw-775Apr29201617:51:48vrpcfg.zip6drw--Mar10201611:28:46update7drw--Apr23201617:33:38localuser8drw--Mar21201620:59:46dhcp9-rw-394Apr29201617:51:50private-data.txt10-rw-126,352,896Mar10201611:14:40AR2220E-V200R007C00SPC600.cc11drw--Mar10201611:29:20shelldir12-rw-23,950Apr27201616:06:06mon_lpu_file.txt13-rw-120Mar24201611:45:44huawei.zip14-rw-777May10201614:23:43vrpnew.zip可以通过put命令把一个文件上传到FTP服务器,上传的同时也可以为该文件配置新的文件名。R2-ftp]putvrpnew.zipvrpnew2.zip200Portcommandokay.150OpeningBINARYmodedataconnectionforvrpnew2.zip.226Transfercomplete.FTP:120byte(s)sentin0.443second(s)270.88byte(s)/sec.上传文件后,执行dir命令查看文件是否存在于FTP服务器上。R1dirDirectoryofflash:/IdxAttrSize(Byte)DateTime(LMT)FileName0-rw-286,620Mar14201609:22:20sacrule.dat1-rw-512,000Mar28201614:39:16mon_file.txt2-rw-1,738,816Mar17201612:05:36web.zip3-rw-48,128Mar10201614:16:56ar2220E_v200r001sph001.pat4-rw-120Mar28201610:09:50iascfg.zip5-rw-699Mar28201617:52:38vrpcfg.zip6-rw-93,871,87