Guest

IP Application Services

How To Copy Configurations To and From Cisco Devices Using SNMP

Cisco - How To Copy Configurations To and From Cisco Devices Using SNMP

Document ID: 15217

Updated: Nov 01, 2005

   Print

Introduction

This document shows how to copy a configuration file to and from a Cisco device with the CISCO-CONFIG-COPY-MIB. If you start from Cisco IOS® software release 12.0, or on some devices as early as release 11.2P, Cisco has implemented a new means of Simple Network Management Protocol (SNMP) configuration management with the new CISCO-CONFIG-COPY-MIB. This MIB replaces the deprecated configuration section of the OLD-CISCO-SYSTEM-MIB. You can still locate the old document on Cisco.com.

Prerequisites

Requirements

There are no specific requirements for this document.

Components Used

The information in this document is based on these software and hardware versions.

  • Any Cisco device running Cisco IOS software release 12.0 and later. Check the supportlist of the devices to ensure support of the CISCO-CONFIG-COPY-MIB.

    Note: This MIB is not supported on Catalysts.

  • SNMPWalk from HP OpenView (HPOV) Network Node Manager, installed on a Windows 2000 platform.

These MIBs are used:

  • CISCO-SMI-V1SMI.my

  • SNMPv2-TC-V1SMI.my

  • CISCO-CONFIG-COPY-MIB-V1SMI.my

  • CISCO-FLASH-MIB.my

The ObjectIDs (OIDs) used from the CISCO-CONFIG-COPY-MIB are:

  • ccCopyEntryRowStatus 
            TYPE : integer 
            VALUES : createAndGo(4) : Create an entry 
                              destroy(6) : Delete an entry 
  • ccCopyProtocol 
            TYPE : integer 
            VALUES : tftp(1) : To use tftp as protocol to copy
                              rcp(3) : To use RCP as protocol to copy 

    Note: The MIB lists that it does File Transfer Protocol (FTP) as well, but this is not supported (refer to CSCdm53866). FTP is not implemented using SNMP, although it does work on the command line.

  • \ccCopySourceFileType: specifies the type of file to copy from. 
            TYPE : integer 
            VALUES : networkFile(1) 
                              startupConfig(3) 
                              runningConfig(4) 
    
    
  • ccCopyDestFileType: specifies the type of file to copy to. 
            TYPE : integer 
            VALUES : networkFile(1) 
                              startupConfig(3) 
                              runningConfig(4) 
    
    

    Note: The MIB lists that it supports iosFile(2) and terminal(5) as well, but this option is not supported (refer to CSCdu08968). You can do this with the CISCO-FLASH-MIB.my. Refer to the Appendix for more information on how to use this MIB.

  • ccCopyServerAddress: The IP address of the Trivial File Transfer Protocol
     (TFTP) server from (or to) which to copy the configuration file. 
            TYPE : ipaddress 
            VALUES : Any valid ip address xxx.xxx.xxx.xxx 
    
    

    Note: Values of 0.0.0.0 or FF.FF.FF.FF are not allowed.

  • ccCopyFileName 
            TYPE : octetstring 
            VALUES : The file name (including the path, if applicable)
            of the file. The file name is referred to as <file name>. 

The information presented in this document was created from devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If you work in a live network, ensure that you understand the potential impact of any command.

Conventions

For more information on document conventions, refer to the Cisco Technical Tips Conventions.

Procedure

Complete these instructions:

  1. Make sure that you add the previously mentioned MIBs into your HP OpenView station.

    This ensures that you can use the OID descriptions instead of the numbered ones. To do this, go to these links on Cisco.com and download the MIBs:

  2. Start HPOV and access the graphic user interface (GUI).

  3. From the Options menu, select Load/Unload MIBs: SNMP.

  4. Click Browse. Select the MIB you want to load and click Open.

  5. Repeat these steps until all the required MIBs are loaded into your HPOV.

Copy the Startup-Configuration Located on the TFTP Server to the Device

In the example, assume these:

  • You are using the HPOV version of snmpset. The tftp-server IP-address is shown as <server ip address> and the device used is shown as <device name>. The example is done with only one command, so type it in on the same rule.

  • The read-write community string on the router in question is private. The protocol used is TFTP.

Notes:

  • 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.

Complete these instructions:

  1. In this example, the OID names are used (refer to point 1). For an example with numbered OIDs, refer to the Appendix.

    C:\>snmpset -v 1 -c private <device name> ccCopyProtocol.<random number> integer 1 
    ccCopySourceFileType.<Random number> integer 1 
    ccCopyDestFileType.<Random number> integer 3 
    ccCopyServerAddress.<Random number> ipaddress "<server ip address>" 
    ccCopyFileName. <Random number> octetstring "<file name>" 
    ccCopyEntryRowStatus.<Random number> integer 4  
  2. Enter Return and you see this output (111 is the random number in this example):

    cisco.ciscoMgmt.ciscoConfigCopyMIB.ciscoConfigCopyMIBObjects.ccCopy.
    ccCopyTable.ccCopyEntry.ccCopyProtocol.111 : INTEGER: tftp 
    cisco.ciscoMgmt.ciscoConfigCopyMIB.ciscoConfigCopyMIBObjects.ccCopy.
    ccCopyTable.ccCopyEntry.ccCopySourceFileType.111 : INTEGER: networkFile 
    cisco.ciscoMgmt.ciscoConfigCopyMIB.ciscoConfigCopyMIBObjects.ccCopy.
    ccCopyTable.ccCopyEntry.ccCopyDestFileType.111 : INTEGER: startupConfig 
    cisco.ciscoMgmt.ciscoConfigCopyMIB.ciscoConfigCopyMIBObjects.ccCopy.
    ccCopyTable.ccCopyEntry.ccCopyServerAddress.111 : IpAddress: 172.17.246.205 
    cisco.ciscoMgmt.ciscoConfigCopyMIB.ciscoConfigCopyMIBObjects.ccCopy.
    ccCopyTable.ccCopyEntry.ccCopyFileName.111 : 
    DISPLAY STRING- (ascii):  foo-confg 
    cisco.ciscoMgmt.ciscoConfigCopyMIB.ciscoConfigCopyMIBObjects.ccCopy.
    ccCopyTable.ccCopyEntry.ccCopyEntryRowStatus.111 : INTEGER: createAndGo  
    
  3. Check the copy status to verify if the copy is successful.

    C:\>snmpwalk <device name> ccCopyState 
    cisco.ciscoMgmt.ciscoConfigCopyMIB.ciscoConfigCopyMIBObjects.ccCopy.
    ccCopyTable.ccCopyEntry.ccCopyState.111 : INTEGER: running 
  4. Repeat step 3 until you see the status: successful.

    C:\>snmpwalk <device name> ccCopyState 
    cisco.ciscoMgmt.ciscoConfigCopyMIB.ciscoConfigCopyMIBObjects.ccCopy.
    ccCopyTable.ccCopyEntry.ccCopyState.111 : INTEGER: successful 
  5. Once you get the successful status, you can clear the row entry. In this example, the row is the <random number> that you chose previously.

    C:\>snmpset -v 1 -c private <device name>
     ccCopyEntryRowStatus.111 integer 6 
    cisco.ciscoMgmt.ciscoConfigCopyMIB.ciscoConfigCopyMIBObjects.ccCopy.
    ccCopyTable.ccCopyEntry.ccCopyEntryRowStatus.111 : INTEGER: destroy 

Copy the Running-Configuration to the TFTP Server

To copy the running configuration to the TFTP server, replace this OIDs from the example above:

ccCopySourceFileType.<Random number> integer 4 
ccCopyDestFileType.<Random number> integer 1 

Notes:

  • Verify that the file exists on your TFTP server when you use a UNIX TFTP server, and that it has the correct permissions! There is no need to create the file when you use a TFTP server on Windows. These are two examples, but remember that you can copy in all possible directions.

  • TFTP is one of two supported protocols. The CONFIG-COPY-MIB also supports Remote Copy Protocol (RCP).

Appendix

This example is the same as the one used previously, but uses numbered OIDs:

C:\>snmpset -v 1 -c private <device name> 
.1.3.6.1.4.1.9.9.96.1.1.1.1.2.<Random number> integer 1 
.1.3.6.1.4.1.9.9.96.1.1.1.1.3.<Random number> integer 4 
.1.3.6.1.4.1.9.9.96.1.1.1.1.4.<Random number> integer 1 
.1.3.6.1.4.1.9.9.96.1.1.1.1.5.<Random number> ipaddress "<server ip address>" 
.1.3.6.1.4.1.9.9.96.1.1.1.1.6.<Random number> octetstring "<file name>" 
.1.3.6.1.4.1.9.9.96.1.1.1.1.14.<Random number> integer 4 

C:\>snmpwalk cognac .1.3.6.1.4.1.9.9.96.1.1.1.1.10 

C:\>snmpset -v 1 -c private <device name>
 .1.3.6.1.4.1.9.9.96.1.1.1.1.14.<Random number> integer 6 

Complete these steps to use the CISCO-FLASH-MIB to copy a configuration file located on a TFTP server to Flash on your router:

C:\>snmpset -v 1 -c private <device name> 

cisco.ciscoMgmt.ciscoFlashMIB.ciscoFlashMIBObjects.ciscoFlashOps.
ciscoFlashCopyTable.ciscoFlashCopyEntry.cisco
  FlashCopyCommand.666 : INTEGER: copyToFlashWithoutErase 
cisco.ciscoMgmt.ciscoFlashMIB.ciscoFlashMIBObjects.ciscoFlashOps.
ciscoFlashCopyTable.ciscoFlashCopyEntry.cisco
  FlashCopyProtocol.666 : INTEGER: tftp 
cisco.ciscoMgmt.ciscoFlashMIB.ciscoFlashMIBObjects.ciscoFlashOps.
ciscoFlashCopyTable.ciscoFlashCopyEntry.cisco
  FlashCopyServerAddress.666 : IpAddress: 172.17.246.205 
cisco.ciscoMgmt.ciscoFlashMIB.ciscoFlashMIBObjects.ciscoFlashOps.
ciscoFlashCopyTable.ciscoFlashCopyEntry.cisco
  FlashCopySourceName.666 : DISPLAY STRING- (ascii):  test_file.txt 
cisco.ciscoMgmt.ciscoFlashMIB.ciscoFlashMIBObjects.ciscoFlashOps.
ciscoFlashCopyTable.ciscoFlashCopyEntry.cisco
  FlashCopyDestinationName.666 : DISPLAY STRING- (ascii):  flash:/test_file.txt 
cisco.ciscoMgmt.ciscoFlashMIB.ciscoFlashMIBObjects.ciscoFlashOps.
ciscoFlashCopyTable.ciscoFlashCopyEntry.cisco
  FlashCopyEntryStatus.666 : INTEGER: createAndGo  

You can find an overview of the OIDs used in the CISCO-CONFIG-COPY-MIB at: http://tools.cisco.com/Support/SNMP/do/BrowseMIB.do?local=en&mibName=CISCO-CONFIG-COPY-MIB.

You can find an overview of the OIDs used in the CISCO-FLASH-MIB at: ftp://ftp.cisco.com/pub/mibs/oid/CISCO-FLASH-MIB.oid.

You can read complete MIB information from the MIBs you downloaded. Read the MIB for other options (for example, if you want to use RCP instead of TFTP).

Related Information

Updated: Nov 01, 2005
Document ID: 15217