Using SNMP to Copy a New IOS Image
Problem
You want use SNMP to remotely upgrade a router’s IOS.
Solution
Before you can upload or download the router’s IOS image to a TFTP server, you have to set up a valid read-write SNMP community string:
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. Router(config)#snmp-server community
ORARW
rw
Router(config)#end
Then you can download a copy of your router’s current IOS file to your TFTP server with the following Unix commands:
Freebsd%touch
Freebsd%
/tftpboot/c2600-jk9o3s-mz.122-7a.bin
chmod 666
Freebsd%
/tftpboot/c2600-jk9o3s-mz.122-7a.bin
snmpset –v1 -c
ORARW Router
.1.3.6.1.4.1.9.2.10.9.
172.25.1.1
enterprises.9.2.10.9.172.25.1.1 = "c2600-jk9o3s-mz.122-7a.bin" Freebsd%
s c2600-jk9o3s-mz.122-7a.bin
Use the following commands to upload an IOS file from your TFTP server to the router’s flash memory:
Freebsd%chmod 666
Freebsd%
/tftpboot/c2600-jk9o3s-mz.122-7a.bin
snmpset –v1 -c
ORARW Router
.1.3.6.1.4.1.9.2.10.6.0 i
1
enterprises.9.2.10.6.0 = 1 Freebsd%snmpset –v1 -c
ORARW
Router
.1.3.6.1.4.1.9.2.10.12.
172.25.1.1
s
enterprises.9.2.10.12.172.25.1.1 = "c2600-jk9o3s-mz.122-7a.bin" Freebsd%
c2600-jk9o3s-mz.122-7a.bin
Discussion
The first example demonstrates how to use SNMP to force a router to download its IOS file to a TFTP server. Most TFTP servers will not accept an incoming transfer unless the destination file is world writable. On Unix computers, the touch command creates a file, and the chmod command gives ...
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.