Routing – Intervlan routing using two Layer 3 Switches in Packet Tracer

layer3routingvlan

I am having trouble when I am using two Layer 3 switches and two PCs to create a simple network for Inter Vlan routing,

First of all have a look at this network,

The configuration for PC1 is,

IP: 192.168.10.1
Default Gateway: 192.168.10.254
Subnet: 255.255.255.0

Similarly for PC2,

IP: 192.168.20.1
Default Gateway: 192.168.20.254
Subnet: 255.255.255.0

enter image description here

Now for the left Switch, I set the Fa0/1 to trunk mode, and enabled created a Vlan 10 and moved the Pc1 to that Vlan,

Switch(config)#vlan 10
Switch(config-vlan)#name forPC1
Switch(config-vlan)#exit

Switch(config)#interface vlan 10


Switch(config-if)#ip address 192.168.10.254 255.255.255.0
Switch(config-if)#exit

Switch(config)#ip routing

Switch(config)#interface fastEthernet 0/24

Switch(config-if)#switchport mode access 

Switch(config-if)#switchport access vlan 10


Switch(config)#interface fastEthernet 0/1
Switch(config-if)#switchport trunk encapsulation dot1q 

Switch(config-if)#switchport mode trunk 

and Similarly, I have done the following configuration for the right switch,

Switch(config)#vlan 20
Switch(config-vlan)#name PC2
Switch(config-vlan)#exit

Switch(config)#interface vlan 20

Switch(config-if)#ip address 192.168.20.254 255.255.255.0
Switch(config-if)#exit

Switch(config)#ip routing 
Switch(config)#interface fastEthernet 0/1
Switch(config-if)#switchport trunk encapsulation dot1q 
Switch(config-if)#switchport mode trunk 
Switch(config-if)#exit


Switch(config)#interface fastEthernet 0/24

Switch(config-if)#switchport mode access 
Switch(config-if)#switchport access vlan 20
Switch(config-if)#exit

I have tried so many things. before i was not enable ip routing but even after using ip routing command i couldn't be able to ping PC1 from PC2

I have correctly set the trunk port also, then what is the issue ?

Best Answer

To allow VLAN routing four things are neccessary:

  • The VLANs you want to route must exist on all switches.
  • The VLANs must be allowed on the trunk between the switches.
  • Interface IPs for each VLAN must be assigned.
  • IP routing enabled.

In your case you need to add the following lines to your config:

Switch7:

Switch(config)#vlan 20
Switch(config-vlan)#name PC2
Switch(config-vlan)#exit

Switch8:

Switch(config)#vlan 10
Switch(config-vlan)#name forPC1
Switch(config-vlan)#exit

It is not neccessary to have the same names of the VLANs on both switches but it's a good practice to keep in consistent.

To verify that the VLANs are created on both switches you can issue the following command from Privileged EXEC:

Switch#show vlan brief

and it should list both VLAN 10 and VLAN 20.

Regarding the other condition it should be said that the default is to allow all vlans on the trunk, but to verify that it is indeed allowed you can issue the command:

Switch#show interfaces fastEthernet 0/1 trunk

and you should see vlan 10 and 20 listed under "Vlans allowed and active in management domain" aswell as "Vlans in spanning tree forwarding state and not pruned". If it is not listed under the latter one you need to check your spanning-tree configuration but that should not be a problem in this case.