Posts: 4
Registered: ‎08-20-2007

howto: configure srw2024 on the fly via a script

This is a bit long, but necessarily so.

In my own search on doing this, I noticed a couple questions here about configuring a srw2024 (gigabit managed) & related products through a script. I'm assuming this might work on related products -- it has only been tested on my srw2024.

Before I begin: I did this through an apparently undocumented interface. In testing out the options, I *locked up the switch several times*, which required a manual power cycle to fix. I'd assume it is perfectly possible to make your switch a paperweight playing around here, so please be careful. If you aren't very experienced with computers, don't do it. Especially don't do this (for the first time anyway) on a switch in production.

The instructions are written for linux, but the necessary tools are available in windows as well. Going over how to set every option would be a book, so I'm assuming you have a good idea as to what you want to do & how to configure it, just not how to make the switch do it in an automatic manner.

Also, as far as I know, this is a version 1 switch (hardware version is actually 00.00.03 -- there is no version info on the outside). Your mileage may vary.

Last warning, I can take no responsibility if following these directions ruins your switch. I thought *I* did once doing this. :-)

Step 1: Update to at least 1.2.2 firmware (oldest firmware is guaranteed to lock up if you try any of this)

Step 2: Try out the command line interface manually:
- Telnet to the switch & login
- Once you get to the menu, hit ctrl+z, you should now see a ">" (type ? to all available commands from this point on)
- Type lcli, hit enter, and put the user name in again (admin usually)
- now you should see "console#"

Most of the interesting options are gained through the configure command. A decent amount of help is available by typing in the command, a space, and then ?. Play around, see what it takes to do whatever it is you want to. I'm going to assume you can figure out most of this by looking around. If everything you see is "techno-babble", please quit the telnet session (repeat the exit command until >, then logout). :-)

Step 3: Take a look at & install expect (
- Expect is a way to automate telnet sessions
- Fedora has expect available through yum, I'd imagine most distros have it through their respective repositories as well.
- A windows version is available, but I haven't tried it
- Send \032 is "Ctrl + Z"

Step 4: Take a gander at my script
I needed a way to fence off an apparently crashed machine in a clustered enviroment so that two machines don't access an ext3 volume at the same time (which is a Very Bad Thing). This script logs in (assuming the username is admin w/ no password) and shuts off port 20. Taking a look at this & the man page for expect should get you started.

spawn telnet
sleep 2
send "admin\r"
expect "Menu"
send \032
expect ">"
send "lcli\r"
expect "Name:"
send "admin\r"
expect "console#"
send "configure\r"
expect "console(config)#"
send "interface ethernet g20\r"
expect "console(config-if)#"
send "shutdown\r"
expect "console(config-if)#"
send "end\r"
expect "console#"
send "exit\r"
expect ">"
send "logout\r"
expect eof

Please note that there is no way (that I can see) to bring an interface back up through the text interface. Which is fine for my particular purposes.

Hopefully that sets you on the right path. It is a bit of a hack, but it does work, and is cheaper than purchasing an enterprise-class switch.

Technically, you could do the same thing on the standard console. If you look up the escape values for escape, tab, up/down arrow, and so on -- you could create a script that automatically navigates its way through the menu system. However, I found the command line interface to be much more straightforward after accidentally discovering it.

Have fun!
Posts: 4
Registered: ‎08-28-2007

Re: howto: configure srw2024 on the fly via a script

In order to return the interface to a working state using the "Cisco" IOS, which is basically what seems to be running on the Linksys managed switches, you need to use the "no" command.

shutdown -- shuts down interface
no shutdown -- brings interface back up

You'll find the "no" command is used in many places around the IOS.

Hope this helps.

PS. Thank you for letting me know how to get into the bloody CLI. Smiley HappyKudos
Posts: 2
Registered: ‎11-17-2008

Re: howto: configure srw2024 on the fly via a script



is there somewhere a documentation for ciscos IOS or CLI?




Posts: 4
Registered: ‎08-28-2007

Re: howto: configure srw2024 on the fly via a script

This is the reference for the latest IOS software, which has significantly than the stunted version of "IOS" running on the linksys products, but it will give you a good understanding of what the commands do.