ESHARP.NET

Technology and life with Eyvonne Sharp

  • LinkedIn
  • RSS
  • Twitter
  • Home
  • Technical Notes
  • Industry Musings
  • Career
  • Community
  • Reading List
  • Find Me Online
You are here: Home / Technical Notes / How to use TCL to script commands on Cisco ISR Routers

How to use TCL to script commands on Cisco ISR Routers

December 21, 2016 By Eyvonne 4 Comments

Network engineers often find themselves in a scenario where the key needed to solve a problem is locked inside the box containing the solution. Scripting tools within Cisco’s IOS can help resolve these issues predictably with minimal interruption.

Locked Box

Recently, I had an issue with Cisco ISR routers that connect to carrier equipment. Our carrier hard codes ethernet ports to 100/full and will not support auto negotiation. When a Cisco router, configured by default to auto negotiate, connects to the carrier equipment the network port comes up half-duplex.

Users call. The network is slow. Utilization graphs do not indicate circuit saturation. It’s a lose-lose situation.

On several router models, including Cisco ISR 4000 series, the CLI interface makes this simple problem difficult to solve. You cannot configure the interface for full-duplex without removing the auto negotiate command. However, when you remove auto negotiate, the interface drops and will not reconnect. On a singly connected router, you lose access before you can complete the configuration change.

To work around this problem, use the integrated TCL shell to batch a set of CLI commands. As always, save your config and then issue the reload in command to reboot the router if you lose access. If required by your organization, coordinate a maintenance window. Even if the change works perfectly, you’ll bounce the port when you change the negotiation settings.

reload in 0:05
tclsh      

set fixinterface {
ios_config "interface gi0/0/2" "no negot auto" "speed 100" "duplex full"
}

eval $fixinterface

If all goes well, after you run the script, the interface will drop and renegotiate at 100/full. Log back into your router, reload cancel, and save your config.

You can use these straight-forward commands to automate much more powerful configurations or to fix equally minor, but difficult to resolve, problems.

Share this:

  • Twitter
  • Facebook
  • LinkedIn
  • Email
  • Print

Filed Under: Technical Notes Tagged With: Cisco, ISR

Comments

  1. Anil says

    February 14, 2017 at 4:58 pm

    I was facing the same issue and this solution is a life saver for me. Thank you so much. 🙂

    Reply
  2. Gary says

    March 30, 2018 at 11:38 am

    My OS requires the media-type to be set before the speed and duplex commands are even an option. Ci$co really made this much more difficult than it used to be…

    set fixint {ios_config “int g0/0/0” “media rj45” “no nego auto” “speed 100” “duplex full”}

    Reply
  3. Patty says

    May 7, 2018 at 12:38 pm

    I am dabbling within a similar but different framework. I need to log into a 5k, and then log into as many as 15 FEX, that may be running different version of ASIC’s and pull taildrop stats and present the results to a text file. I think I can make a solarwinds NCM job handle the presenting the results to the text file, but getting the FEX commands entered in order, is the issue. I have 50ish FEX to pull these stats from.

    And to eventually get cute, to integrate this into, when the taildrops look like they are the result of oversubscription, to then get ServiceNow to produce a ticket to view nodes that may need links added, or have overly bursty servers attached.

    I’m assuming I’ll end up in python, doing this, as the most efficient route.

    Reply
  4. Brent R says

    July 29, 2019 at 1:00 pm

    Wow,
    This was the EXACT issue I was having. Thanks for this. I just changed he interface portion of the script and it worked like a charm!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

About Eyvonne

Picture of Eyvonne
Eyvonne Sharp leads an incredible team of cloud infrastructure customer engineers as the Head of North American Customer Engineering for Infrastructure Modernization at Google Cloud. In her spare time, she reads, writes, and enjoys time with her husband and 4 kiddos. She's an occasional flutist and wannabe philosopher.

What Others Are Reading

  • The Wonderful Life Problem (TWLP): Dealing with Disappointments in our Work Lives
    The Wonderful Life Problem (TWLP): Dealing with Disappointments in our Work Lives
  • The Second Act: Thriving as an Experienced Technologist
    The Second Act: Thriving as an Experienced Technologist
  • The work we want
    The work we want
  • Work and Values: Why it matters
    Work and Values: Why it matters
  • Change - Personal, Professional, Organizational
    Change - Personal, Professional, Organizational

On Twitter

  • Just now
  • See @SharpNetwork on Twitter

Copyright © 2025