Sunday, February 17, 2013

Copying Multiple Config Files onto a Router

Topology

clip_image001

I have several config files (about 30) for each of 6 devices – that’s 180 configs files that I don’t want to manually move over. Not only would it be exhausting and error prone, I know it would take some time to do. I want to move these to the devices so I can quickly move through some TShoot labs without having to tftp each config file for each lab individually. Doing the later would also require each device to have connectivity to the tftp server at all times – it’s just not functional. So, instead, I’d rather have all the config files for each lab already installed in flash so I can quickly “configure replace” as I move through each lab.

Now, is there an easy way to move several config files over all at once? Yes - .tar!

The config files (.txt) for each device are in relative folders, i.e. folder R1 has all the files for that device, folder R2 has all the files for R2, etc. The trick to moving all these files over at the same time is to convert each folder into a .tar file extension. There are two common types of IOS files you’ll see from Cisco: .bin and .tar. From Cisco’s site (1):

  • The .bin file is the Cisco IOS® Software image. If you only want to use the CLI to manage the switch, the .bin file is the only file to download.
  • The .tar file is an archive file. The upgrade process extracts both the Cisco IOS image and the CMS files from the .tar file. If you want to manage switches or clusters of switches through a web interface, such as HTML, this file is the only file to download.

I guess you could say .tar is like a compressed (.zip) folder containing several files. For the IOS Software image, the .tar file contains the .bin file along with other files (html) as noted above.

To convert a MS Windows folder into a .tar extension type, you will need a converter like 7-Zip which is what I’m going to use. I’m not adding the link for that because:

  1. I can’t vouch for the software – I never install software on my computer unless I know, without a doubt, the software is safe, bloat free and is something I absolutely need. Even then I’m paranoid (and don’t want extra services running on my main machine) so I usually install software onto a virtual machine… which is where this went – the TFTP VM Server (note: you can use an XP VM (virtual machine); I’m using WinServer08 but the OS doesn’t matter).
  2. I’m sure there are other programs out there that can convert folders into .tar so pick the one you feel comfortable with and use your best discretion

The conversion is very straightforward. For 7-Zip I right-clicked on the folder I wanted to convert > 7-Zip > Add to archive. From there I just changed the Archive format type to tar and clicked ok. That was easy!

Since this is a .tar file you will want to use the archive attribute. When I first tried this I downloaded the .tar file to the router (c3725) and then tried to extract it:

R1#copy tftp://10.10.10.2/R1.tar flash:

R1#show flash
System CompactFlash directory:
File Length Name/status
1 119296 R1.tar
[119360 bytes used, 16657852 available, 16777212 total]
16384K bytes of ATA System CompactFlash (Read/Write)

R1#archive tar /xtract R1.tar flash:
R1/ (directory) 0 (bytes) -- unable to create (Invalid argument)
extracting R1/Lab101-R1-TT-A-Cfg.txt (2687 bytes)
%Error opening flash:/R1/Lab101-R1-TT-A-Cfg.txt (Device in exclusive use)

R1#

“Device in exclusive use”. Hmm. Okay; from some help on Cisco’s forums the conclusion is that GNS3 cannot read and write to flash at the same time. So I deleted the R1.tar file from the router and started over; but this time I tried extracting the file during the tftp transfer process:

R1#archive tar /xtract tftp://10.10.10.2/R1.tar flash:
Loading R1.tar from 10.10.10.2 (via FastEthernet0/0): !
R1/ (directory) 0 (bytes) -- unable to create (Invalid argument)
extracting R1/Lab10-R1-TT-A-Cfg.txt (2687 bytes)
extracting R1/Lab10-R1-TT-B-Cfg.txt (2648 bytes)
extracting R1/Lab10-R1-TT-C-Cfg.txt (2687 bytes)
… //output omitted
extracting R1/Lab93-R1-TT-A-Cfg.txt (2919 bytes)
extracting R1/Lab93-R1-TT-B-Cfg.txt (3120 bytes)
[OK - 119296 bytes]

R1#

And now I have all the configs for each lab (& trouble tickets). I just need to repeat this for the other devices and and I’m ready to rock out the labs!

Some things to watch out for:

  • Make sure you have enough space in flash to unpack the .tar file.
  • If you get an error like:

R1#archive tar /xtract tftp://10.10.10.2/R1.tar flash:
Loading R1.tar from 10.10.10.2 (via FastEthernet0/0): !
R1/ (directory) 0 (bytes) -- unable to create (Invalid argument)
extracting R1/Lab101-R1-TT-A-Cfg.txt (2687 bytes)
%Error opening flash:/R1/Lab101-R1-TT-A-Cfg.txt (File name too long)

R1#

The error being “File name too long”, go back into the original folder and delete some characters in regards to that named file; in this case it’s “Lab101-R1-TT-A-Cfg.txt”. This happened to me and I’m not sure if it’s because the file name really is too long or that it’s 1 character longer from the other 26 files. I deleted one character, repacked the folder to a .tar file and it worked. Cheers!

1) http://www.cisco.com/en/US/products/hw/switches/ps646/products_configuration_example09186a0080169623.shtml#concept1

1 comment:

  1. I would recommend you to try Long Path Tool program to fix this problem

    ReplyDelete