What is a VLAN?
A VLAN is a virtual LAN. In technical terms, a VLAN is a broadcast domain created by switches. Normally, it is a router creating that broadcast domain. With VLAN’s, a switch can create the broadcast domain.
How can devices on different VLAN’s communicate?
Devices on different VLAN’s can communicate with a router or a Layer 3 switch. As each VLAN is its own subnet, a router or Layer 3 switch must be used to route between the subnets.
What is a trunk port?
When there is a link between two switches or a router and a switch that carries the traffic of more than one VLAN, that port is a trunk port.
How to create a VLAN?
According to above network , it used 1841 Router , 2950-24 switch and Pc s.
First of all you can configure switch .
Switch>enable
Switch#config t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2 // Create vlan and give vlan id
Switch(config-vlan)#name VLAN2 // You can assign vlan name as VLAN2
Switch(config-vlan)#exit
Switch(config)#vlan 3 //Create vlan and give vlan id
Switch(config-vlan)#name VLAN3 //You can assign vlan name as VLAN3
Switch(config-vlan)#exit
Switch(config)#
Switch#config t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2 // Create vlan and give vlan id
Switch(config-vlan)#name VLAN2 // You can assign vlan name as VLAN2
Switch(config-vlan)#exit
Switch(config)#vlan 3 //Create vlan and give vlan id
Switch(config-vlan)#name VLAN3 //You can assign vlan name as VLAN3
Switch(config-vlan)#exit
Switch(config)#
According to this network you can create 3 vlan networks .
vlan 1 is the default vlan .
After creating vlans you must assign PC s to specific vlans .
Switch(config)#interface fa0/2 // PC 0 is assign in interface fastEthernet 0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2 // assign PC 0 to vlan 2
Switch(config-if)#
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2 // assign PC 0 to vlan 2
Switch(config-if)#
Same as this you must assign other PC s to each vlans.
Network address of
vlan 1 - 192.168.10.0
vlan 2 - 192.168.20.0
vlan 3 - 192.168.30.0
When we move to Router configuration we must assign sub network for 3 vlans .
Router>enable
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface fastEthernet 0/0.1 // by giving 0/0.1 it creates sub network
Router(config-subif)#encapsulation dot1Q 1 // select vlan1
Router#config t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface fastEthernet 0/0.1 // by giving 0/0.1 it creates sub network
Router(config-subif)#encapsulation dot1Q 1 // select vlan1
Router(config-subif)#ip address 192.168.10.1 255.255.255.0 // assign ip address for vlan 1
Router(config-subif)#exit
Router(config)#
Router(config-subif)#exit
Router(config)#
encapsulation dot1Q
Use
Allows you to use a router interface as a trunk port to a switch. This is also known as "Router on a stick" because the switch uses the router to route between VLANs.
Same as vlan 1 we must configure other two vlans .
Configure trunk port
Then you must configure trunk port of switch .
Switch(config)#
Switch(config)#interface fastEthernet 0/1 // go to interface mode of the fast Ethernet port of switch (which connected to router)
Switch(config-if)#switchport trunk allowed vlan add 2 // add vlan 2 for switchport trunk .
Switch(config-if)#
Switch(config)#interface fastEthernet 0/1 // go to interface mode of the fast Ethernet port of switch (which connected to router)
Switch(config-if)#switchport trunk allowed vlan add 2 // add vlan 2 for switchport trunk .
Switch(config-if)#
You can ping between different vlans or in same LAN .