KB ID 0001009
Problem
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.
Solution
1. 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.
[box]
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)#
[/box]
2. Let’s see if that worked;
[box]
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
[/box]
How To Configure Multiple Cisco ‘Non Contiguous’ Switch Ports
1. 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.
[box]
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)#
[/box]
2. Let’s see if that worked;
[box]
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
[/box]
You can use the interface range command with the following interfaces;
- FastEthernet
- GigabitEthernet
- TenGigabitEthernet
- Port-Channel
- VLAN
Related Articles, References, Credits, or External Links
NA