注意事项:1,网关必须设置
2.VLAN 的IP必须设置
 
拓扑图
 
 
 
Switch(vlan)#vlan 10
VLAN 10 added:
    Name: VLAN0010
Switch(vlan)#vlan 20
VLAN 20 added:
    Name: VLAN0020
Switch(vlan)#exit
APPLY completed.
Exiting....
Switch#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#int vlan 10
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
Switch(config-if)#ip add
Switch(config-if)#ip address 192.168.1.6 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#int vlan 20
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
Switch(config-if)#ip add
Switch(config-if)#ip address 192.168.2.6 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#int f0/1
Switch(config-if)#sw
Switch(config-if)#switchport acc
Switch(config-if)#switchport access vlan 10
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to upSwitch(config-if)#int f0/2
Switch(config-if)#sw
Switch(config-if)#switchport ac
Switch(config-if)#switchport access vlan 20
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
Switch(config-if)#int f0/3
Switch(config-if)#sw
Switch(config-if)#switchport ac
Switch(config-if)#switchport access vlan 20
Switch(config-if)#no shut
Switch(config-if)#int f0/1
Switch(config-if)#no shut
Switch(config-if)#int f0/2
Switch(config-if)#no shut
Switch(config-if)#exit
Switch(config)#ip routing
Switch#
 
PC0的IP 192.168.1.2 255.255.255.0 网关192.168.1.6
PC1的IP192.168.2.2 255.255.255.0网关192.168.2.6
PC2的IP192.168.2.3 255.255.255.0网关192.168.2.6
实验结果都可以PING通