The feature to download anything (mostly used to download IOS images) from remote HTTP server to the cisco router has
been with us for years, yet there are few caveats to be aware of before using it.
The command itself is pretty simple:
Router# copy http[:full URI specification] flash[: local path to save the file]
The facts you should know:
– router is first doing resolving of the domain name to the IP, then uses this IP as Host header in the communication with
the remote HTTP server. This is important when you try to download something from the webserver already configured
for the Virtual hosts. Because then webserver looks at this header and searches for the matching local file according to
its internal logic.
For example if using Apache configured for named Virtual hosting you should put the file to be downloaded in
the default Virtual host, i.e. first virtual host in the Apache configuration file. Let’s look at the example.
Here we have the partial Apache config file :
#The file we want to download is in /usr/local/apache2/htdocs/mrtg/test.bin
#Here comes the 1st VirtualHost entry
<VirtualHost *:80>
ServerAdmin admin@yurisk.net
DocumentRoot “/usr/local/apache2/htdocs/mrtg”
# as this this the 1st Virtual Host entry server names below are irrelevant for our case
ServerName mrtg.yurisk.info
ServerAlias mrtg. yurisk.net
ErrorLog “logs/mrtg.yurisk.info-error_log”
CustomLog “logs/mrtg.yurisk.info-custom_log” common
<Directory />
Options FollowSymLinks
AllowOverride None
#Here I set up a basic authentication with local user/pass file, you may omit this
AuthType Basic
AuthName “By My Invitation only :)”
AuthUserFile /usr/local/apache2/passwords
Require valid-user
Options None
#Uncomment below if not using the authentication
# Order allow,deny
# Allow from any
</Directory>
<VirtualHost *:80>
——-Cut here – many more virtual hosts ——
– while using TCP with built-in packet verification generally prevents damaged downloads , it is always a good idea to verify with md5
sum the downloaded file. The command:
#verify /md5 flash:<downloaded file name>
– This command also supports copying from HTTPs, but it would add unwanted SSL encrypt/decrypt overload
so I haven’t tested it , yet.
Now the real life example:
Tair#copy http://qwerty:12345@214.90.51.41/test.bin flash
Destination filename [test.bin]?
Loading http:// qwerty:12345@ 214.90.51.41/test.bin
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5120000 bytes copied in 17.924 secs (285651 bytes/sec)
Tair # verify /md5 flash:test.bin
…………………………………………………………………………………………………………………………………………………………………….
……………………………………………………………………………………………………………………………………………………………………..
……………………………………………………………………………………………………………………………………………………………………..
……………………………………………………………………………………………………………………………………………………………………..
……………………………………………………………………………………………………………………………………………………………………..
………………………………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………..Done!
verify /md5 (flash:test.bin) = e8c39d44aafc82b035dfc7ad16fc2183