We will learn how to extend the idea of trunking, which is normally used between switches. So, we will learn how to extend the idea of trunking all the way to a router. The reason why we do this is so that we can reduce the number of physical interfaces that we require when we facilitate inter VLAN routing through a router through the creation of logical interfaces, which Cisco calls sub-interfaces, and after understanding the concepts we will proceed to learn how to configure the inter VLAN routing operations on a Cisco router.
To Route Between Different VLANs
The idea of VLAN is to segment a switch into multiple switching partitions called VLANs, and each VLAN is isolated from each other. But, to facilitate inter-VLAN communication, we need to go through a router For the router to route on behalf of a VLAN, it has to have an interface to that VLAN.
So, in example if we have three VLANs therefore, we would need three physical interfaces on the router, each assigned with a unique IP address and connected to the respective VLANs. And, if you have five VLANs, you would need five physical interfaces on the router for inter-VLAN communication, and if you have 100 VLANs, you would need 100 physical interfaces on the router. And finally, if you have 5000 VLANs you would need…? And if your answer is 5000 physical interfaces, you would be incorrect, as the number of VLANs an 802.1Q environment can support is 4096. As you route more VLANs, you would require more physical interfaces on a router. So, is there a better way to facilitate inter-VLAN communication without constantly buying more physical interfaces on a router?
To address the challenge of requiring a lot of physical interfaces on a router to facilitate inter-VLAN communication, the network engineers took the idea of trunking, which is a switch-to-switch connectivity method, and extended it all the way to a router, so that all VLANs now go to the router using one physical interface. That is why we call this kind of routing one-arm routing, or router on a stick, because all routing activities happen on just one interface of a router.
Dividing a Physical Interface into Subinterfaces
For a router to facilitate inter-VLAN communication, it needs one interface to route on behalf of each VLAN. But with the idea of trunking, all the VLANs are connected to the router on one physical interface. So there is only one interface for routing all the VLANs. That would pose a challenge because every VLAN requires an interface on a router to facilitate inter-VLAN communications.
To overcome this challenge, Cisco introduced the idea of subinterfaces, whereby we break the physical interface into a lot of subinterfaces, so that each subinterface is assigned to route on behalf of each VLAN. Each subinterface will route on behalf of a VLAN. This VLAN and subinterface association has to be manually assigned by the network administrator, as there is no automatic association.
Routing Between VLANs with 802.1Q Trunks
In this example, we want to route between VLANs using a 802.1Q trunk link to the Cisco router on fa0/0. So, to facilitate the inter-VLAN communications using a trunk link, we first have to create the appropriate subinterfaces on the fa0/0 interface.
Here, we have created fa0/0.1 and fa0/0.2. It is important to take note that you have to specify the VLAN and subinterface association first before you can add in the IP address. So, using the command encapsulation dot1q, we associate the respective VLAN to the appropriate subinterface. Here, VLAN 1 is associated to fa0/0.1, and VLAN 2 is associated to fa0/0.2. Now, another thing to note is that the VLAN number and the subinterface number do not have to match. And lastly, because 802.1 uses the idea of native VLAN, so we have to explicitly specify on the Cisco router which VLAN is the native VLAN. In this example, we specify that VLAN 1 is the native VLAN by having the native command after the encapsulation.