1

I follow a tutorial for creating multi vlans in Cisco Switch, but get bellow errors:

Switch(config)#vlan 21, 22, 25-30 
                    ^
% Invalid input detected at '^' marker.

Switch(config)#vlan 21,22,25-30 
                    ^
% Invalid input detected at '^' marker.

Switch(config)#vlan 21,22

EDIT-01

I use the Cisco Packet Tracer 7.2.0.0226. and the Switch is 2950T-24.

4
  • What software version are using? – user36472 Nov 5 '18 at 6:55
  • I don't think that this is possible. Maybe you saw something related to multiple VLAN assignment for trunk interface, like switchport trunk allowed vlan 1,2,5-10,15,20,22-25 – Andrey Prokhorov Nov 5 '18 at 7:10
  • @AndreyProkhorov I mean I want to create multi VLAN in a Cisco Switch. – three-blocks Nov 5 '18 at 8:10
  • Try surrounding the commas and dashes with spaces. That used to be required. For example, vlan 21 , 22 , 25 - 30. – Ron Maupin Nov 5 '18 at 16:45
3

The VLAN range feature was first integrated into Cisco IOS release 12.1(9)EA1 for the Cisco Catalyst 2950/2955 Series.

Test run on an old Cisco 2950:

Switch(config)#vlan 21,22,25-30
Switch(config-vlan)#
Switch(config-vlan)#no vlan 21,22,25-30
Switch(config)#

Thanks to Marc 'netztier' Luethi.

Documentation page 2-342, section vlan (global configuration): https://www.cisco.com/c/dam/en/us/td/docs/switches/lan/catalyst2955/software/release/12_1_12c_ea1/command/reference/cr2955.pdf

8
  • While I have no old catalyst at hand to cross-check, I find it particular that the document you linked mentions no catalyst switches (which were indeed been available back in 2002), and dont' even mention Layer2 VLANs as such, only 802.1q tagged subinterfaces of routers. The document does not show how to define L2-VLANs by group. – Marc 'netztier' Luethi Nov 5 '18 at 13:58
  • Some of the older switches and IOS actually required spaces before and after the commas and dashes. The configuration templates I have still do that because it will work with both old and new switches. – Ron Maupin Nov 5 '18 at 15:42
  • @Marc'netztier'Luethi the document explains the software train 12.2(13)T and it's features introduced, when it came out. This version was only supported on the Cisco 6400, 7200 and ASR 7401 to begin with, but it explains when Cisco introduced the VLAN range command. I suspect, that all Catalyst series hereafter had the feature added. – user36472 Nov 5 '18 at 16:23
  • @RonMaupin You are very correct, older IOS versions required spaces. – user36472 Nov 5 '18 at 16:24
  • 1
    @Marc'netztier'Luethi i guess you were right then. I'll update my post with your findings. Oh and the page was 2-342, not 2-432. – user36472 Nov 5 '18 at 17:25
3

Multiple VLANs cannot be created in a 1-liner on a classic Catalyst IOS Switch.

But you can prepare a command sequence in your preferred text editor and then copy & paste it into the terminal window ofyour switch (ssh, telnet, console...)

vlan 1
 name MY-VLAN-1

vlan 20
 name THIS-IS-VLAN-20

vlan 30
 name ENGINEERING-VLAN

The "name" line is optional and of almost no technical relevance, but recommended - you'll have to define your own style and guidelines to naming VLANs.


EDIT: Erratum: There is a way to configure multiple VLAN IDs with a 1-liner, separating the list of vlans with commata or defining ranges with hyphens. As other commentators pointed out, older releases need spaces between the numbers and commata or hypens.

See solution as proposed by Cown.


As Andrey has pointed out, manipulating the scope of a given (set) of VLAN(s) can happen in a 1-liner: The switchport trunk allowed vlan command (in interface configuration mode) works with a set of VLANs on a single line.

interface FastEthernet X/Y
 switchport mode trunk
 switchport trunk encapsulation dot1q      ! <-- some platforms still need that one
 switchport nonegotiate                    ! <-- suggested, if you don't run DTP or VTP
 switchport trunk allowed vlan 1,20,30

Adding to that, I strongly suggest to exclusively work with switchport trunk allowed vlan add ... and switchport trunk allowed vlan remove ... from the start. Sooner or later in your networking career, you'll learn why if you don't [1].


[1] It is probably the one classical human factor error in switched networking: to forget the add/remove keywords when "let me just add that new VLAN to to this 802.1q trunk" - which reduces that trunk to just the VLAN you were about to add. Dpending on where this happens, this can bring down an entire network within a few seconds.

2
  • The document linked is for 802.1q tagged subinterfaces for routers, not for catalyst switches. "Supported Platforms" doesn't even mention a switch. – Marc 'netztier' Luethi Nov 5 '18 at 14:26
  • I'll give you a vote tomorrow, i exhausted all my votes for today. – user36472 Nov 5 '18 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.