How to configure the Inter-VLAN Routing model with Cisco Routers and Switches

1.About Inter-VLAN

Inter-VLAN is the most efficient established method by providing a single trunk link between the Switch and the Router that can carry traffic of multiple VLANs and where that traffic can in turn be routed by Router.

With Inter-VLAN Routing, the router receives a frame from the switch with the packet coming from a tagged VLAN. It associates frames with the appropriate subinterfaces and then decodes the contents of the frame (the IP packet portion). The router then performs a Layer 3 function based on the destination network address contained in the IP packet to determine the subinterface to forward the IP packet. The IP packets are now encapsulated in dot1Q (or ISL) frames to identify the VLAN of the forwarding subinterface and travel over the trunk to the switch.

2.Diagram

Details:

We will have the following devices:

  • Router R1 is a device used to route, allocate DHCP, VLAN.
  • Switch Core is a device used to distribute IPs and VLANs down to computers.
  • 3 devices named PC1, PC2, PC3 running Windows 7.

3.Scenario

We will configure the sub interface, DHCP, VLAN on the Router and Switch devices so that when the connected computers will receive the correct IP from the VLAN according to the network diagram.

4.What to do

Router:

  • Configure sub interface and set IP.
  • Configure DHCP Pool and routing between VLANs.

Switch:

  • Create VLANs and assign ports to VLANs.
  • Implement trunk port.

Result.

5.Configuration

5.1.Router

5.1.1.Configure sub interface and set IP.

As the network diagram we have 3 VLANs 10,20,30 so we will need to create 3 sub interfaces and set the IP for it according to the network diagram.

To create sub interface for VLAN 10 we use the following command.

Router(config)#interface gigabitEthernet 0/0.10

Router(config-subif)#encapsulation dot1Q 10

Router(config-subif)#ip address 10.145.41.254 255.255.255.0

Similarly, we will also create sub interfaces for VLAN 20 and VLAN 30 as follows.

VLAN 20.

Router(config)#interface gigabitEthernet 0/0.20

Router(config-subif)#encapsulation dot1Q 20

Router(config-subif)#ip address 10.145.42.254 255.255.255.0

VLAN 30.

Router(config)#interface gigabitEthernet 0/0.30

Router(config-subif)#encapsulation dot1Q 30

Router(config-subif)#ip address 10.145.43.254 255.255.255.0

Router(config-subif)#no shutdown

Finally for the sub interfaces to work we need to enter the Gi0/0 physical port and turn it on with the following command.

Router(config)#interface gigabitEthernet 0/0

Router(config-if)#no shutdown

Router(config-if)#

*Oct  9 18:54:40.466: %LINK-3-UPDOWN: Interface GigabitEthernet0/0, changed state to up

*Oct  9 18:54:41.466: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up

5.1.2.Configure DHCP Pool and routing between VLANs

Next we need to create a DHCP Pool so that when computers connect to it, they will automatically receive IPs.

We will create a DHCP Pool for VLAN 10 with the following command.

Router(config)#ip dhcp pool VLAN10

Router(dhcp-config)#network 10.145.41.0 255.255.255.0

Router(dhcp-config)#default-router 10.145.41.254

Similar to VLAN 10 we will create a DHCP Pool for VLANs 20 and 30 as follows.

VLAN 20.

Router(config)#ip dhcp pool VLAN20

Router(dhcp-config)#network 10.145.42.0 255.255.255.0

Router(dhcp-config)#default-router 10.145.42.254

VLAN 30.

Router(config)#ip dhcp pool VLAN30

Router(dhcp-config)#network 10.145.43.0 255.255.255.0

Router(dhcp-config)#default-router 10.145.43.254

Next, for VLANs to communicate with each other, we need to execute the following command.

Router(config)#ip routing

5.2.Switch

5.2.1.Create VLANs and assign ports to VLANs

We will create VLAN 10, 20, 30 and assign the ports to the correct VLAN according to the network diagram.

Create VLAN 10 and assign port Gi0/1 with the following command.

Switch(config)#vlan 10

Switch(config-vlan)#exit

Switch(config)#interface gigabitEthernet 0/1

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 10

Switch(config-if)#no shutdown

Similar to creating VLAN 10 and assigning port Gi0/2 with the following command.

Switch(config)#vlan 20

Switch(config-vlan)#interface gigabitEthernet 0/2

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 20

Switch(config-if)#no shutdown

Similarly create VLAN 30 and assign port Gi0/3 with the following command.

Switch(config)#vlan 30

Switch(config-vlan)#exit

Switch(config)#interface gigabitEthernet 0/3

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 30

Switch(config-if)#no shutdown

5.2.2.Implement trunk port

We will configure trunk for Gi0/0 port with the following command.

Switch(config)#interface gigabitEthernet 0/0

Switch(config-if)#switchport trunk encapsulation dot1Q

Switch(config-if)#switchport mode trunk

Switch(config-if)#no shutdown

5.3.Result.

PC 1 received the IP from the DHCP Pool of VLAN 10.

Similarly, PC 2 and PC 3 also receive IPs from the DHCP Pool of VLAN 20 and VLAN 30.

We will test the communication between VLANs by pinging between computers PC 1, PC 2 and PC 3.

Ping result from PC 3 to PC 2.

Ping result from PC 1 to PC 2.

Ping result from PC 1 to PC 3.

The results show that computers in different VLANs can communicate with each other.

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.