A quick reference guide to commanding a cisco switch or router to write out it's config using only snmp.

Note that cat-os devices have only the running config (all changes are stored to flash within about 3-5s) so there is no equiv for wr mem on a cat-os device.


Rather than type this up here, I'll just refer you to the Cisco page on the subject:

Cat OS

First, you'll proabably want a copy of the

Second, I am assuming here that you're using the net-snmp package, available from sourceforge.

What Symbolic OID Command Line
Set the target tftp servertftpHost . snmpset -IR SWITCH WRCOMM tftpHost.0 s targetserver
Set the target filenametftpFile . snmpset -IR SWITCH WRCOMM tftpFile.0 s filename
Tell the switch which line card's config to upload (in this case, slot 1) tftpModule. snmpset -IR SWITCH WRCOMM tftpModule.0 i 1
Instruct the switch to begin uploading the config
Options: 2 -> d/l config
3-> upload config
4-> download os sw
5->upload os sw
6-> download firmware
7-> upload firmware
tftpAction. snmpset -IR SWITCH WRCOMM tftpAction.0 i 3
Wait for a result code tftpResult. snmpget -IR SWITCH WRCOMM tftpResult.0

tftpResult codes can be:

  1. inProgress
  2. success
  3. noResponse
  4. tooManyRetries
  5. noBuffers
  6. noProcesses
  7. badChecksum
  8. badLength
  9. badFlash
  10. serverError
  11. userCanceled
  12. wrongCode
  13. fileNotFound
  14. invalidTftpHost
  15. invalidTftpModule

Commanding an IOS based device to write it's config to to flash

The CcCopyEntry table (which all these variables are children of) is a sparse table. You need to first come up with a random number to identify this transaction, and then use it for all the following commands. When you turn "ccCopyEntryRowStatus" to active (1), that entry in the table becomes read-only until it completes.

If you want to do this symbolically, you'll need the CISCO-CONFIG-COPY mib.

For the purposes of this demonstration, we'll use entry # 26.
What Symbolic OID Command Line
Set the source to be the running-config ccCopySourceFileType. snmpset -IR iosdevice wrcomm ccCopySourceFileType.26 i 4
Set the dest to be the startup-config ccCopyDestFileType. snmpset -IR iosdevice wrcomm ccCopySourceFileType.26 i 3
Start the transfer (set this variable to 1, aka "active") ccCopyEntryRowStatus. snmpset -IR iosdevice wrcomm ccCopyEntryRowStatus.26 i 1
Check the status of the transfer ccCopyState. snmpget -IR iosdevice wrcomm ccCopyState.26
The possible values for ccCopySourceFileType and ccCopyDestFileType:

  1. networkFile (file on another network device)
  2. iosFile (a file on flash)
  3. startupConfig
  4. runningConfig
  5. terminal (put the file onto the console window. Interesting uses?)
The possible values for ccCopyState are:
  1. waiting
  2. running
  3. successful (done, entry no longer write protected)
  4. failed (done, entry no longer write protected)
Interested in why it failed? Check ConfigCopyFailCause (
  1. unknown (actual quote from mib: "very descriptive")
  2. badFileName (check perms/file name/etc)
  3. timeout
  4. noMem
  5. noConfig ("the agent-config selected as the source was non-existant")