5 Replies Latest reply: Dec 6, 2012 10:02 AM by tnewshott@gmail.com RSS

    How to use script to configure cisco devices?


      How to use script to configure cisco devices?




        • 1. Re: How to use script to configure cisco devices?

          Could you be more specific about what you're trying to achieve? It's a pretty vague question

          • 2. Re: How to use script to configure cisco devices?

            Hi northlandboy,


            I was tring to update the the config, such as updating the name server, ntp server with script.


            e.g.      #conf t

                       #ip name-server


            I have 50 devices, and they are using the same DNS server, so I want to use script to add the config instead of logging to each device and running the command manually.



            • 3. Re: How to use script to configure cisco devices?

              Ah OK, I completely understand what you're trying to do.


              It is definitely something you can do, it's just a matter of working out the best way for you to do it.


              There's two main ways of pushing out changes to a range of devices - using an Expect script, or using a combination of SNMP SET, and TFTP/FTP for config retrieval.


              If you have a bit of scripting experience, then configuring an Expect script is probably easier than using snmpset. This is also free, apart from your time. You should be able to find some Expect scripts that you can customise online - try here for a start: http://cosi-nms.sourceforge.net/alpha-progs.html


              However, if possible, I would recommend you look at using a software package to help manage this in future. I don't know of any decent free config management toolsets out there - RANCID is good for backups, but I don't know of any free packages for pushing out configs.


              Instead you could look at one of these tools:

              * Kiwi Cat Tools - basic config management, including pushing out changes

              * HP iMC - monitoring, as well as full configuration management (reasonably priced)

              * Cisco Prime (Don't know what this will cost you - may be expensive)

              * Solarwinds NCM - integrates with NPM if you're using that too.


              The advantage of using those toolsets is that they deal with variations well - e.g. maybe you've got ASAs, IOS, NX-OS and some HP Networking equipment. If you write your own scripts, you need to customise them for each variant. If you use a software package to do it, then they've worked out the customisation needed for each vendor/model.


              For me, if it was just a once-off change, then write a script. If you want to do proper config management, and will be making more changes in future, then look at software packages to help.

              • 4. Re: How to use script to configure cisco devices?

                Nice. I've not done that before.


                An alternative is to use visual basic with Secure CRT. Write yourself a script to connect to all devices hostnames located in a text file then double click VBScript File. Once your on one of the devices, just right click the bottom pane and select "send to all tabs". You can then copy paste your comands in one window, and it will execute it on all your tabs (i.e. network devices). I can't provide the script I'm using because it belongs to the bank = data protection etc. But it's easy to make (there's only 50 lines of code in the one I'm using).

                • 5. Re: How to use script to configure cisco devices?

                  The newer SecureCRT versions support Perl, which I've always found a bit more superior as a scripting language for quick and dirty tasks than VB. To each their own, however. With that said, though, it is far more extensible to run scripts from a network management server running Linux, than it is to run scripts from SecureCRT on a PC.



                  50 hosts is a bit much for SecureCRT in my opinion, especially if you are sending more than a few lines. You tend to need to tweak the per-character and per-line timer in SecureCRT at that point, similar to pasting in large config files. Then, in the script, you need to ensure you are waiting for the prompt before sending the next line.


                  I've seriously contemplated writing a perl script that would accept an IOS change script in .txt format, then wrap it in perl commands, and kick it out as a perl script, ready to be run in SecureCRT. Of course every time I start doing this, I no longer need it, and I get pulled in another direction. C'est la vie.