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 terminalEnter configuration commands, one per line. End with CNTL/Z. Router(config)#snmp-server communityORARWrwRouter(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%touchFreebsd%/tftpboot/router.cfgchmod 666Freebsd%/tftpboot/router.cfgsnmpset –v1 -cORARWRouter.1.3.6.1.4.1.9.2.1.55.172.25.1.1senterprises.9.2.1.55.172.25.1.1 = "router.cfg" Freebsd%router.cfg
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" >Freebsd%/tftpboot/new.cfgecho "end" >>Freebsd%/tftpboot/new.cfgchmodFreebsd%666 /tftpboot/new.cfgsnmpset –v1 -cORARWRouter.1.3.6.1.4.1.9.2.1.53.172.25.1.1senterprises.9.2.1.53.172.25.1.1 = "new.cfg" Freebsd%new.cfgsnmpset –v1 -cORARWRouter.1.3.6.1.4.1.9.2.1.54.0 i 1enterprises.9.2.1.54.0 = 1 Freebsd%
Discussion
The ability to extract or modify your ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access