Show KB ID 0001009 If you have the same configuration that needs to be placed on multiple ports, then doing each one individually can be time consuming. To save time use the ‘interface range‘ command. Be aware this command is only available on devices running IOS versions newer than 12.0(7)XE, Release 12.1 E, and Release 12.1(5)T. Solution1. From configure terminal mode, I want to apply the same configuration to Gigabit Ethernet ports 3 and 4. Note: There is a space each side of the hyphen.
Petes-Switch(config)#interface range GigabitEthernet 0/3 - 4 Petes-Switch(config-if-range)#switchport mode access Petes-Switch(config-if-range)#switchport access vlan 123 Petes-Switch(config-if-range)#exit Petes-Switch(config)# 2. Let’s see if that worked;
Petes-Switch#show run Building configuration... Current configuration : 1888 bytes ! <------------config removed for the sake of brevity------------> ! interface GigabitEthernet0/3 switchport access vlan 123 switchport mode access ! interface GigabitEthernet0/4 switchport access vlan 123 switchport mode access ! <------------config removed for the sake of brevity------------> ! end How To Configure Multiple Cisco ‘Non Contiguous’ Switch Ports1. The process is the same as above, but you separate ranges, (or individual ports) with a comma. Note: There is a space each side of the comma.
Petes-Switch(config)#interface range GigabitEthernet 0/3 - 4 , GigabitEthernet 0/9 - 10 Petes-Switch(config-if-range)#switchport mode access Petes-Switch(config-if-range)#switchport access vlan 123 Petes-Switch(config-if-range)#exit Petes-Switch(config)# 2. Let’s see if that worked;
Petes-Switch#show run Building configuration... Current configuration : 1888 bytes ! <------------config removed for the sake of brevity------------> ! interface GigabitEthernet0/3 switchport access vlan 123 switchport mode access ! interface GigabitEthernet0/4 switchport access vlan 123 switchport mode access ! interface GigabitEthernet0/5 ! <------------config removed for the sake of brevity------------> ! interface GigabitEthernet0/9 switchport access vlan 123 switchport mode access ! interface GigabitEthernet0/10 switchport access vlan 123 switchport mode access ! <------------config removed for the sake of brevity------------> ! end You can use the interface range command with the following interfaces;
Related Articles, References, Credits, or External LinksNA
Just to add to what Mark has posted, you can have up to five parameters which can be handy when you need to skip some ports or deal with more than one line card, e.g.: interface range g1/0/1 - 18 , g1/0/20 - 24 , g3/0/5 - 48 , g5/0/5 , g 7/0/22 - 24 PS: You can also default interfaces using a range statement, e.g.: default interface range g1/0/1 - 18 , g1/0/20 - 24 , g3/0/5 - 48 , g5/0/5 , g 7/0/22 - 24 |