使用工具:Cisco Packet Tracer 5.3
f0/1 pc0
f0/2 pc1
f0/3 pc3
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int f0/0
Router(config-if)#no shutdown
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
Router(config-if)#int f0/0.1
%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#int f0/0.2
%LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up
Router(config-subif)#encapsulation dot1Q 20
Router(config-subif)#ip address 192.168.2.1 255.255.255.0
Router(config-if)#int f0/0.3
%LINK-5-CHANGED: Interface FastEthernet0/0.3, changed state to up
Router(config-subif)#encapsulation dot1Q 30
Router(config-subif)#ip address 192.168.3.1 255.255.255.0
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10
Switch(config-vlan)#vlan 20
Switch(config-vlan)#vlan 30
Switch(config)#int f0/1
Switch(config-if)#switchport access vlan 10
Switch(config-if)#int f0/2
Switch(config-if)#switchport access vlan 20
Switch(config-if)#int f0/3
Switch(config-if)#switchport access vlan 30
Switch(config-if)#int f0/24
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan all