Friday, June 2, 2017

Cisco Router FTP Command

I had a Linux server that's only routed to a remote Cisco router (R2). So I FTP first a small test file (this could be an IOS or a license file) from an FTP server going to the Linux server, then copy the same file using the copy ftp command on the Cisco router.


linux$ ftp 192.168.25.254      //  FTP TO  3CDAEMON
Connected to 192.168.25.254 (192.168.25.254).
220 3Com 3CDaemon FTP Server Version 2.0
Name (192.168.25.254:john): anonymous       // anonymous/anonymous IS THE DEFAULT USER/PASSWORD IN 3CDAEMON
331 User name ok, need password
Password: anonymous
230 User logged in
Remote system type is UNIX.
Using binary mode to transfer files.

ftp> ls         // POINT TO THE CORRECT DIRECTORY/FILES IN 3CDAMEON
227 Entering passive mode (192,168,25,254,199,61)
125 Using existing data connection
drwxrwxrwx 1 owner group         0 Nov 12 16:32 .
drwxrwxrwx 1 owner group         0 Nov 12 16:32 ..
-rwxrwxrwx 1 owner group   2936005 Nov 12 16:32 apps42.8-5-4TH1-6.sbn
-rwxrwxrwx 1 owner group  25629676 May 09 13:24 asdm-752-153.bin
-rwxrwxrwx 1 owner group   8212480 May 20 13:33 c1520-k9w8-tar.152-2.JB.tar
-rwxrwxrwx 1 owner group    524894 Nov 12 16:32 cnu42.8-5-4TH1-6.sbn
-rwxrwxrwx 1 owner group   2102234 Nov 12 16:32 cvm42sccp.8-5-4TH1-6.sbn
-rwxrwxrwx 1 owner group    342219 Nov 12 16:32 dsp42.8-5-4TH1-6.sbn
-rwxrwxrwx 1 owner group  16751957 Feb 21 16:56 evo_x7_rmt-15.0.2.1.pkg
-rwxrwxrwx 1 owner group   1756328 Nov 12 16:32 jar42sccp.8-5-4TH1-6.sbn
-rwxrwxrwx 1 owner group       670 Nov 12 16:32 SCCP42.8-5-4S.loads
-rwxrwxrwx 1 owner group       674 Nov 12 16:32 term42.default.loads
-rwxrwxrwx 1 owner group       674 Nov 12 16:32 term62.default.loads
-rwxrwxrwx 1 owner group      8393 Nov 12 16:32 XMLDefault.cnf.xml
226 Closing data connection

ftp> help
Commands may be abbreviated.  Commands are:

!               debug           mdir            sendport        site
$               dir             mget            put             size
account         disconnect      mkdir           pwd             status
append          exit            mls             quit            struct
ascii           form            mode            quote           system
bell            get             modtime         recv            sunique
binary          glob            mput            reget           tenex
bye             hash            newer           rstatus         tick
case            help            nmap            rhelp           trace
cd              idle            nlist           rename          type
cdup            image           ntrans          reset           user
chmod           lcd             open            restart         umask
close           ls              prompt          rmdir           verbose
cr              macdef          passive         runique         ?
delete          mdelete         proxy           send

ftp> get SCCP42.8-5-4S.loads
local: SCCP42.8-5-4S.loads remote: SCCP42.8-5-4S.loads
227 Entering passive mode (192,168,25,254,199,62)
125 Using existing data connection
226 Closing data connection; File transfer successful.
670 bytes received in 0.00894 secs (74.94 Kbytes/sec)

ftp> quit
linux$ ls
SCCP42.8-5-4S.loads


R2#dir
Directory of flash0:/

    1  -rw-    99139212  May 17 2014 04:14:50 +00:00  c2900-universalk9-mz.SPA.152-4.M6.bin
    2  -rw-        3064  May 17 2014 04:26:12 +00:00  cpconfig-29xx.cfg
    3  -rw-        2211  Jun 27 2014 08:50:34 +00:00  credential.lic
    4  drw-           0  May 17 2014 04:26:40 +00:00  ccpexp
  245  -rw-        2464  May 17 2014 04:28:26 +00:00  home.shtml
  246  -rw-    13348488  Sep 26 2014 06:01:38 +00:00  pcm.datX-0_1_1-05_57_26_Sep_26_14.dat

261201920 bytes total (146247680 bytes free)


R2#copy ftp://john:password@13.123.7.2/SCCP42.8-5-4S.loads flash    // USE LINUX USERNAME AND PASSWORD
Destination filename [SCCP42.8-5-4S.loads]?
Accessing ftp://*****:*****@13.123.7.2/SCCP42.8-5-4S.loads...
Loading SCCP42.8-5-4S.loads !
[OK - 670/4096 bytes]

670 bytes copied in 4.368 secs (153 bytes/sec)

R2#dir
Directory of flash0:/

    1  -rw-    99139212  May 17 2014 04:14:50 +00:00  c2900-universalk9-mz.SPA.152-4.M6.bin
    2  -rw-        3064  May 17 2014 04:26:12 +00:00  cpconfig-29xx.cfg
    3  -rw-        2211  Jun 27 2014 08:50:34 +00:00  credential.lic
    4  drw-           0  May 17 2014 04:26:40 +00:00  ccpexp
  245  -rw-        2464  May 17 2014 04:28:26 +00:00  home.shtml
  246  -rw-    13348488  Sep 26 2014 06:01:38 +00:00  pcm.datX-0_1_1-05_57_26_Sep_26_14.dat
  247  -rw-         670   Apr 7 2017 00:56:22 +00:00  SCCP42.8-5-4S.loads

261201920 bytes total (146243584 bytes free)


You can remove the file on the Linux server using the rm command to free up space.

linux$ rm SCCP42.8-5-4S.loads
linux$ ls

<EMPTY>


I also had a Linux server which has FTP passive mode off or disabled and only SCP only works.


ciscoasa# ping tcp 10.1.1.4 21     // FTP TCP PORT 21

Type escape sequence to abort.

No source specified. Pinging from identity interface.

Sending 5 TCP SYN requests to 10.1.1.4 port 21

from 10.23.24.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 25/26/30 ms

ciscoasa# copy ftp://john:PW@10.1.1.4/asa917-20-smp-k8.bin disk0:

Address or name of remote host [10.1.1.4]?

Source username [john]?

Source password [PW]?

Source filename [asa917-20-smp-k8.bin]?

Destination filename [asa917-20-smp-k8.bin]?

Accessing ftp://johnl:PW@10.1.1.4/asa917-20-smp-k8.bin...
%Error reading ftp://johnl:PW@10.1.1.4/asa917-20-smp-k8.bin (No more processes)

linux2$ ftp
ftp> passive
Passive mode off.
 

ftp> ls
227 Entering Passive Mode (10,1,1,4,43,154).
150 Here comes the directory listing.
-rw-------    1 558      558      38338560 Mar 25 03:24 asa917-20-smp-k8.bin



linux2$ scp asa917-20-smp-k8.bin john@10.23.2.1:disk0:/asa917-20-smp-k8.bin
johnl@
10.23.24.2's password: <ASA PW>
asa917-20-smp-k8.bin          5% 2176KB  37.6KB/s   15:39 ETA

asa917-20-smp-k8.bin          100%   37MB  37.7KB/s   16:33


If the FTP or TFTP server is reachable via a VRF, you'll need to configure the ip <ftp or tftp> source-interface command then use the copy ftp://<USERNAME>:<PASSWORD>@<FTP IP ADDRESS>:<VRF NAME>/<IOS.bin> flash command.
 

Router(config)#ip ftp source-interface ?
  Async                    Async interface
  Auto-Template            Auto-Template interface
  BVI                      Bridge-Group Virtual Interface
  CDMA-Ix                  CDMA Ix interface
  CTunnel                  CTunnel interface
  Dialer                   Dialer interface
  Embedded-Service-Engine  cisco embedded service engine module
  GigabitEthernet          GigabitEthernet IEEE 802.3z
  LISP                     Locator/ID Separation Protocol Virtual Interface
  Lex                      Lex interface
  LongReachEthernet        Long-Reach Ethernet interface
  Loopback                 Loopback interface
  MFR                      Multilink Frame Relay bundle interface
  Multilink                Multilink-group interface
  Null                     Null interface
  Port-channel             Ethernet Channel of interfaces
  Tunnel                   Tunnel interface
  Vif                      PGM Multicast Host interface
  Virtual-PPP              Virtual PPP interface
  Virtual-Template         Virtual Template interface
  Virtual-TokenRing        Virtual TokenRing
  vmi                      Virtual Multipoint Interface

Router(config)#ip tftp source-interface ?
  Async                    Async interface
  Auto-Template            Auto-Template interface
  BVI                      Bridge-Group Virtual Interface
  CDMA-Ix                  CDMA Ix interface
  CTunnel                  CTunnel interface
  Dialer                   Dialer interface
  Embedded-Service-Engine  cisco embedded service engine module
  GigabitEthernet          GigabitEthernet IEEE 802.3z
  LISP                     Locator/ID Separation Protocol Virtual Interface
  Lex                      Lex interface
  LongReachEthernet        Long-Reach Ethernet interface
  Loopback                 Loopback interface
  MFR                      Multilink Frame Relay bundle interface
  Multilink                Multilink-group interface
  Null                     Null interface
  Port-channel             Ethernet Channel of interfaces
  Tunnel                   Tunnel interface
  Vif                      PGM Multicast Host interface
  Virtual-PPP              Virtual PPP interface
  Virtual-Template         Virtual Template interface
  Virtual-TokenRing        Virtual TokenRing
  vmi                      Virtual Multipoint Interface


Router#copy ftp://ftpuser:ftp123@172.27.5.4:Mgmt-intf/c2900-universalk9-mz.SPA.151-4.M6.bin flash
Destination filename [c2900-universalk9-mz.SPA.151-4.M6.bin]?
Accessing ftp://*****:*****@172.27.5.4:Mgmt-/c2900-universalk9-mz.SPA.151-4.M6.bin...
Loading c2900-universalk9-mz.SPA.151-4.M6.bin !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[OK - 74581380/4096 bytes]

74581380 bytes copied in 1633.988 secs (45644 bytes/sec)


No comments:

Post a Comment