PC1:192.168.1.2
PC2:192.168.2.2
PC3:192.168.1.3
PC4:192.168.2.3
SW1的f0/1连接SW2的f0/4,f0/2连接PC1,f0/3连接PC2
SW2的f0/1连接R1的f0/0,f0/2连接PC3,f0/3连接PC4
SW1:
SW1#vlan database
SW1(vlan)#vlan 10 name one
SW1(vlan)#vlan 20 name two
SW1(vlan)#vtp domain haha
SW1(vlan)#vtp server
SW1(vlan)#vtp password 123
SW1(vlan)#exit
SW1#conf t
SW1(config)#int f0/2
SW1(config-if)#switchport mod access
SW1(config-if)#switchport access vlan 10
SW1(config-if)#int f0/3
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 20
SW1(config-if)#exit
SW1(config)#int f0/1
SW1(config-if)#switchport mode trunk
SW1(config-if)#exit
SW2:
SW2#vlan database
SW2(vlan)#vtp domain haha
SW2(vlan)#vtp client
SW2(vlan)#vtp password 123
SW2(vlan)#exit
SW2#conf t
SW2(config)#int f0/2
SW2(config-if)#switchport mod access
SW2(config-if)#switchport access vlan 10
SW2(config-if)#int f0/3
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 20
SW2(config-if)#exit
SW2(config)#int f0/4
SW2(config-if)#switchport mode trunk
SW2(config-if)#exit
R1:
R1(config)#int f0/0
R1(config-if)#no sh
R1(config)#int f0/0.10
R1(config-subif)#encapsulation dot1Q 10
R1(config-subif)#ip address 192.168.1.1 255.255.255.0
R1(config-subif)#no sh
R1(config-subif)#int f0/0.20
R1(config-subif)#encapsulation dot1Q 20
R1(config-subif)#ip ad
R1(config-subif)#ip address 192.168.2.1 255.255.255.0
R1(config-subif)#no sh
R1(config-subif)#exit