A subinterface is a virtual interface created by dividing one physical interface into multiple logical interfaces. A sub-interface in a Cisco Router uses the parent physical interface for sending and receiving data.
Subinterfaces are used for a variety of purposes. If we have one Router with one physical interface, but needed to have the router connected to two IP networks to route traffic between two routers, we can create two sub interfaces within the physical interface, assign each sub interface an IP address within each subnet and then route the data between two subnets.
We use Subinterfaces for inter VLAN traffic routing by using a Router-on-a-Stick configuration, NBMA (Non Broadcast Multiple Access) WAN solutions like frame-relay or ATM etc.
A Subinterface can be configured just like a physical interface. If you take the help from Cisco IOS using question mark, we can see the number range which be can used to create subinterfaces.
R1(config)#interface fastEthernet 0/0.? <0-4294967295> FastEthernet interface number
To create a subinterface and configure it with an IP address, use the following commands.
To bring the physical interface from Administrativly down state to up, first go to the physical interface and issue “no shutdown” command as shown below.
R1>enable R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R1(config)#interface fastethernet 0/0 R1(config-if)#no shutdown R1(config-if)#exit R1(config)#exit R1#
Now create and configure a sub interface as shown below. In below configuration example the encapulation is set to IEEE 802.1q for Inter-VLAN routing for VLAN 100.
R1>enable R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R1(config)#interface fastethernet 0/0.100 R1(config-subif)#encapsulation dot1Q 100 R1(config-subif)#ip address 172.16.100.1 255.255.255.0 R1(config-subif)#exit R1(config)#exit R1#