知识归纳思科模拟器命令:设置交换机名字为yzhSwitch> 进入超级终端控制台Switch>enable 进入交换机特权模式Switch#Switch#configure terminal 进入交换机全局配置模式Switch(configure)#hostname yzh 改变名字为XXXyzh(configure)# 显示改名成功yzh(configure)#exit 退回上级操作模式,即返回特权模式yzh#yzh#exit 返回到用户模式yzh>参看交换机有关信息yzh#yzh#configure terminal 进入交换机全局配置模式yzh#show version 查看交换机的版本信息yzh#show vlan 查看交换机的VLAN信息,默认情况下所有借口均属于VLAN yzh#show running-config 查看交换机当前生效的配置信息配置交换机接口f0/2yzh>yzh>enableyzh#yzh#configure terminal 进入交换机配置模式yzh(config)#interface fastEthernet 0/2 进入交换机接口fa0/2yzh(config-if)# 进入接口配置模式yzh(config-if)#speed 100 设置接口F0/2速率为100Myzh(config-if)#duplex half 配置接口的双工模式是半双工yzh(config-if)#no shutdown 开启接口,使得处于工作状态,等待转发数据。
yzh(config-if)#exit 输入exit返回全局模式yzh(config)#exit 返回特权模式yzh# 位于特权模式yzh#show interfaces fastEthernet 0/2 查看刚才对接口f0/2配置情况设置交换机Enable特权密码为adminyzh> 进入超级终端控制台yzh>enable 进入交换机特权模式yzh#configure terminal 进入交换机配置模式yzh(config)#enable secret admin 设置Enable密码为admin注:验证密码自己思考。
查看设备配置信息yzh#show running-config保存配置信息yzh#write 保存设置配置,把配置指令写入对到系统文件夹中yzh#dir 查看系统文件删除配置,恢复初始配置yzh#yzh#dir 查看系统文件yzh#delete? 输入“?”号,获得帮助yzh#delete flash:config.txt 删除配置文件系统就恢复了出厂配置三层交换机与二层交换机的大多数都相同。
配置三层交换机的名称为SW3,enable密码为admin,并且配置与远程登陆相关的选项。
Switch>enable 进入交换机特权模式Switch#configure terminal 进入交换机全局模式Swirch(config)#hostname yzh 修改交换机名称Yzh(config)#enable password admin 设置交换机enable密码为adminYzh(config)#interface vlan1 进入vlan1Yzh(config-if-VLAN1)#ip address 192.168.1.1 255.255.255.0 配置IP地址yzh(config-if-VLAN1)#exit 退出配置vlan1yzh(config)#username admin password admin 配置登陆交换机的用户名与密码yzh(config)#line vty 0 4 进入vty端口配置yzh(config-line)#login local 配置vty端口使用本地数据库验证yzh(config-line)#exit 退出vty端口配置yzh(config)# 配置OK保存三层交换机配置。
SW3#write配置三层交换机名称与VLANyzh>enable 进入交换机特权模式yzh#configure terminal 进入交换机全局模式yzh(config)#hostname YZH 修改交换机名称为YZHYZH(config)#vlan10 创建vlan10YZH(config-vlan)#vlan20 创建vlan20YZH(config-vlan)#exitYZH(config)#interface range fastEthernet 0/1-10 进入fa/1-10端口YZH(config-if-range)#switchport access vlan10 划分fa/1-10端口为vlan10 YZH(config-if-range)exitYZH(config)#interface range fastEthernet 0/11-20 进入fa/11-20端口YZH(config-if-range)#switchport access vlan20 划分fa/11-20端口为vlan20 YZH(config-if-range)#exit查看vlan配置信息YZH(config)#exitYZH#show vlan 查看交换机vlan信息配置vlan10与vlan20的IP地址,使vlan10与vlan20之间能相互通讯。
YZH(config)#interface vlan10 进入vlan10YZH(config-vlan10)#ip address 192.168.1.1 255.255.255.0 配置vlan10的IP地址YZH(config-vlan10)#exitYZH(config)#interface vlan20 进入vlan20YZH(config-vlan20)#ip address 192.168.2.1 255.255.255.0 配置vlan20的IP地址YZH(config)#exitYZH#show running-config 查看交换机配置信息在三层交换机上配置vlan10与20的IP地址后,PC1与PC2可以相互通讯YZH>enable 进入特权模式YZH#configure terminal 进入全局模式YZH(config)#hostname yzh 修改名称yzh(config)#interface range fasrEthernet 0/1-2 进入fa0/1、fa0/2端口yzh(config-if-range)#port-group 1 把fa0/1、fa0/2端口聚合为端口组1 yzh(config-if-range)#exityzh(config)#exit 注:验证测试:查看交换机配置yzh#show running-config配置三层交换机SW1的生成树协议yzh>enableyzh#configureyzh(config)#hostname YZHYZH(config)#spanning-tree 配置生成树YZH(config)#exit验证配置:YZH#show vlan 查看VLAN划分信息配置二层交换机SWB的VLAN划分YZH>enableYZH #configure terminalYZH(config)#hostname SWB 配置交换机名称YZH (config)#vlan20 创建VLAN20YZH (config-vlan)#exitYZH (config)#int fa0/1YZH (config-if)#switYZH (config-if)#switchport access vlan20 将端口Fa0/1划分为VLAN20YZH (config-if)#exitYZH (config)#int fa0/24YZH (config-if)#switchport access vlan20 将端口Fa0/24划分为VLAN20YZH (config-if)#exit配置三层交换机SW1不同VLAN之间的通信YZH>enableYZH #configure terminalYZH (config)#hostname yzh !配置交换机名称yzh (config)#vlan10 !创建VLAN10yzh (config-vlan)#vlan20 !创建VLAN20yzh (config-vlan)#vlan 30 !创建VLAN30yzh (config-vlan)#exityzh (config)#interface vlan10 !配置VLAN10的IP地址yzh (config-VLAN10)#ip address 192.168.1.1 255.255.255.0yzh (config-VLAN10)#exityzh config)#interface vlan20 !配置VLAN20的IP地址yzh (config-VLAN20)#ip address 192.168.2.1 255.255.255.0yzh config-VLAN20)#exityzh (config)#interface vlan 30 !配置VLAN30的IP地址yzh (config-VLAN 30)#ip address 192.168.3.1 255.255.255.0yzh (config-VLAN 30)#exityzh (config)#interface range fastEthernet 0/1-7yzh (config-if-range)#switchport access vlan10 !划分VLAN10yzh (config-if-range)#exityzh (config)#interface range fastEthernet 0/8-14yzh (config-if-range)#switchport access vlan20 !划分VLAN20yzh (config-if-range)#exityzh (config)#interface range fastEthernet 0/15-21yzh (config-if-range)#switchport access vlan 30 !划分VLAN30yzh (config-if-range)#exit配置风暴控制。
在交换机配置F0/1端口(连接PC1 的端口)对广播报文进行风暴控制,限制其端口收到的报文速率(pps)yzh#configureyzh(config)#interface fastEthernet 0/1yzh(config-if)#storm-control broadcast pps 100 配置报文速率阈每秒100个报文yzh(config-if)#exit配置交换机端口安全的最大连接数和端口违背模式,绑定PC机IP地址和MAC地址到端口上yzh>enableyzh#configureyzh(config)#interface fastEthernet 0/1yzh(config-FastEthernet 0/1)#switchport port-security 打开端口安全功能yzh(config-FastEthernet 0/1)#switchport port-security mac address 0023.7d51.72adip-addreess 192.168.1.1yzh(config-if-range)#switchport port-security violation shutdown 配置安全违背关闭模式验证交换机端口的最大连接数和端口违背模式yzh(config)#show port-secruity验证端口绑定的MAC地址和IP地址yzh(config)#show port-security验证端口绑定的MAC地址和IP地址yzh(config)#show port-security address配置镜像源端口0/1-2的进出流量映射到目的端口F0/20yzh>enableyzh#configureyzh(config)#monitor session 1 source interface fasrEthernet 0/1-2 bothyzh(config)#monitor session 1 destination interface fastEthernet 0/20yzh(config)#exit查看配置信息yzh(config)#show monitor session 1交换机地址绑定(address-bind)功能yzh>yzh>enableyzh#configure terminalyzh(config)#address-bind install 使用address-bind功能yzh(config)#address-bind 192.168.1.1 0016.d390.6cc5绑定IP地址为192.168.1.1 MAC地址为0016.d390.6cc5的主机让其使用网络yzh(config)#address-bind 192.168.1.2 0016.d390.6cc4绑定IP地址为192.168.1.2 MAC地址为0016.d390.6cc4的主机让其使用网络yzh(config)#address-bind iplink GigabitEthernet 0/24设置F0/24为例外端口,对于绑定地址策略不生效!查看配置信息yzh#show address-bind创建ACL,定义需要限速的主机范围yzh>enableyzh#configureyzh(config)#ip access-list standard gc 创建标准访问控制列表gcyzh(config-std-ipacl)#permit host 192.168.1.0 定义限速的数据流yzh(config)#ip access-list standard yg 创建标准访问控制列表ygyzh(config-std-ipacl)#permit host 192.168.2.0 定义限速的数据流定义分类表Yzh(config)#class-map yg 创建名为yg的分类表yzh(config-cmap)#match access-group yg 关联匹配的列表地址yzh(config-cmap)#exityzh(config)#class-map gc 创建名为yg的分类表yzh(config-cmap)#match access-group gc 关联匹配的列表地址yzh(config-cmap)#exit创建策略列表,关联对应的分类表,配置限速大小yzh(config)#policy-map qos1 创建名为qos1的策略列表yzh(config-pmap)#class yg 关联分类表ygyzh(config-pmap-c)#police 20000 2000 exceed-action drop将满足yg分类规则的报文的带宽设置为20M比特/秒,突发值为2M字节,超出此带宽的报文一律丢弃yzh(config-pmap)#class gc 关联分类表gcyzh(config-pmap-c)#bandwidth 20 percent 设置cg占取20%带宽yzh(config-pmap-c)#exit将带宽限制策略应用到相应的端口yzh#configureyzh(config)#interface range fastEthernet 0/1-2 进入端口1-2yzh(config-if)#service-policy input qos1 应用策略列表小贴士验证分类表和策略列表的配置命令Switch#show class-mapSwitch#show policy-mapyzh#configyzh(config)#time-range schooltime 创建时间表schooltimeyzh(config-time-range)#periodic Daily 23:00 to 23:59定义时间范围为23:00到23:59yzh(config-time-range)#periodic Daily 0:00 to 7:00定义时间范围为0:00 到 7:00yzh(config)#exit:创建扩展ACL并命名为schoolACl,配置禁止172.20.83.0该网段在每天晚上23:00至凌晨7:00禁止访问外网IP地址172.20.82.100。