Tuesday, March 16, 2010

Changing the Break Character in Cisco IOS

August 21, 2009 by Greg Ferro · 8 Comments 

This Post is Part of a Series — click for list on Console Mastery»

The Break Character

For whatever his­tor­ical reason (I used to know, but I’ve for­got­ten ) the break char­ac­ter for Cisco IOS com­mand line is Ctrl-​​Shift-​​6 and X. Now, that is a pain to type and I often makes mis­takes because it takes four fin­gers in coordin­ated fash­ion (lets face it, I’m not a world class ath­lete, and using four fin­gers is bey­ond my phys­ical cap­ab­il­ity). So I have a habit of repeat­ing it about five times …just to make sure.

Most import­antly, when you are using a Cisco ter­minal server to access a router on a test bench (or study rack) and you hit the break sequence, the ses­sion snaps back to ter­minal server as if you had issued the com­mand 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 con­nec­ted over to a neigh­bor­ing router, and fool­ishly attemp­ted to ping some­thing 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 impa­tient and

R0#

That right, I have shif­ted the con­sole back to the first router.

Solution

My solu­tion on my test bench has been to change the escape char­ac­ter on the routers (but not on the ter­minal server).

Works for Telnet/​SSH too

A com­mon prac­tice when mak­ing rout­ing changes is to tel­net to the nearest router, then jump to to remote router and make the rout­ing changes. This way, if the rout­ing doesn’t work exactly right you still have a con­sole ses­sion running.

This has the same prob­lem. If you hit break to shut out a ping com­mand, or inter­rupt a DNS lookup, your con­sole will snap back to the ori­ginal router.

Changing the Break /​ Escape Character

There are two ways to change the escape sequence /​ break char­ac­ter on Cisco IOS.

Change the break char­ac­ter for the cur­rent session

This sequence changes it only for cur­rent SSH/​Telnet ses­sion 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 per­sonal choice is Ctrl-​​W because it’s easy to type and doesn’t con­flict 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 recom­mend mak­ing this a default, because other people will have to work on your net­work even­tu­ally and this is the sort of thing that can have unex­pec­ted prob­lems. But the set­tings for the cur­rent ses­sion is a neat trick and can save a lot of time in com­plex networks.

CCIE Mendicants may choose to use this also, but you need to be con­sist­ent about put­ting into your con­fig­ur­a­tion across all devices. Might be a bit tricky.

Hope it’s useful.

Please rate this post:

  Why Rate Posts?
1 Star - It\\\'s Crud2 Stars - It\\\'s Tosh3 Stars - Something\\\'s missing4 Stars - Needs works5 Stars - Good Enough6 Stars - Good7 Stars - Excellent8 Stars - Brilliant9 Stars - Astonishing10 Stars - Awesomely Godlike? (4 votes, average: 8.50 out of 10)
Loading ... Loading ...

Comments

8 Responses to “Changing the Break Character in Cisco IOS”
  1. Oh, one more annoy­ance: Ctrl-​​Shift-​​6 works only on US (QWERTY) key­boards (because the Caret sign hap­pens to be Shift-​​6), non-​​US key­boards usu­ally require dif­fer­ent sequence (some­times even depend­ent on the ter­minal emu­lator you use).

    • Greg Ferro says:

      I didn’t know that. Do you think that using Ctrl-​​W is good solu­tion or would some other char­ac­ter be a bet­ter sequence ?

    • Karsten says:

      Thanks Greg for your art­icle and thanks Ivan for your com­ment about the Caret. While work­ing with PCs I never had prob­lems with the break-​​sequence, even not on ger­man key­boards. But after switch­ing to MAC I didn’t get the break work­ing on my (ger­man) MAC-​​keyboard. “CTRL-​​Caret-​​x” does the “magic” which I was miss­ing so much …
      Thanks again!!! (I’ll shout a beer if we meet some­time … :-) )

  2. Aaron Paxson says:

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

  3. snetherland says:

    This is a really great post. To be hon­est, some­thing that has bugged me even more though is the auto-​​complete key. I have a habit of “tab­bing out” lengthy com­mand syn­tax. One of the things that I like about JunOS is that the space bar func­tions as the auto-​​complete key. Obviously not a real pro­ductiv­ity boost, but I have relent­lessly scoured the internet(meaning i have per­formed 3 google searches, and hopped through 2 blogrolls) and I have yet to run across a con­veni­ent method of modi­fy­ing this in an IOS ter­minal session.

Trackbacks

Check out what others are saying about this post...
  1. […] by Aaron Paxson on August 21, 2009 Greg Ferro, Ethereal Mind, pos­ted a great post on how to change the break char­ac­ter on Cisco’s.  This can be handy for folks like me, who always for­get, just because it’s not a usual or […]



Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!