download cisco configuration with snmpget

8,258

Solution 1

Your initial question stated that you were trying to get the configuration from a monitoring server, but your response to petrus indicates that you want to copy the configuration to the server, and that's what your original example shows, so I assume that's what you're after.

Two things:

1 - This doesn't work for me without a . at the beginning of the numerical OIDS.

2 - It looks like the TYPE values available with your version of snmpget don't match those in the Cisco doc (it says they use the HPOV version of snmpset). Try running 'snmpset' without any parameters and see what you get; if you're using Net-SNMP there should be a section near the bottom that specifies the TYPEs available.

--

Here are the steps I've used in the past, using Net-SNMP and CISCO-CONFIG-COPY-MIB (apologies for the length):

Step 1: Configure the ccCopyEntryTable with the desired protocol (tftp=1), the source file type (runningConfig=4), the destination file type (networkFile=1), the IP address of your tftp server, and the desired filename on the tftp server. Last, set the RowStatus to "createAndGo" (4).

Numerically:

snmpset -v 2c -c private lab-rtr1 \
.1.3.6.1.4.1.9.9.96.1.1.1.1.2.111 i 1 \
.1.3.6.1.4.1.9.9.96.1.1.1.1.3.111 i 4 \
.1.3.6.1.4.1.9.9.96.1.1.1.1.4.111 i 1 \
.1.3.6.1.4.1.9.9.96.1.1.1.1.5.111 a 10.1.1.1 \
.1.3.6.1.4.1.9.9.96.1.1.1.1.6.111 s "lab-rtr1-confg" \
.1.3.6.1.4.1.9.9.96.1.1.1.1.14.111 i 4

Using the text OIDs from the MIB:

snmpset -O s -m CISCO-CONFIG-COPY-MIB -v 2c -c private lab-rtr1 \
ccCopyProtocol.111 i 1 \
ccCopySourceFileType.111 i 4 \
ccCopyDestFileType.111 i 1 \
ccCopyServerAddress.111 a 10.1.1.1 \
ccCopyFileName.111 s "lab-rtr1-confg" \
ccCopyEntryRowStatus.111 i 4

You should get back something like this:

ccCopyProtocol.111 = INTEGER: tftp(1)
ccCopySourceFileType.111 = INTEGER: runningConfig(4)
ccCopyDestFileType.111 = INTEGER: networkFile(1)
ccCopyServerAddress.111 = IpAddress: 10.1.1.1
ccCopyFileName.111 = STRING: lab-rtr1-confg
ccCopyEntryRowStatus.111 = INTEGER: createAndGo(4)

Step 2: Check the status:

snmpget -v 2c -c private lab-rtr1 .1.3.6.1.4.1.9.9.96.1.1.1.1.10.111

Text version:

snmpget -O s -m CISCO-CONFIG-COPY-MIB -v 2c -c private lab-rtr1 ccCopyState.111

You should get back a "3", for success (check the MIB for other possible values):

ccCopyState.111 = INTEGER: successful(3)

Step 3: Destroy the row you created:

snmpset -v 2c -c private lab-rtr1 .1.3.6.1.4.1.9.9.96.1.1.1.1.14.111 i 6

Text version:

snmpset -O s -m CISCO-CONFIG-COPY-MIB -v 2c -c private lab-rtr1 ccCopyEntryRowStatus.111 i 6

You should get back something like this:

ccCopyEntryRowStatus.111 = INTEGER: destroy(6)

Step 4: Go verify it was actually copied over to the tftp server.

Solution 2

snmpset -v 2c -c <community> <router address> OLD-CISCO-SYS-MIB::netConfigSet.<tftp server> s <config-file>

<tftp-server> is dotted decimal.

<config-file> is a path relative to you TFTP root.

Example:

snmpset -v 2c -c private 192.168.0.254 OLD-CISCO-SYS-MIB::netConfigSet.192.168.0.10 s router-confg.txt

Solution 3

Thanks a lot for your answer.

However, according to OLD-CISCO-SYS-MIB

The oid is 1.3.6.1.4.1.9.2.1.50 and the command tipped was

snmpset -v2c -c public 172.23.176.71 1.3.6.1.4.1.9.2.1.50.172.23.129.4 s config

which returned

Error in packet.
Reason: commitFailed Failed object: iso.3.6.1.4.1.9.2.1.50.172.23.129.4

Did I choose the appropriate OID?

Moreover, it looks like it puts the configuration into the switch, I would like to perform the opposite transfer: from switch to server

Thanks for your help

Share:
8,258

Related videos on Youtube

philippe
Author by

philippe

Something about Myself

Updated on September 18, 2022

Comments

  • philippe
    philippe over 1 year

    I currently have troubles using snmpset to get the cisco configuration from a monitoring server.

    Here is what I tip:

    snmpset -v2c -cvtmYdXVHfo9v38oAbtACikvV calcium \
    1.3.6.1.4.1.9.9.96.1.1.1.1.2.111 integer 1 \
    1.3.6.1.4.1.9.9.96.1.1.1.1.3.111 integer 4 \ 
    1.3.6.1.4.1.9.9.96.1.1.1.1.4.111 integer 1 \
    1.3.6.1.4.1.9.9.96.1.1.1.1.5.111 ipaddress 172.23.129.4 \
    1.3.6.1.4.1.9.9.96.1.1.1.1.6.111 octetstring "config" \
    1.3.6.1.4.1.9.9.96.1.1.1.1.14.111 integer 4
    

    Following the documentation available at cisco_snmp_doc:

    ccCopyProtocol is 1.3.6.1.4.1.9.9.96.1.1.1.1.2
    ccCopySourceFileType 1.3.6.1.4.1.9.9.96.1.1.1.1.3
    ccCopyDestFileType 1.3.6.1.4.1.9.9.96.1.1.1.1.4
    ccCopyServerAddress 1.3.6.1.4.1.9.9.96.1.1.1.1.5
    ccCopyFileName 1.3.6.1.4.1.9.9.96.1.1.1.1.6
    ccCopyEntryRowStatus 1.3.6.1.4.1.9.9.96.1.1.1.1.14
    

    The Cisco documentation indicates to specify a random integer (here, 111, as it is in the documentation, but specifying 1 does not change anything)

    Here is what I get:

    1.3.6.1.4.1.9.9.96.1.1.1.1.5.111: Value out of range (172.23.129.4)
    1.3.6.1.4.1.9.9.96.1.1.1.1.6.111: Unknown Object Identifier \
    (Sub-id not found: (top) -> config)
    

    Obviously, I can't set the ip address of my server to the related oid. Furthermore, I can't figure out what the second error means.

    Can anyone give me some advice ? Any help or clue would be deeply appreciated

    Thanks a lot :)