VLAN划分实验
- 如下图四台PC的网段均为192.168.1.0/24.,在末划分vlan前都可以相互平通,在这里我就不测试了,读者可以自行测试。
- 任务:把vlan10划分到PC1和PC4,vlan20划分到PC2和PC3
- 命名交换机为S1,S2
- 测试PC1和PC4能ping通
- P1和PC2不能ping通
- 注:记得打开两台交换机之间的trunk
- int f0/24
- switchport mode trunk
- S1的配置
Switch>enable
Switch#conf
Switch#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host S1
S1(config)#vlan 10
S1(config-vlan)#int vlan 10
S1(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
S1(config-if)#exit
S1(config)#vlan 20
S1(config-vlan)#int vlan 20
S1(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
S1(config-if)#exit
S1(config)#int f0/1
S1(config-if)#switchport access vlan 10
S1(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
S1(config-if)#int f0/2
S1(config-if)#switchport access vlan 20
S1(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
S1(config-if)#
S1(config-if)#int f0/24
S1(config-if)#switchport mode trunk
S1(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up
S1(config-if)#
- S2的配置
Switch>enable
Switch#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host S2
S2(config)#vlan 10
S2(config-vlan)#int vlan 10
S2(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
S2(config-if)#vlan 20
S2(config-vlan)#int vlan 20
S2(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
S2(config-if)#int f0/2
S2(config-if)#switchport access vlan 10
S2(config-if)#
S2(config-if)#int f0/1
S2(config-if)#switchport access vlan 20
S2(config-if)#
S2(config-if)#
- 命令配置完后先测试PC1ping PC2是不通的
- PC1和PC4能通
- PC2和PC3能通