R1配置:

interface GigabitEthernet0/0/1.1

 dot1q termination vid 10

 ip address 192.168.1.254 255.255.255.0

 arp broadcast enable

#

interface GigabitEthernet0/0/1.2

 dot1q termination vid 20

 ip address 192.168.2.254 255.255.255.0

 arp broadcast enable

#

interface GigabitEthernet0/0/1.3

 dot1q termination vid 30

 ip address 192.168.3.254 255.255.255.0

 arp broadcast enable

S1配置:

vlan batch 10 20 30

interface GigabitEthernet0/0/1

 port link-type trunk

 port trunk allow-pass vlan 2 to 4094

#

interface GigabitEthernet0/0/2

 port link-type trunk

 port trunk allow-pass vlan 2 to 4094

#

interface GigabitEthernet0/0/3

 port link-type trunk

 port trunk allow-pass vlan 2 to 4094

S2配置:

vlan batch 10 20

interface Ethernet0/0/1

 port link-type access

 port default vlan 10

#

interface Ethernet0/0/2

 port link-type access

 port default vlan 20

interface GigabitEthernet0/0/2

 port link-type trunk

 port trunk allow-pass vlan 2 to 4094

S3配置:

vlan 30

 description manager

interface Ethernet0/0/1

 port link-type access

 port default vlan 30

interface GigabitEthernet0/0/2

 port link-type trunk

 port trunk allow-pass vlan 2 to 4094

(即:port trunk allow-pass vlan all)

PC1、PC2、PC3互ping通

PC1 ping 192.168.1.254通

PC2 ping 192.168.2.254通

PC3 ping 192.168.3.254通