今日实验:vlan的基本配置(vlan划分、Trunk、VTP)
根据下图进行拓扑连接,使用软件GNS3
第一步:设置PC1,PC2的ip地址如图(未划分Vlan时,PC1可以ping通PC2)
第二步:配置S1 (S1vlan划分完成后,PC1不能ping通PC2)
PC1> ping 192.168.2.2
host (192.168.2.2) not reachable
要求: 1、划分Vlan2
2、E0/1接口分配至VLAN2
3、E0/2起Trunk
4、S1配置VTP为server模式,domain设置为ccna
第三步:配置S2(S2完成配置后,PC1可ping通PC2)
要求: 1、划分Vlan2
2、E0/1接口分配至VLAN2
3、E0/2起Trunk
4、S2配置VTP为client模式,domain设置为ccna
具体命令如下:
交换机S1配置如下
S1#
S1#vlan data
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
S1(vlan)#vtp domain ccna
Domain name already set to ccna .
S1(vlan)#vtp ser
Device mode already VTP SERVER.
S1(vlan)#vlan 2 name ccna
VLAN 2 modified:
Name: ccna
S1(vlan)#exit
APPLY completed.
Exiting....
S1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
S1(config)#int e0/2
S1(config-if)#sw mo tr
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
S1(config-if)#sw tr en do
S1(config-if)#no sh
S1(config-if)#exit
S1(config)#int e0/1
S1(config-if)#sw ac vlan 2
S1(config-if)#no shu
S1(config-if)#ex
交换机S2配置如下:
S2#vlan da
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
S2(vlan)#vtp domain ccna
Domain name already set to ccna .
S2(vlan)#vtp client
Device mode already VTP CLIENT.
S2(vlan)#ex
In CLIENT state, no apply attempted.
Exiting....
S2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
S2(config)#int e0/2
S2(config-if)#sw mo tr
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
S2(config-if)#sw tr en do
S2(config-if)#no shu
S2(config-if)#exit
S2(config)#int e0/1
S2(config-if)#sw ac vlan 2
S2(config-if)#no shu
S2(config-if)#ex
测试结果:
PC1> ping 192.168.2.2
84 bytes from 192.168.2.2 icmp_seq=1 ttl=64 time=0.641 ms
84 bytes from 192.168.2.2 icmp_seq=2 ttl=64 time=0.593 ms
84 bytes from 192.168.2.2 icmp_seq=3 ttl=64 time=0.603 ms
84 bytes from 192.168.2.2 icmp_seq=4 ttl=64 time=0.578 ms
84 bytes from 192.168.2.2 icmp_seq=5 ttl=64 time=0.665 ms
PC1成功ping通PC2
查看vlan的运行状态:
VLAN2是通过VTP协议从交换机S1学习到的。
S2#vlan da
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
S2(vlan)#show current
VLAN ISL Id: 2
Name: ccna
Media Type: Ethernet
VLAN 802.10 Id: 100002
State: Operational
MTU: 1500
Backup CRF Mode: Disabled
Remote SPAN VLAN: No
还可以在特权模式下,通过show vtp status 命令来查看VTP状态,请大家自行尝试。
发表评论