Sub Interface Mode

Configure sub-interfaces on a switch port to support multiple VLANs on a single physical interface, commonly used for router-on-a-stick configurations.

Step 1: Enter the physical interface

1
2
3
4
5
6
7
8
SW1>enable
SW1#configure terminal
SW1(config)#interface gigabitEthernet 0/1
SW1(config-if)#description Trunk to Router
SW1(config-if)#switchport mode trunk
SW1(config-if)#switchport trunk allowed vlan 10,20,30
SW1(config-if)#no shutdown
SW1(config-if)#exit

Step 2: Create sub-interfaces for each VLAN Configure sub-interfaces on the router side to handle inter-VLAN routing. Each sub-interface corresponds to a VLAN.

1
2
3
4
5
6
7
8
R1>enable
R1#configure terminal
R1(config)#interface gigabitEthernet 0/0.10
R1(config-subif)#description VLAN 10 Gateway
R1(config-subif)#encapsulation dot1Q 10
R1(config-subif)#ip address 192.168.10.1 255.255.255.0
R1(config-subif)#no shutdown
R1(config-subif)#exit

Step 3: Configure additional sub-interfaces

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
R1(config)#interface gigabitEthernet 0/0.20
R1(config-subif)#description VLAN 20 Gateway
R1(config-subif)#encapsulation dot1Q 20
R1(config-subif)#ip address 192.168.20.1 255.255.255.0
R1(config-subif)#no shutdown
R1(config-subif)#exit

R1(config)#interface gigabitEthernet 0/0.30
R1(config-subif)#description VLAN 30 Gateway
R1(config-subif)#encapsulation dot1Q 30
R1(config-subif)#ip address 192.168.30.1 255.255.255.0
R1(config-subif)#no shutdown
R1(config-subif)#exit

Step 4: Enable the parent interface

1
2
3
4
R1(config)#interface gigabitEthernet 0/0
R1(config-if)#description Trunk from Switch
R1(config-if)#no shutdown
R1(config-if)#end

Step 5: Verify the configuration

1
2
3
R1#show ip interface brief
R1#show interfaces gigabitEthernet 0/0.10
SW1#show interfaces trunk

Key Points:

  • Sub-interface number doesn’t have to match VLAN ID, but it’s best practice
  • Parent interface must be up for sub-interfaces to function
  • Each sub-interface needs encapsulation dot1Q command with correct VLAN tag
  • Switch port must be configured as trunk with allowed VLANs