8

I want to make a script to copy the running config of a switch 4506 in one line. So far, I see two option :

copy run tftp:

sw#copy run tftp://10.0.0.1/cfg.cfg
Address or name of remote host [10.0.0.1]? 
Destination filename [cfg.cfg]? 

Cons: need confirmation, press enter.

Info : I have define the ip tftp source-interface Vlan10 with management vlan to have connectivity.

or

show running-config | redirect tftp://10.0.0.1/run-R1.cfg

sw#show running-config | redirect tftp://10.0.0.1/run-R1.cfg
.....
%Error opening tftp://10.0.0.1/run-R1.cfg (Timed out)
sw#sh ip route 10.0.0.1 
% Subnet not in table

Cons: the ip source of the redirect is an private IP 172.16.0.2 due this is a transit subnet. So no connectivity with the outgoing interface IP but connectivity with the managment subnet. as you can see below.

sw#ping 10.0.0.1 source vlan 10    
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.1, timeout is 2 seconds:
Packet sent with a source address of 172.16.0.2 
.....
Success rate is 0 percent (0/5)
sw#ping 10.0.0.1 source vlan 11
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.1, timeout is 2 seconds:
Packet sent with a source address of <Public_IP> 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/6/8 ms
sw#

ip tftp source-interface Vlan10 does not help with redirect

Questions :
- Is there the possibility of no confirmation copy with 'copy run tftp:' ?
- How can I define for all packet sourced on switch should be sourced with a defined IP ?

7
  • 1
    Where does the requirement come from that it has to be single line. There might exist option to remedy that problem.
    – ytti
    Sep 21, 2013 at 11:39
  • We have a provisioning system, we can enter commands on a webgui to execute on devices. We would like to perform backup before or after provisioning ports.This is actually for 4506, updated. I've already thought about the 'archive' IOS capability but we want to control this.
    – cgasp
    Sep 21, 2013 at 11:46
  • Is it in-house system? Or some known system? It might be possible to punch in \n or \r\n in place of 'enter'.
    – ytti
    Sep 21, 2013 at 12:03
  • 1
    @cdq74cn, configure with ip tftp source-interface Vlan10 to source your tftp correctly... then show running-config | redirect tftp://10.0.0.1/run-R1.cfg should work Sep 21, 2013 at 12:08
  • @MikePennington, already configured and didn't work, as described.
    – cgasp
    Sep 21, 2013 at 12:17

5 Answers 5

18

Try turning file prompt behavior to quiet.

6506(config)#file prompt quiet
6506(config)#end
6506#copy run tftp://192.168.1.1/file.txt
.....
1
  • That's a hidden hack command ! Many thanks. Problem Solved
    – cgasp
    Sep 24, 2013 at 19:53
3

The copy command (at least with Cisco boxes) allows you to specify the username and password all in one line. Something like this:

copy running-config ftp://put_user_name_here:put_password_here@put_machie_name_or_ip_here//home/users/some_location/ut-running-config.txt

You should be able to use scp or tftp in place of ftp as well.

1
  • Well but I think I will face the same issue on connectivity.
    – cgasp
    Sep 23, 2013 at 3:50
2

You can do this with FTP.

First you need to setup the FTP username and password:

ip ftp username xxx
ip ftp password xxx

Then get your script to do this:

show run | redirect ftp://1.1.1.1

IOS will then use the local username and password set up before

2
  • Well but I think I will face the same issue on connectivity
    – cgasp
    Sep 23, 2013 at 3:51
  • 1
    ip ftp source-interface vlan 11 will fix that. That config stays in the running config
    – mellowd
    Sep 23, 2013 at 15:52
0

It might be easier to enable SCP server on the router and script the backup from the other side. Instead of trying to push it it from the router, why not pull it from the backup server? You will have greater scripting flexibility this way.

1
  • I've already thought in this alternative but we have a provisioning system, we can enter commands on a webgui to execute on devices. We would like to perform backup before or after provisioning ports.
    – cgasp
    Sep 21, 2013 at 11:48
0

You might also consider creating an alias with this command:

alias exec .save copy run tftp://192.168.1.1/file.txt

and issue .save instead of typing the entire line every time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.