PC4 192.168.0.4/24
S1(config-if)#switch mode trunk
S1(config)#interface fa0/2
S1(config-if)#switchport mode trunk
S2(config-if)#switchport mode trunk
S2(config-if)#switchport trunk allow vla all//为了pc互ping建立trunk
S2(config-if)#exit
S2(config)#interface fa0/2
S2(config-if)#switchport mode trunk
---- -------------------------------- --------- -------------------------------
1 default active Fa0/4, Fa0/5, Fa0/6, Fa0/7
Fa0/8, Fa0/9, Fa0/10, Fa0/11
Fa0/12, Fa0/13, Fa0/14, Fa0/15
Fa0/16, Fa0/17, Fa0/18, Fa0/19
Fa0/20, Fa0/21, Fa0/22, Fa0/23
Fa0/24, Gig1/1, Gig1/2
2 VLAN0002 active Fa0/3
S2(config)#interface fastEthernet 0/3
S2(config-if)#switchport access vlan 2//PC2对应交换机上的端口加入vlan2
---- -------------------------------- --------- -------------------------------
1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15, Fa0/16, Fa0/17, Fa0/18
Fa0/19, Fa0/20, Fa0/21, Fa0/22
Fa0/23, Fa0/24, Gig1/1, Gig1/2
2 VLAN0002 active Fa0/2
S3(config-if)#switchport mode trunk
S3(config-if)#switchport trunk allowed vlan all//为了pc互ping建立trunk
S3(config-if)#switchport acc vla 2//PC3对应交换机上的端口加入vlan2
S4(config)#vtp domain domainname
---- -------------------------------- --------- -------------------------------
1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15, Fa0/16, Fa0/17, Fa0/18
Fa0/19, Fa0/20, Fa0/21, Fa0/22
Fa0/23, Fa0/24, Gig1/1, Gig1/2
2 VLAN0002 active Fa0/2
S4(config)#interface fa0/1
S4(config-if)#switchport mode trunk
S4(config-if)#interface fa0/2
S4(config-if)#switchport access vlan 2//PC4对应交换机上的端口加入vlan2