Changing the Break Character in Cisco IOS

The Break Character

For whatever historical reason (I used to know, but I’ve forgotten ) the break character for Cisco IOS command line is Ctrl-Shift-6 and X. Now, that is a pain to type and I often makes mistakes because it takes four fingers in coordinated fashion (lets face it, I’m not a world class athlete, and using four fingers is beyond my physical capability). So I have a habit of repeating it about five times …just to make sure.

Most importantly, when you are using a Cisco terminal server to access a router on a test bench (or study rack) and you hit the break sequence, the session snaps back to terminal server as if you had issued the command there. Annoying right ?

R0#sh run int fa1/0
Building configuration...

Current configuration : 95 bytes
!
interface FastEthernet1/0
 ip address 198.18.1.2 255.255.255.0
 duplex auto
 speed auto
end

R0#telnet 198.18.1.1
Trying 198.18.1.1 ... Open

r1#
r1#
r1#
r1#
r1#

So now I have connected over to a neighboring router, and foolishly attempted to ping something that doesn’t exist:

r1#ping 10.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
...

Now I hit the break key because I’m impatient and

R0#

That right, I have shifted the console back to the first router.

Solution

My solution on my test bench has been to change the escape character on the routers (but not on the terminal server).

Works for Telnet/SSH too

A common practice when making routing changes is to telnet to the nearest router, then jump to to remote router and make the routing changes. This way, if the routing doesn’t work exactly right you still have a console session running.

This has the same problem. If you hit break to shut out a ping command, or interrupt a DNS lookup, your console will snap back to the original router.

Changing the Break / Escape Character

There are two ways to change the escape sequence / break character on Cisco IOS.

Change the break character for the current session

This sequence changes it only for current SSH/Telnet session that you are using. Changes are lost when you exit the session.

Router#terminal escape-character ?
  BREAK            Cause escape on BREAK
  CHAR or <0-255>  Escape character or its ASCII decimal equivalent
  DEFAULT          Use default escape character
  NONE             Disable escape entirely
  soft             Set the soft escape character for this line

Router#terminal escape-character 23
"^W" is the escape character
Router#

See that? My personal choice is Ctrl-W because it’s easy to type and doesn’t conflict with much else in the ASCII characters

Change the break permanently

Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#lin
Router(config)#line vty 0 4
Router(config-line)#escape-character ?
BREAK            Cause escape on BREAK
CHAR or <0-255>  Escape character or its ASCII decimal equivalent
DEFAULT          Use default escape character
NONE             Disable escape entirely
soft             Set the soft escape character for this line
Router(config-line)#escape-character 23
Router(config-line)#

Changing it back

For those people who will rush off and test this on a live router (oh yes, Elizabeth, they do exist):

Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#line vty 0 4
Router(config-line)#default escape-character
Router(config-line)#^Z
Router#sh run | beg line
line con 0
 stopbits 1
line aux 0
 stopbits 1
line vty 0 4
 login
!
end

Router#

Closing this out

Generally, I wouldn’t recommend making this a default, because other people will have to work on your network eventually and this is the sort of thing that can have unexpected problems. But the settings for the current session is a neat trick and can save a lot of time in complex networks.

CCIE Mendicants may choose to use this also, but you need to be consistent about putting into your configuration across all devices. Might be a bit tricky.

Hope it’s useful.

About Greg Ferro

Greg Ferro is a Network Engineer/Architect, mostly focussed on Data Centre, Security Infrastructure, and recently Virtualization. He has over 20 years in IT, in wide range of employers working as a freelance consultant including Finance, Service Providers and Online Companies. He is CCIE#6920 and has a few ideas about the world, but not enough to really count.

He is a host on the Packet Pushers Podcast, blogger at EtherealMind.com and on Twitter @etherealmind and Google Plus

  • http://blog.ioshints.info Ivan Pepelnjak

    Oh, one more annoyance: Ctrl-Shift-6 works only on US (QWERTY) keyboards (because the Caret sign happens to be Shift-6), non-US keyboards usually require different sequence (sometimes even dependent on the terminal emulator you use).

    • http://etherealmind.com Greg Ferro

      I didn’t know that. Do you think that using Ctrl-W is good solution or would some other character be a better sequence ?

    • http://security-planet.de Karsten

      Thanks Greg for your article and thanks Ivan for your comment about the Caret. While working with PCs I never had problems with the break-sequence, even not on german keyboards. But after switching to MAC I didn’t get the break working on my (german) MAC-keyboard. “CTRL-Caret-x” does the “magic” which I was missing so much …
      Thanks again!!! (I’ll shout a beer if we meet sometime … )

      • http://etherealmind.com Greg Ferro

        I’ll look forward to that!!

  • http://teneo.wordpress.com Aaron Paxson

    Nice post! This may come in handy! Will need to store this in long-term memory. Thanks for sharing!

    • http://etherealmind.com Greg Ferro

      And thanks for the link! Good blog by the way, keep it up.

  • Pingback: Changing the break character on Cisco « Teneo !!!

  • snetherland

    This is a really great post. To be honest, something that has bugged me even more though is the auto-complete key. I have a habit of “tabbing out” lengthy command syntax. One of the things that I like about JunOS is that the space bar functions as the auto-complete key. Obviously not a real productivity boost, but I have relentlessly scoured the internet(meaning i have performed 3 google searches, and hopped through 2 blogrolls) and I have yet to run across a convenient method of modifying this in an IOS terminal session.

  • Pingback: SSH Escape Sequences (aka Kill Dead SSH Sessions) - The Lone Sysadmin