How to Send Commands to the CISCO Router via SNMP

Requirements

1- First create a community and grant Read&Write rights to this community.

en
conf t
snmp-server community community-name rw
copy running-config startup-config

2- Configure tftp, ftp etc services on the server which will be sending the commands.
3- Create a directory including the file containing the commands to be sent.

Method

The X values below are unique for each command process. Suppose that we created commands.txt file and it is containing the commands to be sent.

1- First choose the file transfer protocol (ccCopyProtocol).

snmpset -v 2c -c community-name router_ip 1.3.6.1.4.1.9.9.96.1.1.1.1.2.X i 1
1: tftp
2: ftp
3: rcp
4: scp
5: sftp

2- Choose the source file type (ccCopySourceFileType).

snmpset -v 2c -c community-name router_ip 1.3.6.1.4.1.9.9.96.1.1.1.1.3.X i 1
1:networkFile
2:iosFile
3:startupConfig
4:runningConfig
5:terminal
6:fabricStartupConfig

3- Choose the destination file type (ccCopyDestFileType).

snmpset -v 2c -c  community-name router_ip 1.3.6.1.4.1.9.9.96.1.1.1.1.4.X i 4
1:networkFile
2:iosFile
3:startupConfig
4:runningConfig
5:terminal
6:fabricStartupConfig

4- Set the server IP address which will transfer the files (ccCopyServerAddress).

snmpset -v 2c -c  community-name router_ip 1.3.6.1.4.1.9.9.96.1.1.1.1.5.X a TFTP_Server_IP

5- Set the file name to be transferred. (ccCopyFileName).

snmpset -v 2c -c  community-name router_ip 1.3.6.1.4.1.9.9.96.1.1.1.1.6.X s commands.txt

6- Apply the configuration (ccCopyEntryRowStatus).

snmpset -v 2c -c  community-name router_ip 1.3.6.1.4.1.9.9.96.1.1.1.1.14.X i 1
1:active
2:notInService
3:notReady
4:createAndGo
5:createAndWait
6:destroy


Example

The details of the commands.txt file:

conf t 
ip route 1.1.1.0 255.255.255.0 2.2.2.2
ip prefix-list CUSTOMER seq 1 permit 1.1.1.0/24
exit
copy running-config startup-config


Commands to be run on the server:

snmpset -v 2c -c awesome 10.20.30.40 1.3.6.1.4.1.9.9.96.1.1.1.1.2.1 i 1
snmpset -v 2c -c awesome 10.20.30.40 1.3.6.1.4.1.9.9.96.1.1.1.1.3.1 i 1
snmpset -v 2c -c awesome 10.20.30.40 1.3.6.1.4.1.9.9.96.1.1.1.1.4.1 i 4
snmpset -v 2c -c awesome 10.20.30.40 1.3.6.1.4.1.9.9.96.1.1.1.1.5.1 a 172.25.6.12
snmpset -v 2c -c awesome 10.20.30.40 1.3.6.1.4.1.9.9.96.1.1.1.1.6.1 s commands.txt
snmpset -v 2c -c awesome 10.20.30.40 1.3.6.1.4.1.9.9.96.1.1.1.1.14.1 i 1