How to Configure VLAN in Cisco Layer 2 Switch in GNS3

In this article, we will create VLAN and configure Inter-VLAN routing on the Cisco L2 Switch using the Graphical Network Simulator program.

Configuring VLAN in Cisco Layer 2 Switch in GNS3

How to Create a VLAN on a Cisco Switch

With GNS3, you can make more specific network designs. Also, with Dynamips, you can create a proper network topology using the IOS images of the Cisco Router or Cisco Switch devices.

While designing the network in GNS3, we were integrating virtual machines running on VMware Workstation as a client computer. In this article, we will use VPCS (Virtual PC Simulator) instead of a virtual machine.

You can make your computer work more efficiently with VPCS, as virtual machines will create a load on your computer.

But remember that you need to use virtual computers in different scenarios.

In our previous articles, we have studied how to add Layer 2 Switch. In this article, we will examine how to create a VLAN on an L2 Switch in GNS3.

How to Add VLAN in Switch and Configure Inter-VLAN Routing in Router

In this article, we will discuss the following steps;

  1. Assigning IP Address to VPCS
  2. Creating a VLAN
  3. Determination of Switch Trunk Ports
  4. Trunking Between Switches
  5. Cisco Router Inter-VLAN Configuration

Step 1

To configure VLAN in GNS3, first, add one Cisco Router to the workspace.

Add a Cisco Router to the GNS3 Workspace

Step 2

Add Layer 2 Switch and 2 VPCS computers to the workspace.

Adding VPCS

Step 3

Add another Layer 2 Switch and VPCS.

Adding Cisco Switch

Step 4

Right-click / configure on the Layer 2 Switch. In the window that opens, increase the amount of RAM for the Switch. Since the L2 Switch is Qemu-based, boot problems with low RAM may occur.

Set the Cisco L2 Switch RAM to 400 MB and then click the Network tab.

Increasing the RAM of the Switch

Step 5

On the Network tab, set the number of Adapters to 4 to add an interface to the Switch.

Adding a Network Adapter to a Switch

Step 6

Since we will use two interfaces on Switch-2, 300 MB RAM is enough.

Increasing the RAM of the Switch

Step 7

Add 2 interfaces from the Network tab.

Adding an Interface to a Switch

Step 8

After performing the above steps, click the wiring option and then wiring all devices in the work area.

Cabling All Devices in the Workspace

Step 9

The latest status of the network topology is as in the following image. After you determine the VLANs on the network topology, you must configure the TCP/IP settings for the VPCSs.

Then, after making a Trunk connection between Cisco Switches, you must configure the connection between R1 and SW1 as a Trunk.

Now, double-click to assign an IP address to the VPCS PC1.

Running All Nodes

Step 10

Type the following command to assign an IP address to PC1 and press Enter. To view the IP configuration, use the show ip command.

ip 192.168.5.5/24 192.168.5.1

ip 192.168.5.5/24 192.168.5.1

Step 11

Execute the following command to assign the IP address to the VPCS PC2.

The critical point here is to take steps according to the notes on the network topology.

Since PC2 will be a member of VLAN10, the IP address will be different.

ip 192.168.10.10/24 192.168.10.1

ip 192.168.10.10/24 192.168.10.1

Step 12

Configure the IP address settings for VPCS PC3, which will be members of VLAN5, as follows:

ip 192.168.5.10/24 192.168.5.1

ip 192.168.5.10/24 192.168.5.1

Step 13

Click on Layer 2 Switch-1 and Layer 2 Switch-2 to configure Cisco Switches.

Switch CLI Command Prompt

Step 14

Follow the instructions below to create a VLAN on the switches.

L2 Switch-1

vIOS-L2-01# conf t
vIOS-L2-01(config)# vlan 5
vIOS-L2-01(config-vlan)# name IT
vIOS-L2-01(config-vlan)# exit
vIOS-L2-01(config)# vlan 10
vIOS-L2-01(config-vlan)# name SALES
vIOS-L2-01(config-vlan)# exit
vIOS-L2-01(config)# end
vIOS-L2-01# wr

L2 Switch-2

vIOS-L2-01# conf t
vIOS-L2-01(config)# vlan 5
vIOS-L2-01(config-vlan)# name IT
vIOS-L2-01(config-vlan)# exit
vIOS-L2-01(config)# end
vIOS-L2-01# wr

Creating VLANs on Cisco Switches

Step 15

You must configure the L2 Switch interfaces. Configure the interfaces connected to the Cisco Router and L2 Switch as Trunk.

Use the following commands to determine the Access and Trunk interfaces of the Layer 2 Switch and to make PCs a member of VLANs.

vIOS-L2-01(config)#interface gigabitethernet 0/1
vIOS-L2-01(config-if)#switchport mode access
vIOS-L2-01(config-if)#switchport access vlan 5
vIOS-L2-01(config-if)#exit
vIOS-L2-01(config)#
vIOS-L2-01(config)#interface gigabitethernet 0/2
vIOS-L2-01(config-if)#switchport mode access
vIOS-L2-01(config-if)#switchport access vlan 10
vIOS-L2-01(config-if)#exit
vIOS-L2-01(config)#
vIOS-L2-01(config)#interface gigabitethernet 0/3
vIOS-L2-01(config-if)#switchport trunk encapsulation dot1q
vIOS-L2-01(config-if)#switchport mode trunk
vIOS-L2-01(config-if)#exit
vIOS-L2-01(config)#
vIOS-L2-01(config)#interface gigabitethernet 0/0
vIOS-L2-01(config-if)#switchport trunk encapsulation dot1q
vIOS-L2-01(config-if)#switchport mode trunk
vIOS-L2-01(config-if)#exit
vIOS-L2-01(config)#exit

switchport mode trunk

Step 16

Use the following commands to perform the same operations on Cisco Layer 2 Switch-2.

vIOS-L2-01# conf t
vIOS-L2-01(config)#interface gigabitethernet 0/1
vIOS-L2-01(config-if)#switchport mode access
vIOS-L2-01(config-if)#switchport access vlan 5
vIOS-L2-01(config-if)#exit
vIOS-L2-01(config)#
vIOS-L2-01(config)#interface gigabitethernet 0/0
vIOS-L2-01(config-if)#switchport trunk encapsulation dot1q
vIOS-L2-01(config-if)#switchport mode trunk
vIOS-L2-01(config-if)#end
vIOS-L2-01#wr

switchport mode access

Step 17

Up to this step, we have configured VPCS computers and created VLANs. Then, we assigned the PCs to VLANs and made the Trunking connection.

In this step, open the command prompt by clicking R1 in the workspace to perform VLAN routing on a single cable on the Cisco Router and perform the following commands.

R1# conf t
R1(config)#interface fastethernet 0/0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#
R1(config)#interface fastethernet 0/0.5
R1(config-subif)#encapsulation dot1q 5
R1(config-subif)#ip address 19
*Mar 1 00:09:18.259: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
R1(config-subif)#ip address 192.168.5.1 255.255.255.0
R1(config-subif)#no shutdown
R1(config-subif)#exit
R1(config)#
R1(config)#interface fastethernet 0/0.10
R1(config-subif)#encapsulation dot1q 10
R1(config-subif)#ip address 192.168.10.1 255.255.255.0
R1(config-subif)#no shutdown
R1(config-subif)#end
R1#wr

R1(config)#interface fastethernet 0/0.10

Step 18

Now, ping the PC2 to the V2 member PC2 and test the connection. Check that the routing between VLANs is working correctly.

Testing VLANs

Step 19

When you ping from PC2 to PCs that are members of VLAN5, you can see that the process is successful.

Ping from PC2 to VLAN5

Step 20

Likewise, PC3 and VLAN10 will establish a healthy connection.

Ping from PC3 to VLAN10

Show Commands

PC1> ip 192.168.5.5/24 192.168.5.1
Checking for duplicate address...
PC1 : 192.168.5.5 255.255.255.0 gateway 192.168.5.1

PC1> show ip

NAME : PC1[1]
IP/MASK : 192.168.5.5/24
GATEWAY : 192.168.5.1
DNS :
MAC : 00:50:79:66:68:00
LPORT : 10003
RHOST:PORT : 127.0.0.1:10002
MTU: : 1500

PC1>

 

PC2> ip 192.168.10.10/24 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.10 255.255.255.0 gateway 192.168.10.1

PC2> show ip

NAME : PC2[1]
IP/MASK : 192.168.10.10/24
GATEWAY : 192.168.10.1
DNS :
MAC : 00:50:79:66:68:01
LPORT : 10005
RHOST:PORT : 127.0.0.1:10004
MTU: : 1500

PC2>

 

PC3> ip 192.168.5.10/24 192.168.5.1
Checking for duplicate address...
PC1 : 192.168.5.10 255.255.255.0 gateway 192.168.5.1

PC3> show ip

NAME : PC3[1]
IP/MASK : 192.168.5.10/24
GATEWAY : 192.168.5.1
DNS :
MAC : 00:50:79:66:68:02
LPORT : 10007
RHOST:PORT : 127.0.0.1:10006
MTU: : 1500

PC3>

 

vIOS-L2-01#show vlan brief

VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active
5 IT active Gi0/1
10 SALES active Gi0/2
100 VLAN100 active
200 VLAN0200 active
300 VLAN0300 active
1002 fddi-default act/unsup
1003 trcrf-default act/unsup
1004 fddinet-default act/unsup
1005 trbrf-default act/unsup

 

vIOS-L2-01#show vlan brief

VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active
5 IT active Gi0/1
100 VLAN100 active
200 VLAN0200 active
300 VLAN0300 active
1002 fddi-default act/unsup
1003 trcrf-default act/unsup
1004 fddinet-default act/unsup
1005 trbrf-default act/unsup
vIOS-L2-01#

 

vIOS-L2-01#show running-config
Building configuration...

Current configuration : 5125 bytes
!
! Last configuration change at 06:26:58 UTC Mon May 15 2017
!
version 15.0
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
service compress-config
!
hostname vIOS-L2-01
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
!
!
!
vtp domain CISCO-vIOS
vtp mode transparent
!
!
!
ip cef
no ipv6 cef
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
vlan internal allocation policy ascending
!
vlan 5
name IT
!
vlan 10
name SALES
!
vlan 100
name VLAN100
!
vlan 200,300
!
!
!
!
!
interface GigabitEthernet0/0
switchport trunk encapsulation dot1q
switchport mode trunk
media-type rj45
negotiation auto
!
interface GigabitEthernet0/1
switchport access vlan 5
media-type rj45
negotiation auto
!
interface GigabitEthernet0/2
switchport access vlan 10
media-type rj45
negotiation auto
!
interface GigabitEthernet0/3
switchport trunk encapsulation dot1q
switchport mode trunk
media-type rj45
negotiation auto
!
ip forward-protocol nd
!
no ip http server
no ip http secure-server
!
!
!
line con 0
logging synchronous
line aux 0
line vty 0 4
logging synchronous
login
line vty 5 15
logging synchronous
login
!
!
end

vIOS-L2-01#

 

vIOS-L2-01#show running-config
Building configuration...

Current configuration : 4883 bytes
!
! Last configuration change at 06:30:23 UTC Mon May 15 2017
!
version 15.0
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
service compress-config
!
hostname vIOS-L2-01
!
boot-start-marker
boot-end-marker
!
!
!
no aaa new-model
!
!
!
vtp domain CISCO-vIOS
vtp mode transparent
!
!
!
ip cef
no ipv6 cef
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
vlan internal allocation policy ascending
!
vlan 5
name IT
!
vlan 100
name VLAN100
!
vlan 200,300
!
!
!
interface GigabitEthernet0/0
switchport trunk encapsulation dot1q
switchport mode trunk
media-type rj45
negotiation auto
!
interface GigabitEthernet0/1
switchport access vlan 5
media-type rj45
negotiation auto
!
ip forward-protocol nd
!
no ip http server
no ip http secure-server
!
!
!
line con 0
logging synchronous
line aux 0
line vty 0 4
logging synchronous
login
line vty 5 15
logging synchronous
login
!
!
end

vIOS-L2-01#

 

vIOS-L2-01#show interfaces trunk

Port Mode Encapsulation Status Native vlan
Gi0/0 on 802.1q trunking 1
Gi0/3 on 802.1q trunking 1

Port Vlans allowed on trunk
Gi0/0 1-4094
Gi0/3 1-4094

Port Vlans allowed and active in management domain
Gi0/0 1,5,10,100,200,300
Gi0/3 1,5,10,100,200,300

Port Vlans in spanning tree forwarding state and not pruned
Gi0/0 1,5,10,100,200,300
Gi0/3 1,5,10,100,200,300
vIOS-L2-01#

 

vIOS-L2-01#show interfaces trunk

Port Mode Encapsulation Status Native vlan
Gi0/0 on 802.1q trunking 1

Port Vlans allowed on trunk
Gi0/0 1-4094

Port Vlans allowed and active in management domain
Gi0/0 1,5,100,200,300

Port Vlans in spanning tree forwarding state and not pruned
Gi0/0 1,5,100,200,300
vIOS-L2-01#

 

R1#show running-config
Building configuration...

Current configuration : 1149 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
no ip icmp rate-limit unreachable
ip cef
!
!
!
!
no ip domain lookup
ip auth-proxy max-nodata-conns 3
ip admission max-nodata-conns 3
!
!
!
!
ip tcp synwait-time 5
!
!
!
!
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
!
interface FastEthernet0/0.5
encapsulation dot1Q 5
ip address 192.168.5.1 255.255.255.0
!
interface FastEthernet0/0.10
encapsulation dot1Q 10
ip address 192.168.10.1 255.255.255.0
!
interface Serial0/0
no ip address
shutdown
clock rate 2000000
!
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
!
ip forward-protocol nd
!
!
no ip http server
no ip http secure-server
!
no cdp log mismatch duplex
!
!
!
control-plane
!
!
!
gatekeeper
shutdown
!
!
line con 0
exec-timeout 0 0
privilege level 15
logging synchronous
line aux 0
exec-timeout 0 0
privilege level 15
logging synchronous
line vty 0 4
login
!
!
end

R1#

 

How to Enable VLAN ⇒ Video

You can watch the video below to enable VLAN step by step and also subscribe to our YouTube channel to support us!

Conclusion

In this article, we created a virtual LAN in an L2 Switch with a GNS3 simulator and routed VLANs through a Cisco router. Thanks for following us!

2 Comments

Add a Comment

Your email address will not be published. Required fields are marked *