How To Configure VLAN and interVLAN Routing in Packet Tracer
How To Configure VLAN and interVLAN Routing in Packet Tracer
And just before you configure, have in mind that switch ports could be
either access or trunk.
Switch(config)#int fa0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config-if)#int fa0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config-if)#int fa0/3
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20
Switch(config-if)#int fa0/4
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20
Worth noting: We could have configured all the above interfaces as access ports
using interface range command as shown below:
Switch(config-if)#int range fa0/1-4
Switch(config-if-range)#switchport mode access
In the above commands, we have specified an interface range and then
proceeded to configure all the ports specified as access ports.
4 . Assign static IP addresses to the four PCs which are located in the separate
VLANs. PC1 and PC2 fall in VLAN 10 while PC3 and PC4 fall in VLAN 20.
Ping PC2 from PC1 both in VLAN 10. Ping test should be successful.
Ping PC3 in VLAN 20 from PC1 in VLAN 10. Ping here will definitely fail. Why?
Because inter-VLAN routing is not yet enabled. Hope you can see how we’ve
used VLANs to place the hosts into two logical networks which can be viewed as
separate broadcast domains.
Now, in order to allow the hosts in the two VLANs to communicate, we need to
do something extra. And you can guess what. We’ll configure the router to
permit inter-VLAN communication. Let’s do that right away.
We’ll configure the router so that it will enable communication between the two
vlans via a single physical interface. How is this made possible? We’ll divide the
single physical interface on the router into logical interfaces (sub interfaces).
Each sub-interface will then serve as a default gateway for each of the VLANs.
This scenario is called router on a stick (R.O.A.S) and will allow the VLANs to
communicate through the single physical interface.
Router(config)#int fa0/0
Router(config-if)#no shutdown
Router(config-if)#int fa0/0.10
Router(config-subif)#encapsulation dot1q 10
Router(config-subif)#ip add 192.168.1.1 255.255.255.0
Router(config-subif)#
Router(config-subif)#int fa0/0.20
Router(config-subif)#encapsulation dot1q 20
Router(config-subif)#ip add 192.168.2.1 255.255.255.0
As you can notice from above, the routers physical interface fa0/0 was
subdivided into two sub-interfaces( fa0/0.10 and fa0/0.20) , which are then
configured as trunk interfaces and given IP addresses.
Finally,
6. Test inter-VLAN connectivity.
Ping PC3 in VLAN 20 from PC1 in VLAN 10. If everything is well configured,
then ping should work perfectly.