Inter vlan routing on gns3 | Router on stick configuration





Network devices in different VLANs cannot communicate with one another without a router to route traffic between the VLANs. In most network environments, VLANs are associated with individual networks or subnetworks. There are two ways to communicate different VLANs with each other.
      1. Inter vlan 
      2. Switch virtual interface SVI 

How inter VLAN works: 

Inter VLAN communicate different VLANs via sub interfaces that we have create on router for each VLANs. When Host A in VLAN 10 needs to communicate with Host B in VLAN 10, it sends a packet addressed to that host. Switch A forwards the packet directly to Host B, without sending it to the router.
When Host A in VLAN 10 sends a packet to Host B in VLAN 20, Switch forwards the packet to the router, which receives the traffic on the VLAN 10 interface sub interface and forwards this to sub interface for VLAN 20.
To implement interVLAN on gns3 I use the follow simple topology. In which R1 have two sub interfaces int f0/0.10 and int f0/0.20 for VLANs 10 and 20 respectively. And we use only two PC, one belong to VLAN 10 and other to 20.   

 
Configuration for Router R1:

R2(config)#interface f0/0
R2(config-if)#no shutdown
R2(config-subif)#interface f0/0.20
R2(config-subif)#encapsulation dot1Q 20
R2(config-subif)#ip address 20.1.1.1 255.255.255.0
R2(config-subif)#interface f0/0.10
R2(config-subif)#encapsulation dot1Q 10
R2(config-subif)#ip address 10.1.1.1 255.255.255.0

Configuration for Switch:

SW#vlan database
SW(vlan)#vlan 10 name office1
SW(vlan)#vlan 20 name office2
SW(vlan)#exit
SW(config)#interface f1/0
SW(config-if)#no shutdown
SW(config-if)#switchport mode trunk
SW(config-if)#interface f0/0
SW(config-if)#no shutdown
SW(config-if)# switchport mode access
SW(config-if)# switchport access vlan 10
SW(config-if)#interface f0/1
SW(config-if)#no shutdown
SW(config-if)#switchport mode access
SW(config-if)# switchport access vlan 20



Configuration for Qemu1

tc@box:$ sudo su 
root@box:$ Ifconfig eth0 10.1.1.2 netmask 255.255.255.0
root@box:$ Route add default gw 10.1.1.1 eth0

Configuration for Qemu2

tc@box:$ sudo su 
root@box:$ Ifconfig eth0 20.1.1.2 netmask 255.255.255.0
root@box:$ Route add default gw 20.1.1.1 eth0

Results:
Ping from qemu1 to qemu2 is successful and voice versa



Router on stick in Packet Tracer

To learn How Switch virtual interface SVI  works: Visit next Post.

Thanks.

    10 comments:

    1. Heloo after configuring vlans, i do a 'show vlans' and it says no vlans configured

      ReplyDelete
    2. try "show vlan-switch" instead of show vlan....

      ReplyDelete
    3. I sometimes prefer a VLAN configuration since it can save space in the office.

      ReplyDelete
    4. Hi, I´m trying to configure the above scenario but when I get to the f1/0 link between switch and router there is no switchport command available to set it up. Did i miss anything ? btw I´m using the 3640 ios for switch.

      ReplyDelete
    5. I was trying to configure VLAN with switch and Router. I have used VLAN 1 and 2 and successfully configured VLAN in switch. But I can't configure VLAN in Router.

      "interface fastethernet 0/1.1
      ^
      %invalid inpute detected"


      IP address of VPCs - 192.168.1.1/24 and 192.168.2.1/24

      ReplyDelete
    6. Hi, I´m trying to make this scenario on GNS3 1.4 but when drag switch and connect cable to pc from switch and from switch to router then i make ping from pc to router doesn't work

      ReplyDelete
    7. I am facing the same problem
      Hi, I´m trying to configure the above scenario but when I get to the f1/0 link between switch and router there is no switchport command available to set it up. Did i miss anything ? btw I´m using the 3640 ios for switch. anyone resolved it?

      ReplyDelete

    UA-23728446-1