How to Configure Inter VLAN Routing

Introduction

VLAN is defined as a virtual local area network or virtual LAN. VLAN is used to divide the broadcast domain of a switch. By default a switch has multiple collision domains and a single broadcast domain.

There are two types of VLANs, they are:

  • Static VLAN
  • Dynamic VLAN

VTP (VLAN Trucking Protocol)

VTP is defined as VLAN trucking protocol. It is a Cisco proprietary protocol. It is used to manage the inter VLAN communication into a network. Using VTP we can create, delete and modify the network. VTP carries VLAN information to all the switches in a VTP domain. It works with ISL, 802.1q, andIEEE 802.10.

Inter-VLAN Routering

By default one VLAN cannot communicate with another VLAN. To create inter-VLAN communication we need a L3 device like a router or L3 switch. To create inter VLAN routing, we need a make a port trunk port. All VLAN communicate is done with this trunk port.

On the router we create a sub-interface on the router witch is connected with the trunk port of the switch.  All sun interfaces are configured with some encapsulation technique like  ISL or IEEE 802.1q.

Example

In this network we have one switch (L2 switch). In this switch we are creating two the VLANs, VLAN 2 and VLAN 3. VLAN 2 has two computers and has the 192.168.1.0 network. VLAN 3 has three computers and network 192.168.2.0.

VirtualLAN.jpg

Configuration of Switch

Switch>enable
Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#hostname IT
IT(config)#enable secret admin
IT(config)#enable secret ?

  0      Specifies an UNENCRYPTED password will follow
  5      Specifies an ENCRYPTED secret will follow
  LINE   The UNENCRYPTED (cleartext) 'enable' secret
  level  Set exec level password

IT(config)#vlan 2
IT(config-vlan)#name it
IT(config-vlan)#exit

IT(config)#vlan 3
IT(config-vlan)#name hr
IT(config-vlan)#exit

IT(config)#interface fastEthernet 0/2
IT(config-if)#switchport mode access
IT(config-if)#switchport access vlan 2
IT(config-if)#exit

IT(config)#interface fastEthernet 0/3
IT(config-if)#switchport mode access
IT(config-if)#switchport access vlan 2
IT(config-if)#exit

IT(config)#interface fastEthernet 0/11
IT(config-if)#switchport mode access
IT(config-if)#switchport access vlan 3
IT(config-if)#exit

IT(config)#interface fastEthernet 0/12
IT(config-if)#switchport mode access
IT(config-if)#switchport access vlan 3
IT(config-if)#exit

IT(config)#interface fastEthernet 0/13
IT(config-if)#switchport mode access
IT(config-if)#switchport access vlan 3
IT(config-if)#exit

IT(config)#interface vlan 2
IT(config-if)#ip address 192.168.1.1 255.255.255.0
IT(config-if)#no shutdown
IT(config-if)#exit

IT(config)#interface vlan 3

%LINK-5-CHANGED: Interface Vlan3, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to up

IT(config-if)#ip address 192.168.2.1 255.255.255.0
IT(config-if)#no shutdown
IT(config-if)#exit

IT(config)#interface fa
IT(config)#interface fastEthernet 0/1
IT(config-if)#shutdown

%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to administratively down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to down


IT(config-if)#interface fastEthernet 0/1
IT(config-if)#switchport mode access
IT(config-if)#switchport mode trunk

 

Configuration of Router

Router>enable
Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#interface fastEthernet 0/0
Router(config-if)#no shutdown

%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-if)#interface fastEthernet 0/0.1

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

Router(config-subif)#encapsulation dot1Q 1
Router(config-subif)#ip address 192.168.1.1 255.255.255.0
Router(config-subif)#no shutdown
Router(config-subif)#exit

Router(config)#interface fastEthernet 0/0.2

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

Router(config-subif)#encapsulation dot1Q 2
Router(config-subif)#ip address 192.168.2.1 255.255.255.0
Router(config-subif)#no shutdown

 

It shows all VLAN configured on switch

ShowVLAN.jpg

It shows all configuration of router interface

InterVLANCommunication.jpg

It show all interfaces of switch

SwitchInterface.jpg

It show all interfaces of router

InterVlanRouting.jpg


Similar Articles