Cisco – Can’t ping Router from vlan 2 or 1 or between vlans

ciscopacket-tracerrouterswitchvlan

enter image description here

This is driving me nuts. There are 2 vlans on the switch( vlan 20 and 21.) one trunking port g0/1 and thats connected to a Router On A Stick. I CANT PING DIVINCES ON SEPARATE VLANS NOR THE ROUTER FROM THE PCs. HELP!!!!!

Interface configuration on the switch:

interface FastEthernet0/1
 switchport access vlan 21
 switchport mode access
 switchport nonegotiate
 spanning-tree portfast
!
interface FastEthernet0/2
 switchport access vlan 21
 switchport mode access
 switchport nonegotiate
 spanning-tree portfast
!
interface FastEthernet0/3
 switchport access vlan 20
 switchport mode access
 switchport nonegotiate
 spanning-tree portfast
!
interface FastEthernet0/4
 switchport access vlan 20
 switchport mode access
 switchport nonegotiate
 spanning-tree portfast


!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
!
interface FastEthernet0/16
!
interface FastEthernet0/17
!
interface FastEthernet0/18
!
interface FastEthernet0/19
!
interface FastEthernet0/20
!
interface FastEthernet0/21
!
interface FastEthernet0/22
!
interface FastEthernet0/23
!
interface FastEthernet0/24
!
interface GigabitEthernet0/1
 switchport trunk allowed vlan 20-21
 switchport trunk encapsulation dot1q
!
interface GigabitEthernet0/2
!

Note the interface connecting switch to router( the one on the switch is gig 0/1)

configuration on router interface g0/0 as its the one connecting to the switch below

interface GigabitEthernet0/0
 no ip address
 duplex auto
 speed auto
!
interface GigabitEthernet0/0.20
 encapsulation dot1Q 20
 ip address 150.19.20.6 255.255.255.248
!
interface GigabitEthernet0/0.21
 encapsulation dot1Q 21
 ip address 150.19.21.6 255.255.255.248
!

Best Answer

I don't see where you have globally defined the VLANs on the switch. You need something like:

Vlan 20
 name VLAN_20   ! or whatever you want to name it
 exit
!
Vlan 21
 name VLAN_21   ! or whatever you want to name it
 exit
!