Defining Encapsulations for VLAN between Router and Switch for Inter-VLANs Routing
Step1: Configue Port on Router for Logically divided an Fast Ethernet Port into 3 VLANs ports
Router(config)#interface FastEthernet0/0 (Enter the Fast Ethernet Port of Router)
Router(config-if)# no ip address (Remove the IP address from the Interface)
Router(config-if)#no shutdown (Give the Interface UP)
Router(config-if)#exit (Exit from the Port)
Router(config)#interface FastEthernet0/0.2 (sub interface for the VLAN 2)
Router(config-subif)# encapsulation dot1Q 2 (IEEE 802.1Q Encapsulation for VLAN 2)
Router(config-if)# ip address 10.1.1.1 255.0.0.0 (IP Address for the VLAN 2)
Router(config)#exit (Exit from the Port)
Router(config)#interface FastEthernet0/0.3 (sub interface for the VLAN 3)
Router(config-subif)# encapsulation dot1Q 3 (IEEE 802.1Q Encapsulation for VLAN 3)
Router(config-subif)# ip address 20.1.1.1 255.0.0.0 (IP Address for the VLAN 3
Router(config-subif)#exit (Exit from the Port)
Router(config-if)#interface FastEthernet0/0.4 (sub interface for the VLAN 4)
Router(config-subif)# encapsulation dot1Q 4 (IEEE 802.1Q Encapsulation for VLAN 4)
Router(config-subif)# ip address 30.1.1.1 255.0.0.0 (IP Address for the VLAN 4)
Router(config-subif)#exit (Exit from the Port)
Step2: Now Create VLANs on The Switch
Switch(config)#vlan 2
Switch(config)#name Sale
Switch(config)#vlan 3
Switch(config)#name Hr
Switch(config)#vlan 4
Switch(config)#name IT
OUTPUT:
Switch#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20
Fa0/21, Fa0/22, Fa0/23, Fa0/24
2 sales active Fa0/1
3 HR active Fa0/2, Fa0/3, Fa0/4, Fa0/5
Fa0/6, Fa0/7, Fa0/8
4 IT active Fa0/9, Fa0/10, Fa0/11, Fa0/12
Step3: Configure Port for Trunk
Switch(config)#interface F0/1
Switch(config-if)#switchport mode trunk
Step4: Now connect Different PC for Acess to VLANs.
PC1: IP address: 10.1.1.2
Subnet Mask: 255.0.0.0
Default Gateway:10.1.1.1
PC2: IP address: 20.1.1.2
Subnet Mask: 255.0.0.0
Default Gateway:20.1.1.1
PC3: IP address: 30.1.1.2
Subnet Mask: 255.0.0.0
Default Gateway:30.1.1.1
Step5: Ping Each Other
On pc1 to pc2 and pc3
ping 10.1.1.2
ping 20.1.1.2
ping 30.1.1.2
You see Each Reply for each ping.