为什么我配置的三层交换机无法连接vlan?

图片说明
配置过程:
主机ip为默认网关最后一位设置为100(计算机0为99),子网掩码为255.255.255.0

交换机0配置

en
config t
vlan 10
exit
vlan 20
exit
interface range fastEthernet0/1-10
switchport access vlan 10
exit 
interface range fastEthernet0/11-23
switchport access vlan 20
exit

交换机1配置:

en
config t
vlan 30
exit
vlan 40
exit
interface range fastEthernet0/1-10
switchport access vlan 30
exit 
interface range fastEthernet0/11-23
switchport access vlan 40
exit

然后手动把两个交换机f0/24配置为trunk模式

多层交换机配置:
先退到用户模式然后

en
config t 
interface range GigabitEthernet0/1-2
switchport trunk encapsulation dot1q       
switchport mode trunk 
switchport trunk allowed vlan all   
ip routing                                   
vlan 10
exit
vlan 20
exit    
vlan 30
exit
vlan 40
exit
interface vlan 10
ip address 172.16.10.1 255.255.255.0
no shu
exit
interface vlan 20
ip address 172.16.20.1 255.255.255.0
no shu
exit
interface vlan 30

ip address 172.16.30.1 255.255.255.0
no shu
exit
interface vlan 40
ip address 172.16.40.1 255.255.255.0
no shu 
exit

然后计算机1ping 除了计算机0都无法成功

SW2一定要打开IP路由转发 : SW2(config)#ip routing
SW2在设置f0/22-23端口为trunk 模式之前,必须开启二层端口封装802.1q协议(dot1q),也就是trunk链路的中继协议

这两项都注意到了

看下这个吧
https://blog.csdn.net/pwc1996/article/details/50589248