Tuesday, June 25, 2013

Quickly Change Cisco Nexus Config via Run-Script and Sed

This is a tip that I picked up from my friend Shahin. The Cisco Nexus 3K line of products (Nexus 3064, 3048) includes the Python interpretor built-in, which is great. But the rest of the 7k and 5k product line do not (not sure about 2k and 1k). The following tip is a way to create scripts that live in bootflash, then use the 'run-script' command to execute them in a quick and easy fashion. If you feel adventurous, you can cron the job or do it via EEM while you have a beer at the bar. :)

Note that the below example I am using the infamous Titanium image, but it works on real production NX-OS as well for sure.

1. Eth2/1 has an IP address that we will change to

2. We make a script by using the 'echo' statement and write to the file in bootflash:

3. We can view the file via 'show file':

4. We use 'run-script' to execute:

5. Verify:

That was kind of fun, but what if we want to remove ALL ip address on ALL interfaces in one shot? We can also use the *Nix sed to modify the text stream:

1. Back to the IP:

2. We can use sed to change string, note that it does not change the original string:

3. Now we can use the Cisco include command to include the string we want, then use sed to substitute the string. In this example I just include '' but you can use 'include 'ip addresses' for example:

4. Now you see the interface:

5. Run the script:

6. Now you dont:

How cool is that? This is an absolute time saver in large scale environment. I wish Cisco includs *Nix tools in all of their platforms.

Happy coding!


  1. Nice post. You pointed on very important facts by this post. This is really very informative and useful information. Thanks for sharing this post.apply aws jobs in hyderabad.

  2. Good job! Fruitful article. I like this very much. It is very useful for my research. It shows your interest in this topic very well. I hope you will post some more information about the software. Please keep sharing!!
    AWS Training in Chennai
    AWS Course in Chennai
    Selenium Training in Chennai
    Software Testing Training in Chennai
    Java Training in Chennai
    AWS Training in Anna Nagar
    AWS Training in T Nagar

  3. A IEEE project is an interrelated arrangement of exercises, having a positive beginning and end point and bringing about an interesting result in Engineering Colleges for a particular asset assignment working under a triple limitation - time, cost and execution. Final Year Project Domains for CSE In Engineering Colleges, final year IEEE Project Management requires the utilization of abilities and information to arrange, plan, plan, direct, control, screen, and assess a final year project for cse. The utilization of Project Management to accomplish authoritative objectives has expanded quickly and many engineering colleges have reacted with final year IEEE projects Project Centers in Chennai for CSE to help students in learning these remarkable abilities.

    Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
    Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

  4. "This is an absolute time saver " - absolutely agree, thanks .

  5. This comment has been removed by the author.