一、交换机的基本配置
1.
Switch> (用户执行模式提示符)
Switch>enable (进入特权模式)
Switch# (特权模式提示符)
Switch#config terminal (进入配置模式)
Switch(config)#enable password cisco (设置enable password为cisco)
Switch(config)#enable secret cisco1 (设置enable secret为sisco1)
Switch(config)#hostname C2950 (设置主机名为C2950)
C2950(config)#end (退回到特权模式)
C2950#
2.
C2950(config)#ip address 192.168.1.1 255.255.255.0 (设置交换机IP)
C2950(config)#ip default-gateway 192.168.1.254 (设置默认网关)
C2950(config)#ip domain-name cisco.com (设置域名)
C2950(config)#ip name-server 200.0.0.1 (设置域名服务器)
C2950(config)#end
3.
C2950(config )#interface fastethernet0/1 (进入接口0/1的配置模式)
C2950(config-if)#speed ? (查看speed命令的子命令)
C2950(config-if)#speed 100 (设置该端口速率为100Mbps)
C2950(config-if)#duplex ? (查看duplex命令的子命令)
C2950(config-if)#duplex full (设置该端口为全双工)
C2950(config-if)#description TO_PC1 (设置该端口描述为TO_PC1)
C2950(config-if)#^Z (返回到特权模式,同end)
C2950#show interface fastethernet0/1 (查看端口0/1的配置结果)
C2950#show interface fastethernet0/1 status (查看端口0/1的状态)
4.
C2950(config)#mac-address-table ? (查看mac-address-table的子命令)
C2950(config)#mac-address-table aging-time 100 (设置超时时间为100s)
C2950(config)#mac-address-table permanent 0000.0c01.bbcc f0/3 (加入永久地址)
C2950(config)#mac-address-table restricted static 0000.0c02.bbcc f0/3 f0/7
(加入静态地址)
C2950(config)#end
C2950#show mac-address-table (查看整个MAC地址表)
C2950#clear mac-address-table restricted static (清除限制性地址)
二、配置和管理VLAN
1. VLAN
VLAN技术:把物理上直接相连的网络从逻辑上划分为多个子网。每一个VLAN对应着一个广播域,处于不同VLAN上的主机不能直接进行通信,不同VLAN之间的通信要引入第三层交换技术才可以解决。
VLAN中继(VLAN Trunk)也称为VLAN主干,是指在交换机与交换机或交换机与路由器之间连接的情况下,在互相连接的端口上配置中继模式,使得属于不同VLAN的数据帧都可以通过这条中继链路进行传输。
VLAN中继协议(即VTP协议)可以帮助交换机配置VLAN。VTP有三种工作模式:服务器模式、客户模式、透明模式。交换机的初始状态是工作在透明模式。
通常虚拟局域网(VLAN)的实现形式有三种:静态端口分配、动态虚拟网、多虚拟网端口配置。
2.
1)配置2950A交换机为服务器模式
Switch>enable (进入特权模式)
Switch#config terminal (进入配置子模式)
Switch(config)#hostname 2950A (修改主机名为2950A)
2950A(config)#end
2950A#
2950A#vlan dataBase (进入VLAN配置子模式)
2950A(vlan)#vtp ? (查看和VTP配合使用的命令)
2950A(vlan)#vtp server (设置本交换机为Server模式)
Setting device to VTP SERVER mode.
2950A(vlan)#vtp domain vtpserver (设置域名)
Changing VTP domain name from NULL to vtpserver.
2950A(vlan)#vtp pruning (启动修剪功能)
Pruning switched ON
2950A(vlan)#exit (退出VLAN配置模式)
APPLY completed.
Exiting…
2950A#show vtp status (查看VTP设置信息)
2)配置2950B交换机为客户端模式
Switch(config)#config terminal (进入配置子模式)
Switch(config)#hostname 2950B (修改主机名为2950B)
2950B(config)#end
2950B#vlan database
2950B(vlan)#vtp client
Setting device to VTP CLIENT mode.
2950B(vlan)#exit
3.
跨交换机的同一VLAN内的数据经过Trunk线路进行交换,默认情况下trunk允许所有的VLAN通过。可以使用switchport trunk allowed vlan remove vlan-list来去掉某一VLAN。可以在交换机2950A和2950B上做如下相同的配置操作。
Switch#config terminal
Swich(config)#interface f0/24 (进入端口24配置模式)
Switch(config-if)#switchport mode trunk (设置当前端口为Trunk模式)
Switch(config-if)#switchport trunk allowed vlan all
(设置允许从该端口交换数据的VLAN)
Switch(config-if)#exit
Switch(config)#exit
Switch#
4.
VLAN信息可以在服务器模式或透明模式交换机上创建。
2950A#vlan dataBase
2950A(vlan)#vlan 2 (创建一个VLAN2)
VLAN 2 added:
Name:VLAN0002 (系统自动命名)
2950A(vlan)#vlan 3 name vlan3 (创建一个VLAN3,并命名为vlan3)
VLAN 3 added:
Name:vlan3
2950A(vlan)#exit
5.
Switch#config terminal
Enter configuration commands,one per line.End with CNTL/Z.
Switch(config)#interface f0/9 (进入端口9的配置模式)
Switch(config-if)#switchport mode access (设置端口为静态VLAN访问模式)
Switch(config-if)#switchport access vlan2 (把端口9分配给相信的VLAN2)
Switch(config-if)#exit
Switch(config)#interface f0/10
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan3
Switch(config-if)#exit
Switch(config)#exit
Switch#show vlan (查看VLAN配置信息)
(结果省略)
Switch#
三、生成树协议配置
生成树协议(STP)的目的是在实现交换机之间冗余连接的同时,避免网络环路的出现,实现网络的高可靠性。当交换机之间有多个VLAN时Trunk线路负载会过重,这时需要设置多个Trunk端口,但这样会形成网络环路,而STP协议便可以解决这一问题。
1.
假如用端口f0/23做Trunk1,用端口f0/24做Trunk2,则配置如下。
(配置VTP)
Switch1#vlan dataBase (进入VLAN配置子模式)
Switch1(vlan)#vtp server (设置本交换机为Server模式)
Switch1(vlan)#vtp domain vtpserver (设置域名)
Switch1(vlan)#exit
Switch1#show vtp status (验证VTP设置信息)
(配置Trunk)
Switch1#config terminal
Switch1(config)#interface f0/23 (进入端口23配置模式)
Switch1(config-if)#switchport mode trunk (设置当前端口为Trunk模式)
Switch1(config-if)#exit
Switch1(config)#interface f0/24 (进入端口24配置模式)
Switch1(config-if)#switchport mode trunk (设置当前端口为Trunk模式)
Switch1(config-if)#end
Switch1#
(配置STP权值)
Switch1#config terminal
Switch1(config)# interface f0/23 (进入端口23配置模式,Trunk1)
Switch1(config-if)#spanning-tree vlan 1 port-priority 10
(将VLAN 1的端口权值设为10)
Switch1(config-if)#spanning-tree vlan 2 port-priority 10
(将VLAN 2的端口权值设为10)
Switch1(config-if)#exit
Switch1(config)#interface f0/24 (进入端口24配置模式,Trunk2)
Switch1(config-if)#spanning-tree vlan 3 port-priority 10
(将VLAN 3的端口权值设为10)
Switch1(config-if)#spanning-tree vlan 4 port-priority 10
(将VLAN 4的端口权值设为10)
Switch1(config-if)#spanning-tree vlan 5 port-priority 10
(将VLAN 5的端口权值设为10)
Switch1(config-if)#end
Switch1#copy running-config startup-config (保存配置文件)
2.
Switch1#config terminal
Switch1(config)#interface f0/23 (进入端口23配置模式,Trunk1)
Switch1(config-if)#spanning-tree vlan 3 cost 30 (设置VLAN 3生成树路径值为30)
Switch1(config-if)#spanning-tree vlan 4 cost 30 (设置VLAN 4生成树路径值为30)
Switch1(config-if)#spanning-tree vlan 5 cost 30 (设置VLAN 5生成树路径值为30)
Switch1(config-if)#exit
Switch1(config)#interface f0/24 (进入端口24配置模式,配置Trunk2)
Switch1(config-if)#spanning-tree vlan 1 cost 30 (设置VLAN 1生成树路径值为30)
Switch1(config-if)#spanning-tree vlan 2 cost 30 (设置VLAN 2生成树路径值为30)
Switch1(config-if)#end
Switch1#
大家好,我是老季,一个做弱电的民工,我将尽我最大的努力做好这个公众号,和大家一起分享,一起学习。这是我的个人微信号,想加入弱电圈子可以添加我的个人号,圈子里都是做弱电的,资源互相补充,实时资源多多。
扫一扫,关注本公众号,成为弱电行业高手
喜欢这篇文章,在右下角点个在看,点个赞,谢谢