VLAN Interfaces are required in network scenarios where you have different VLANs and need Inter-VLAN switching on Layer3 (Routing capable) switches. Every VLAN that needs to be routed should have a VLAN interface.
Let’s say we have VLAN 10 which hosts the subnet 192.168.10.0 subnet, VLAN hosts 192.168.20.0 subnet and VLAN 30 hosts 192.168.30.0 subnet. For Inter-VLAN routing to work, we need to have a VLAN interface setup for each of these VLANs and configured with an IP address from the same subnet which will be the default Gateway for that subnet. Lets say, 192.168.10.254,192.168.20.254.192.168.30.254 are the IP addresses for VLAN Interfaces of VLAn 10,20,30 respectively.
Assuming the VLANs are configured already, let’s proceed to get the VLAN interfaces created.
Enable Routing on the Switch
ciscoswitch# conf t ciscoswitch(config)# ip routing
Add VLAN Interface
ciscoswitch(config)# interface vlan10 ciscoswitch(config-if)# no shut ciscoswitch(config-if)# ip address 192.168.10.0 255.255.255.0
This configures a VLAN interface for VLAN 10.
Default Route on Switch
Add a default route on the Switch. This will forward all traffic from the different VLANs to the default router.
ciscoswitch(config)#ip route 0.0.0.0 0.0.0.0 192.168.100.1
Interface to the Router
If the switch cannot reach the default router through a VLAN then an interface that connects to the router which does these routing needs to configured as a routed interface and assigned with an IP address that is in the same subnet as that of the Default router.
ciscoswitch(config)# interface gi0/1 ciscoswitch(config-if)# no shut ciscoswitch(config-if)# no switchport ciscoswitch(config-if)# ip address 192.168.100.2 255.255.255.0
This makes the interface as a routed interface and assigns an IP address in the same subnet as the default router.