Using SNMP to Modify a Router’s Running Configuration

Problem

You want to use SNMP to either download or modify a router’s configuration.

Solution

To upload or download a current copy of your router’s configuration file to a TFTP server via SNMP, you have to first configure the router for read-write SNMP access:

Router#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#snmp-server community ORARW rw
Router(config)#end

To download the current configuration file, you will need to create an empty file on your TFTP server. In this case, we assume a Unix server, although TFTP server software is available for essentially every popular operating system. Then you can send an SNMP command to the router to trigger the TFTP download:

Freebsd% touch /tftpboot/router.cfg
Freebsd% chmod 666 /tftpboot/router.cfg
Freebsd% snmpset –v1 -c ORARW Router .1.3.6.1.4.1.9.2.1.55.172.25.1.1 s router.cfg
enterprises.9.2.1.55.172.25.1.1 = "router.cfg"
Freebsd%

You can use SNMP to trigger the router to upload a configuration file from your TFTP server via SNMP as follows:

Freebsd% echo "no ip source-route" > /tftpboot/new.cfg
Freebsd% echo "end" >> /tftpboot/new.cfg
Freebsd% chmod 666 /tftpboot/new.cfg
Freebsd% snmpset –v1 -c ORARW Router .1.3.6.1.4.1.9.2.1.53.172.25.1.1 s new.cfg
enterprises.9.2.1.53.172.25.1.1 = "new.cfg"
Freebsd% snmpset –v1 -c ORARW Router .1.3.6.1.4.1.9.2.1.54.0 i 1
enterprises.9.2.1.54.0 = 1
Freebsd%

Discussion

The ability to extract or modify your ...

Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.