1.实验目的<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

n  掌握交换机的基本配置和VLAN的配置,并能使用IOS操作技巧简化配置。
n   验证同一VLAN内的主机之间可以通信,不同VLAN之间的主机即使配置了相同网段的IP地址,也不能通信。
2.配置需求

为交换机添加VLAN2VLAN3,处于同一VLAN的主机之间可以ping通,处于不同VLAN的主机之间不能ping通。

3.网络拓扑

 

4.操作步骤

给交换机配置主机名
(1)       Console连接交换机,进入交换机的全局配置模式。
(2)       配置交换机的主机名为Benet1
验证方法:
查看交换机的提示符是什么?
(3)       配置交换机的console密码为123enable密码为ciscoenable口令为ciscoswitch
验证方法:
退出交换机配置状态,再登陆,需要在什么状态下输入哪些密码?
(4)       配置交换机的IP地址为172.16.1.1,掩码为255.255.0.0,配置交换机的网关为172.16.1.100
验证方法:
查看交换机的配置,是否能够看到配置正确的IP地址和网关?
PCIP地址配置为172.16.1.2,掩码为255.255.0.0,用直连网线连接PC和交换机,PC是否能ping通交换机?
(5)       为交换机添加两个VLAN
验证方法:
查看交换机的VLAN信息,是否有新添加的VLAN?
(6)       将交换机端口2~8分配给VLAN2,将交换机的端口9~12分配给VLAN3
验证方法:
查看交换机的VLAN信息,端口是否已经分配进VLAN2VLAN3
VLAN2的两个端口上有两台PC,两台PCIP地址为172.16.1.20 172.16.1.30,两台PC是否能ping通?
172.16.1.30的主机连接到VLAN3的端口上,是否能ping172.16.1.20的主机。
5.配置命令
给交换机配置主机名
Console连接交换机,进入交换机的全局配置模式
Switch(config)#hostname Benet1
配置交换机的密码
Benet1(config)#line console 0
Benet1(config-line)#password 123
Benet1(config-line)#login
Benet1(config)#enable password ciscoswitch
Benet1(config)#enable secret cisco
配置交换机的管理IP地址为172.16.1.1,掩码为255.255.0.0;
Benet1(config)#intface vlan 1
Benet1(config-if)#ip address 172.16.1.1 255.255.0.0
Benet1(config-if)#no shutdown
配置交换机的网关为172.16.1.100
Benet1(config)#ip default-gateway 172.16.1.100
配置VLAN
Benet1#vlan database
Benet1(vlan)#vlan 2
Benet1(vlan)#vlan 3
Benet1(vlan)#exit
将交换机端口2~8分配给VLAN2,将交换机端口9~12分配给VLAN3
Benet1(config)#intface range f0/2 – 8
Benet1(config)#switchport mode access
Benet1(config-range-if)#switchport access vlan 2
Benet1(config)#intface range f0/9 – 12
Benet1(config)#switchport mode access
Benet1(config-range-if)#switchport access vlan 3