When you want to establish communication between different VLANs you will need a device that can do routing. You could use an external router with separate physical gateways or sub-interface (router on stick) method but it’s also possible to use a multilayer switch.

The router must have a physical or logical connection to each VLAN so that it can forward packets between VLANs.





Let’s see the first method router with separate physical gateways:-





Topology:

Goal:





configure the topology as per our diagram and the assign the IP addresses.

create VLAN 101 sales and VLAN 102 marketing and assign the interfaces to their VLAN as per the diagram







Router(config-if)#ip address 192.168.10.1 255.255.255.0

Router(config-if)#no shutdown

Router(config-if)#exit



%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up



Router(config)#interface fastEthernet 0/1

Router(config-if)#ip address 192.168.20.1 255.255.255.0

Router(config-if)#no shutdown

Router(config-if)#exit



%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up



Router#show ip interface brief

Interface IP-Address OK? Method Status Protocol



FastEthernet0/0 192.168.10.1 YES manual up up

FastEthernet 192.168.20.1 YES manual up up



Switch(config)#vlan 101 Router(config)#interface fastEthernet 0/0Router(config-if)#ip address 192.168.10.1 255.255.255.0Router(config-if)#no shutdownRouter(config-if)#exitRouter(config)#interface fastEthernet 0/1Router(config-if)#ip address 192.168.20.1 255.255.255.0Router(config-if)#no shutdownRouter(config-if)#exitRouter#show ip interface briefInterface IP-Address OK? Method Status ProtocolFastEthernet0/0 192.168.10.1 YES manual up upFastEthernet 192.168.20.1 YES manual up upSwitch(config)#vlan 101

FROM HOST 1

FROM HOST 4

configure the topology as per the diagram and assign the IP addresses

configure VLAN 101 and VLAN 102

assign the port to their respective VLANs

configure sub-interfaces on router fast Ethernet 0/0 assign IP address as per the topology

ensure the connectivity between VLAN 101 and VLAN 102, make sure HOST 1 (VLAN 101) IS able to ping HOST 4 (VLAN 102).

from host 1

from host 4

switch virtual interface (SVI)

configure the topology as per the diagram and assign the IP address as per the topology

configure VLAN 111, VLAN 122 and assign the port into their VLANs respectively

configure the IP address on multilayer switch

Switch(config-vlan)#name sales

Switch(config-vlan)#exit



Switch(config)#vlan 122

Switch(config-vlan)#name marketing

Switch(config-vlan)#exit

from host 2

from host 4

Switch(config-vlan)#name salesSwitch(config-vlan)#exitSwitch(config)#vlan 102Switch(config-vlan)#name marketingSwitch(config-vlan)#exitSwitch(config)#interface range fastEthernet 0/1-2Switch(config-if-range)#switchport mode accessSwitch(config-if-range)#switchport access vlan 101Switch(config-if-range)#exitSwitch(config)#interface range fastEthernet 0/3-4Switch(config-if-range)#switchport mode accessSwitch(config-if-range)#switchport access vlan 102Switch(config-if-range)#exitSwitch(config)#interface fastEthernet 0/5Switch(config-if)#switchport mode accessSwitch(config-if)#switchport access vlan 101Switch(config-if)#exitSwitch(config)#interface fastEthernet 0/6Switch(config-if)#switchport mode accessSwitch(config-if)#switchport access vlan 102Switch(config-if)#exitlets see from HOST 4A router on stick can be used to route between VLANs using either ISL or IEEE 801.1Q as the trunking protocol. its requires sub-interface for each respective VLAN.NOTE: whatever is your VLAN number its should be exact on sub-interface.Let see the configuration using sub-interface (router on stick)Topology:-Goal:Switch(config)#vlan 101Switch(config-vlan)#name salesSwitch(config-vlan)#exitSwitch(config)#vlan 102Switch(config-vlan)#name marketingSwitch(config-vlan)#exitSwitch(config)#interface range fastEthernet 0/1-2Switch(config-if-range)#switchport mode accessSwitch(config-if-range)#switchport access vlan 101Switch(config-if-range)#exitSwitch(config)#interface range fastEthernet 0/3-4Switch(config-if-range)#switchport mode accessSwitch(config-if-range)#switchport access vlan 102Switch(config-if-range)#exitSwitch(config)#interface fastEthernet 0/5Switch(config-if)#switchport trunk encapsulation dot1qSwitch(config-if)#switchport trunk allowed vlan 101,102Switch(config-if)#exitRouter(config)#interface fastEthernet 0/0Router(config-if)#no shutdownRouter(config-if)#exitRouter(config)#interface fastEthernet 0/0.101Router(config-subif)#encapsulation dot1Q 101Router(config-subif)#ip address 192.168.10.1 255.255.255.0Router(config-subif)#exitRouter(config)#interface fastEthernet 0/0.102Router(config-subif)#encapsulation dot1Q 102Router(config-subif)#ip address 192.168.20.1 255.255.255.0Router(config-subif)#exit%LINK-5-CHANGED: Interface FastEthernet0/0.102, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.102, changed state to upRouter#show ip interface briefInterface IP-Address OK? Method Status ProtocolFastEthernet0/0 unassigned YES manual up upFastEthernet0/0.101 192.168.10.1 YES manual up upFastEthernet0/0.102 192.168.20.1 YES manual up uplet see the third method , inter-VLAN routing using multi-layer switchswitch virtual interface (SVI).NOTE: to enable routing on multi-layer switch is command use IP ROUTING.Topology:-Goal:Switch(config)#vlan 111Switch(config)#interface range fastEthernet 0/1-2Switch(config-if-range)#switchport access vlan 111Switch(config-if-range)#exitSwitch(config)#interface range fastEthernet 0/3-4Switch(config-if-range)#switchport mode accessSwitch(config-if-range)#switchport access vlan 122Switch(config-if-range)#exitSwitch(config)#ip routingSwitch(config)#interface vlan 111Switch(config-if)#ip address 192.168.10.1 255.255.255.0Switch(config-if)#no shutdown%LINK-5-CHANGED: Interface Vlan111, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan111, changed state to upSwitch(config-if)#exitSwitch(config)#interface vlan 122Switch(config-if)#ip address 192.168.20.1 255.255.255.0Switch(config-if)#no shutdownSwitch(config-if)#exitSwitch(config)#end%LINK-5-CHANGED: Interface Vlan122, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan122, changed state to upSwitch#show ip interface briefInterface IP-Address OK? Method Status ProtocolVlan111 192.168.10.1 YES manual up upVlan122 192.168.20.1 YES manual up uplet see the connectivity between both the VLANs.