Building Network Automation Solutions
6 week online course starting in September 2017

Merging VTY configurations

Someone has sent me an interesting question a while ago: he's changed the configuration of a single VTY line and got three blocks of VTY configuration commands, similar to this:

line vty 0 2
line vty 3
 password secret
line vty 4
He wanted to merge the three configuration blocks back into a single one but somehow didn't know how to do it.

To realize what's going on, you have to understand how the IOS generates line configurations. It takes the first line (VTY 0, for example) and generates its configuration. If the next line (VTY 1) has exactly the same configuration, the range of numbers is expanded (becoming VTY 0 1) and so forth until the pool of similar lines is exhausted or a line is found that has at least one parameter different from the starting one, in which case a new block is started. That's why the sample configuration has three blocks (0-2, 3 and 4) even though the first and the third block are identical.

However, if you change the offending parameter, the VTY lines will have identical configurations and will be automatically merged. If you want to be on the safe side, you should change the parameter for all lines, for example:
line vty 0 4
 password secret

Note: This article is part of You've asked for it series.


  1. This seems to work on most IOS, but I've noticed on Sup720s, 12.2(33)SXH Cisco has added VTY 5 - 15. Even if you standardized all 16 lines, the configuration still displays vty 0-4 and 5-15 separately.

    1. That is for backwards compatibility incase you were to paste the config to an older IOS.


You don't have to log in to post a comment, but please do provide your real name/URL. Anonymous comments might get deleted.