Send Cisco commands via SNMP

In the article “How to save configurations using SNMP“, I have explained how to get the Cisco configuration using SNMP. Now, I explain how to send commands via SNMP using the “ciscoConfigCopyMIB” MIB;  with this MIB, you can replace running/startup configuration, send commands, save the “show” output or reload the device.

OK, let’s start :)

First of all, check if your PC/Server has the SNMP suite; if not, install the net-snmp software (

Then open a terminal on your pc and use these commands:

snmpset -c [snmp-community-string] -v 2c [ip-device][Random number] i 1
snmpset -c [snmp-community-string] -v 2c [ip-device][Random number] i 1
snmpset -c [snmp-community-string] -v 2c [ip-device][Random number] i 4
snmpset -c [snmp-community-string] -v 2c [ip-device][Random number] a [ip-tftp-server]
snmpset -c [snmp-community-string] -v 2c [ip-device][Random number] s [file-name]
snmpset -c [snmp-community-string] -v 2c [ip-device][Random number] i 1


  • snmp-community-string is the community key of your Cisco device; remember that the community must have write rights.
  • ip-device is the ip address of your Cisco device.
  • ip-tftp-server is the ip address of your tftp server.
  • file-name is the file that contains the commands to be executed to your Cisco device.

But what is the meaning of the last part of each command? See you below an explanation: i 1

ccCopyProtocol: The protocol file transfer protocol that should be used to copy the configuration file over the network. If the config file transfer is to occur locally on the SNMP agent, the method of transfer is left up to the implementation, and is not restricted to the protocols below. The object can be (in this case I choise the tftp):

  • tftp
  • ftp
  • rcp
  • scp
  • sftp i 1

ccCopySourceFileType: Specifies the type of file to copy from. The object can be:

  • networkFile
  • iosFile
  • startupConfig
  • runningConfig
  • terminal
  • fabricStartupConfig i 4

ccCopyDestFileType: specifies the type of file to copy to. The object can be:

  • networkFile
  • iosFile
  • startupConfig
  • runningConfig
  • terminal
  • fabricStartupConfig a

ccCopyServerAddress: The IP address of the TFTP server to copy the configuration file. In this case the tftp server is


snmpset -c c1sc0zine -v 2c s ciscozine.txt

ccCopyFileName: The file name (including the path, if applicable) of the file. i 1

ccCopyEntryRowStatus: The status of this table entry. Once the entry status is set to active, the associated entry cannot be modified until the request completes (ccCopyState transitions to ‘successful’ or ‘failed’ state). The object can be:

  • active
  • notInService
  • notReady
  • createAndGo
  • createAndWait
  • destroy


Remember: The command syntax are the same on linux or windows PCs.


Suppose that you want overwrite the running configuration from a configuration saved in a text file (like a “copy tftp: running-config”).

The client sends the “snmp set” commands to the router, then the router overwrites the running configuration with the “ciscozine.txt”, downloaded from the tftp server.

The first five commands define the the SNMP characteristics:


snmpset -c c1sc0zine -v 2c i 1
snmpset -c c1sc0zine -v 2c i 1
snmpset -c c1sc0zine -v 2c i 4
snmpset -c c1sc0zine -v 2c a
snmpset -c c1sc0zine -v 2c s ciscozine.txt

The last command submit the snmpset commands:


snmpset -c c1sc0zine -v 2c i 1

After the last command, the router displays this message:

%SYS-5-CONFIG_I: Configured from tftp:// by console

Remember: the “ciscozine.txt” can contain a startup-configuration or a single command; in fact, if you would ONLY create a loopback interface, create a ciscozine.txt file like that:

conf t
  interface loopback1
  ip address 2552.55.255.255

After the snmpset commands, the device will create the loopback1 interface!

Another good tip, it is to use the snmpset commands to save some show output. How? Suppose you want to save the “show interfaces” into the “show.txt” file via tftp;  create a “ciscozine.txt” like that and execute the snmpset:

conf t
 do show interf | redirect tftp://

And.. Is it possible reload a device using SNMP? Sure! First of all, enable the router/switch to do it (remember it is dangerous…):

snmp-server system-shutdown

Then use only this command (the previous snmpset are not required):

snmpset snmpset -c [snmp-community-string] -v 2c [ip-device]  . i 2

Where [ip-device] is the ip address of the device that you want reload; the [snmp-community-string] is the snmp-server community (must be R/W).

Note: If you don’t configure the “snmp-server system-shutdown”, the device shows this message:

%SYS-4-RELOAD_ATTEMPT: Attempt via SNMP failed, system shutdown not configured


  • Each time you copy to or from a device using SNMP, choose a random number. This number creates a row instance. It must be the same everywhere in your command. Once you use a specific number, it can not be used again before it times out. The timeout is five minutes. If you use the same number within the five minutes, you get an error (SNMP: Inconsistent value.)
  • You must upload complete configurations when you use the snmpset command. Partial configurations erase what is currently stored in non-volatile RAM (NVRAM). This is only needed for startup configurations. When you run a configuration copy it merges the contents.