可网管交换机(三层交换机除外)无需配置便可做为傻瓜交换机使用,可是没有配置的交换机将不能发挥其功能和安全性。没有配置的路由器没法实现网络之间的通讯。html
2,网络设备的管理方式数据库
外置配置源api
控制台(超级终端),虚拟终端(Telnet),网管工做站(Cisco的CiscoWork,HP的OpenView),TFTP服务器安全
3,CLI服务器
一种基于DOS 命令行的软件系统,对大小写不敏感,能够缩写命令和参数。网络
Cisco IOS命令行 须要在各自的命令模式下才能执行,所以,想执行某个命令,必须进入相应的配置模式。session
4,Cisco IOS 共包括7种不一样的命令模式dom
用户模式,特权模式,全局配置模式,Config-VLAN 模式,VLAN配置模式,接口配置模式,ide
Line配置模式。工具
模式 |
访问方法 |
提示符 |
退出方法 |
用途 |
User Exec |
开始默认模式 |
Switch> |
quit或 end或 exit |
改变终端设置,执行基本测试,显示系统信息 |
Privileged Exec |
Switch>enable |
Switch# |
校验键入的命令,该模式由密码保护 |
|
Gobal Configuration |
Switch#config |
Switch(config)# |
将配置的参数应用于整个网络设备 |
|
Config-vlan |
Switch(config)#vlan vlan-id |
Switch(config-vlan)# |
配置VLAN 参数。 |
|
VLAN configuration |
Switch#vlan database |
Switch(vlan)# |
在VLAN database 中为VLAN 1-1005配置VLAN 参数 |
|
Interface Configuration |
Switch(config)#interface |
Switch(config-if)# |
为Ethernet interfaces等 配置参数 |
|
Line Configuration |
Switch#line |
Switch(config-line)# |
为terminal line 配置参数 |
5,帮助,在#提示符后 输入 ? 可查看那些命令可用
6,命令的简略方式 show running-config 可简写成sh run
7,no执行命令相反的活动 如 no shutdown, 将命令恢复默认值如no speed
8,使用CiscoNetwork Assistant配置交换机
团体和集群,
团体最多容纳40个链接网络设备的设备组,Network Assintant 使用Cisco Discovery Protocol的自动查找能力来找出合格的网络设备,并将它添加到团体中。
用于为路由器快速设置LAN链接和Internet链接的管理工具
思科交换机路由器 模拟软件
如下配置 粗体是命令的关键字 ,斜体是参数, {}可选其一
Switch# configure terminal
Switch(config)# interface interface-id
Switch(config-if)# media-type {auto-select |rj45 | sfp}
Switch(config-if)# end
Switch# show interface interface-id transceiver properties
(保存配置)
Switch#copy running-config startup-config
配置速率,双工和自动翻转
Switch(config-if)# speed {10 | 100 |1000|auto|nonegotiate}
Switch(config-if)# duplex {auto |full |half }
Switch(config-if)# mdix auto
Switch#show controllers ethernet-controller interface-id phy
配置流控制
Switch(config-if)# flowcontrol {receive |send |} { on | off | desired
查看模块或端口状态
Switch# show module all
检查指定模块的状态
Switch# show module mod_num
⑴当须要查看端口工做状态时,可以使用下述命令
Swtich#show interface status
Switch#show interface interface-id
禁用并从新启用接口
Switch(config-if)# shutdown
Switch(config-if)#no shutdown
使用端口汇聚协议(PAgP)能够很容易在有EtherChannel能力的端口间,自动创建Fast EtherChannel 和Gigabit EtherChannel 链接,进行信息的交流。该协议具备学习相邻端口组动态和信息的能力。PAgP是EtherChannel的加强版,它支持在EtherChannel上的Spanning Tree和Uplink Fast功能,并支持自动配置EtherChannel的捆绑。Uplink Fast也是Cisco交换机技术,可以保证交换机在几秒种内快速从失败中恢复。
EtherChannel简介
使用端口汇聚协议(PagP, Port Aggregation Protocol)或链路汇聚控制协议(LACP,Link Aggration Control Protocol)能够将交换机之间,交换机和路由器之间,以及交换机与服务器之间的最多8条链路绑定在一块儿,叠加其传输带宽,使网络设备之间的通讯更加快速与顺畅。
PagP协议支持的模式
auto 当增测PAgP设备时,将只启用PAgP。将接口置于被动协商状态,能够对接收到的PagP作出响应,可是不主动发送PAgP包进行协商
desirable 无条件启用PAgP。将接口置于主动协商状态,经过发送PAgP包,主动与其余接口进行协商
on 将接口强行指定至Channel。只有两个on模式接口组相连时,EtherChannel才可用。
non-silent (可选)若是交换机链接有PAgP能力的伙伴,能够将接口配置为nonsilent(非沉默)运行。若是没有为auto 或 desirable 模式指定non-silent关键字,默认为silent 。
采用PAgP协议时,如下几种模式能够构建EtherChannel:
一个接口为 desiable 模式 ,另外一个接口为 desiable 或 aut哦模式。
一个接口为 auto 模式,另外一个接口为desiable模式。
LACP协议支持的模式:
Active 当侦测到LACP设备时,将只启用LACP .激活端口的主动协商状态,经过发送LACP包,与其余接口进行主动协商。
Passive 当侦测到LACP 设备时,将只启用LACP,将端口置于被动协商状态,能够对接收到的LDCP做出响应,可是,不能主动发送LACP包进行协商。
Switch#config terminal
2建立Port-channel接口。port_channel_number 取值范围为1-48
Switch(config)# interface port-channel port_channel_number
3将接口置于三层模式
Switch(config-if)#no switchport
4为该EtherChannel指定IP地址和子网掩码。
Switch(config-if) # ip address ip_address subnet_mask
5返回全局配置模式
Switch(config-if)#exit
6选择配置的物理接口,
Switch(config)#interface {fastethernet|gigabitethernet} slot/port
7建立三层路由接口
Switch(config-if)#no switchport
8确保该物理接口没有IP地址
Switch(config-if)#no ip address
9将接口配置为port-channel并指定为PAgP 或LDCP模式
Switch(config-if)#channel-group channel-group-number mode { auto [non-silent] | desirable[non-silent] |on} |{active | passive}
Switch(config-if)#end
10查看配置
Switch#show running-config
Switch#show running-config interface port-channel port_channel_number
实例 略
移除端口和EtherChannel
1从EtherChannel中移除接口
Switch#config terminal
Switch(config)# interface interface-id
从EtherChannel中移除接口
Switch(config-if)#no channel-group
Switch(config-if)#end
Swtich# show running-config
保存配置
Switch#copy running-config startup-config
2移除EtherChannel
Switch# configure terminal
Switch(config)#no interface port-channel port_channel_number
Switch(config-if)#end
查看配置
Switch# show etherchannel summary
VLAN 和Trunk简介
VLAN用于将端口指定为不一样的虚拟局域网,从而隔离彼此的之间的广播和直连通讯,提升网络的传输效率和安全性。Trunk 用于借助一个接口实现不一样交换机之间多VLAN的传输。
VLAN 的做用
下降移动和变动管理成本,控制广播,加强安全性,网络监督和管理自动化
Trunk的功能
能够将同一交换机的不一样端口划分为同一VLAN ,并且还能够设置跨越交换机的VLAN 。
不一样交换机上具备相同ID的VLAN 之间,可借助一条链路实现彼此之间的链接。用于链接VLAN的链路,称之为VLAN中继
VTP 简介
VTP (VLAN TrunkingProtocol ,VLAN 中继协议)是一种消息协议,用于在VTP域内同步VLAN 信息(VLAN 的添加,删除和重命名),而没必要在每台交换机上配置相同的VLAN 信息,从而实现VLAN配置的一致性。使用VTP,能够在一个或多个交换机上创建配置修改中心。
VTP域(也称为VLAN管理域),由一个或多个相互链接,使用相同VTP域名的交换机组成。一台交换机只能配置一个VTP域。
若是一个交换机收到一个中继传来的VTP通告,它将继承管理域名和VTP配置版本号,而且再也不理睬不一样的管理域名或更早的配置版本号。
VTP模式(三种):
Server 服务器
Client客户端
Transparent透明模式
VTP的配置规则:
VTP域中VTP版本要相同
当在交换机上启用VTP版本2时,同一域中可以运行版本2的交换机都将启用版本2,配置前确保域中交换机都能运行版本2。
Token Ring 环境必须启用版本2,
在VTP server上启用(禁用)修剪将致使整个管理域启用(禁用)修剪。
VLAN 的配置规则
在配置VLAN时,应遵循如下规则:
在VTP客户端,服务器和透明模式中,交换机支持1005个VLAN。
标准序列VLAN 的ID为1~1001 。VLAN 号为1002~1005的是Token Ring 和FDDI VLAN.
VLAN 1~1005的VLAN 配置一般被保存在VLAN数据库中。若是VTP模式是透明模式的,VTP和VLAN 配置也保存在交换机运行配置(running configuration)文件中。
VTP透明模式中,交换机也支持VLANID 1006~4094 ,该扩展序列和配置选项被限制。扩展序列VLAN 不能保存在VLAN 数据库。
配置VTP服务器
在一个局域网中,一般只须要配置1~2个VTP服务器,可将核心交换机配置为VTP服务器。在该交换机上配置VLAN,并为VLAN指定IP地址信息,其余交换机做为VTP客户端,接受并更新VTP服务器中的VLAN配置,从而使VLAN配置,修改和管理实现自动化和全网统一。
配置VTP服务器的步骤,将交换机设置为VTP服务器模式;将交换机端口指定到相应的VLAN;建立一个VLAN Trunk,用于实现与其余交换机的通讯。
Switch# config terminal
Switch(config)#vtp mode server
Switch(config)#vtp domain domain-name
(设置VTP域密码,密码长度为8-64个字符)
Switch(config)#vtp password password
Switch(config)#end
配置VTP客户端
若要使交换机接受VTP服务器对VLAN的配置,从而实现VLAN添加,删除和修改的自动化,就必须将其设置为VTP客户端。事实上,除了VTP服务器外的全部交换机都应该配置为VTP客户端。
配置 VTP客户端的步骤, 将交换机设置为VTP客户端模式;将交换机端口指定到相应的VLAN;建立一个VLAN Trunk,用于实现与其余交换机的通讯。
Switch(config)#vtp mode client
Switch(config)#vtp domain domain-name
(设置VTP域密码,密码长度为8-64个字符)
Switch(config)#vtp password password
(略)
VTP客户端虽然没必要建立VLAN,可是必须以手工方式将端口指定为不一样的VLAN,若是不将端口指定至VLAN ,那么该交换机的全部端口都将与级联端口在同一VLAN.
查看配置
Switch#show vtp status
(保存配置)
Switch#copy running-config startup-config
启用版本2
Switch(config)#vtp version 2
配置VTP透明模式
Switch(config)#vtp mode transparent
建立VLAN并将端口指定到VLAN
第1步 进入全局配置模式
Switch#config terminal
第2步 以太网VLAN ID 取值范围为1-1001,其中vlan 1为系统默认VLAN不能被建立,也不能被删除
Switch(config)# vlan vlan-id
第3步 为VLAN 命名,可不配置名称,名称默认为VLAN ID前加多个0
Swtich(config-vlan)# name vlan-name
第4步 返回全局配置模式
Swtich(config-vlan)# exit
第5步 进入接口模式
Switch(config)# interface interface-id
或者
Switch(config)# interface range interface-range
第6步 为端口(第二层访问端口)定义VLAN成员模式
Switch(config-if)# switchport mode access
第7步 将接口添加至指定的VLAN
Switch(config-if)# switchport access vlan vlan-id
第8步 退出接口配置模式
Switch(config)# end
第9步 查看 VLAN 配置
Switch(config)#show vlan {id |name|brief} vlan_name
清除接口配置
Switch(config)# default interface interface-id
删除某个VLAN
Switch(config)# no vlan vlan-id
删除所有VLAN
Switch# delete flash:vlan.dat
Delete filename [vlan.dat]?回车键
Delete flash:/vlan.dat? [confirm]回车键
配置VLAN Trunk
Trunk 端口不能是安全端口
Trunk 端口能够是EtherChannel组成员,可是组中全部Trunk必须具备相同的配置。包括:容许VLAN列表;每一个VLAN的STP端口优先级,STPPort Fast设置;Trunk状态,若是端口组中的一个端口不是Trunk,全部端口也将再也不是Trunk
在PVST模式下,建议配置很少于24个Trunk端口,在MST模式下,建议配置很少于40个Trunk端口。
Switch(config)#interface interface-id
Switch(config-if)#switchport mode trunk
配置ISL 或802.1Q封装,若是两端都是Cisco交换机用ISL封装
Switch(config-if)#switchport trunk encapsulation {isl| dot1q | nogotiate}
Switch(config-if)#switchport trunk allow vlan {all|add|except|remove} vlan-list
为802.1Q指定本地VLAN ,若不指定本地VLAN ,默认为VLAN 1
Switch(config-if)#switchport trunk native vlan vlan-id
Switch#config terminal
Switch(config)# spanning-tree mode {pvst |mst| rapid-pvst}
Switch(config)#end
Switch#show spanning-tree vlan vlan-id
对于较早的交换机
Switch(config)#spanning-tree vlan vlan_id
Switch(config)# no spanning-tree vlan vlan_id
配置根交换机
当VLAN 中存在拓扑环时,应当经过根交换机,端口优先级和路径费用等设置,肯定网络拓扑结构,一般状况下,应当将核心交换机配置为根交换机,当网络中有两台核心交换机时,能够分别配置根交换机和次根交换机。
diameternet-diamete用于指定两个终端间交换机数量,取值范围为2—7
Switch(config)#spanning-tree vlan vlan_id root primary diameter net-diamete
配置次根交换机
Switch(config)#spanning-tree vlan vlan_id root secondary diameter net-diamete
配置端口优先级
Switch#config terminal
Switch(config)#interface interface-id
为接口配置优先级,取值范围为0-255 ,默认值为128 。数值越低,优先级越高。
Switch(config-if)#spanning-tree port-priority priority
为接口配置VLAN端口优先级。取值范围为0-255,默认值为128.数值越低,优先级越高。
Switch(config-if)#spanning-tree vlan vlan-id port-priority priority
Switch(config)#end
Switch#show spanning-tree interface interface-id | {port-channel port_channel_number}
Switch#show spanning-tree vlan vlan_id
配置路径费用
Switch#configterminal
选择欲配置的接口,既能够是物理接口,也能够是EtherChannel逻辑端口
Switch(config)#interface interface-id | {port-channel port_channel_number}
配置接口的费用,取值范围为1-200 000 000.较低的路径费用代表有较高的传输速率。
Switch(config-if)#spanning-tree cost cost
Switch(config-if)#spanning-tree vlan vlan-id cost cost
Switch(config-if)#end
Switch# show spanning-tree interface {interface-id} |{port-channel port_channel_number}
Switch#show spanning-tree vlan vlan_id
配置Post Fast端口
Spanning-Tree Port Fast将使端口绕过监听和学习阶段,当即进入Spanning-Tree转发状态。Post Fast只适用于终端与交换机链接的端口。
Switch#config terminal
Switch(config)#interface interface-id
指定trunk关键字 ,能够在Trunk端口启用Port Fast。默认状况下,全部端口都被禁用Port Fast
Switch(config-if)#spanning-tree postfast [trunk]
Switch(config-if)#end
Switch#show spanning-tree interface interface-id portfast
Switch#copyrunning-config startup-config
配置MSTP
Switch#config terminal
进入配置MST模式
Switch(config)#spanning-tree mode mst
将VLAN映射到MST实例。instace-id的取值范围为0-4094.vlan-range的取值范围为1-4094,使用“-”能够指定一个VLAN范围,例如,instace2 vlan 1-13 命令将把VLAN1至VLAN13添加到MST实例2.一样,也可使用“,”来指定若干不连续的VLAN,例如 instace 1 vlan 10,20,30将把VLAN0010,VLAN0020,VLAN0030添加至MST实例1。当将VLAN映射至MST实例时,命令中指定的VLAN将从早前的映射中被添加或移除。
Switch(config-mst)#instance instance-id vlan vlan-range
指定配置名称。name字符串最长为32个字符,而且对大小写敏感。
Switch(config-mst)#name name
指定配置修订编号,取值范围为0-65535。
Switch(config-mst)#revision version
校验配置
Switch(config-mst)#show pending
Switch(config-mst)#end
Switch#show running-config
配置根、次根交换机
Switch# config terminal
配置为根交换机,
diameter net-diameter(可选) 取值范围2-7,用于指定任意两端之间的交换机最大数
hello-time seconds(可选) 用于指定根交换机发生配置消息的时间间隔,取值范围为1-10秒,默认值为2秒。
Switch(config)# spanning-tree mst instace-id root primary
[diameter net-diameter [hello-time seconds]]
配置为次根交换机
Switch(config)# spanning-tree mst instace-id root secondary
[diameter net-diameter] [hello-time seconds]
Switch(config)# end
Switch# show spanning-tree mst instance-id
VLAN之间是没法直接通讯的,VLAN之间的通讯必须借助第三层交换机。同时,VLAN之间的通讯必须借助三层接口才能实现。所以,VLAN建立完成后,必须配置三层VLAN端口,才能使VLAN之间的通讯成为可能。
第三层交换机根据OSI模型网络层的IP地址完成端到端的数据交换,主要应用于不一样VLAN子网的路由。当某一消息源的第一个数据流进行路由后,交换机会产生MAC地址到IP地址的映射表,直接从第二层由原地址传输到目的地址,再也不通过第三层路由系统处理,提升了数据包的转发效率,解决了VLAN 子网间传输消息时传统路由产生的速率问题。
配置逻辑三层接口
前提:1.已经建立VLAN,并将VLAN成员指定到二层接口 。2.已经启用IP路由,并指定IP路由协议。
Switch#config terminal
Switch(config)# ip routing
进入VLAN接口
Switch(config)# interface vlan vlan-id
为该VLAN指定IP地址信息,该VLAN中的计算机,将使用该IP地址做为默认网关。
Switch(config-if)# ip address ip_address subnet_mask
Switch(config-if)# no shutdown
Switch(config-if)# end
保存配置
Switch# copy running-config startup-config
查看配置
Switch# show interface interface-id
Switch# show ip interface interface-id
Switch# show running-config interface interface-id
Switch# show running-config interface vlan vlan_id
配置物理三层接口
Switch(config)#ip routing
Switch(config)# interface interface-id
Switch(config-if)# no switchport
Switch(config-if)# ip address ip_address subnet_mask
Switch(config-if)# no shutdown
交换机支持的访问列表
IP访问列表。过滤IP通讯,包括TCP,UDP,IGMP,ICMP
Ethernet访问列表,过滤非IP通讯
端口访问列表,路由访问列表,VLAN访问列表
访问列表类型
1标准IP访问列表
只过滤源地址
2扩展IP访问列表
扩展访问列表容许过滤源地址,目的地址,协议类型,端口号
3命名访问列表
方便修改
配置访问列表的注意事项
考虑访问列表中语句的顺序
默认拒绝
过滤方向: 向内的 inbound,向外的outbound
access-list-number及说明
基本访问列表
Switch#configure terminal
Switch(config)# access-list access-list-number {deny| permit} {ip_addresssubnet_mask|host ip_address|any}
IP访问列表
查看访问列表配置
Switch#show access-lists {name| access-list-number}
在接口上应用访问控制列表
Switch(config-if)#ip access-group access-list-number in
Switch(config-if)#ip access-group access-list-number out
使用CDP(CiscoDiscover Protocol)可发现网络中相邻的Cisco设备,包括交换机,网桥,访问服务器和交换机,从而便于网络的配置和管理。CiscoWorks和Cisco CAN监控和配置交换机,也必须借助CDP才能实现。
Switch#config terminal
启用CDP,使用no cdp run命令能够禁用CDP
Switch(config)#cdp run
设置保持其余设备发送消息的时间,取值范围为10-255,默认值为180
Switch(config)#cdp timer seconds
设置CDP更新的发送频率。取值范围为5-254,默认值为60秒
Switch(config)#cdp holdtime seconds
设置采用版本2发送广告。该状态为默认值
Switch(config)#cdp advertise-v2
Switch(config)#end
Switch#show cdp
配置DHCP中继代理
Switch# config terminal
Switch(config)# service dhcp
2.指定包转发地址
第1步 进入全局配置模式
Switch#config terminal
第2步 进入接口配置模式,并建立一个交换机虚拟接口
Switch(config)# interface vlan vlan-id
第3步 为该接口配置IP地址和子网掩码
Switch(config) # ip address ip-address subnet-mask
第4步 指定DHCP 包转发地址。helper-address 能够指定为DHCP 服务器地址,或者默认网关的地址(若是DHCP 服务器位于另外的网关)。使用网关地址,可使DHCP服务器可以响应DHCP请求。若是网络内安装有多台DHCP服务器,能够为每台服务器分配一个helper address 。DHCP服务器所在的VLAN没必要指定helper address
在接口模式下配置
Switch(config-if)# ip helper-address ip-address
第5步 返回全局配置模式
Switch(config)# exit
第6步 指定欲链接至DHCP客户端的交换机端口
Switch#interface range port-range
或者
Switch# interface interface-id
第7步 定义为VLAN 成员模式
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan vlan-id
使用SPAN(SwitchedPort Analyzer)或者RSPAN(RemoteSPAN)能够有效的分析经过端口或VLAN的网络流量。借助SPAN或RSPAN ,能够将一个交换机的端口映像到另外一个交换机端口,即发送流量的备份到该交换机或者其余交换机的另外一个端口,这样只须要将分析或侦听设备链接至监控端口,便可实现对被监听端口的分析和侦听。因为SPAN采用复制(或镜像)源端口或源VLAN上的接受或发送(或二者都有的)流量到目的端口,所以SPAN不影响源端口或VLAN的网络交换。事实上,除了SPAN或RSPAN会话所需的流量以外,目的端口不会接收或转发流量。
SPAN术语
入口业务:进入交换机的业务
出口业务:离开交换机的业务
源(SPAN)端口:用SPAN功能受监控的端口
目的地(SPAN)端口:监控源端口的端口,一般连有一个网络分析器。
监控端口:监控端口也是目的地SPAN端口
管理源:已配置受监控的源端口或者VLAN列表。
操做源:受到有效监控的端口列表。这可能和管理源有所不一样。例如,在关闭模式下的端口可能在管理源中出现,但它不受到有效监控。
SPAN模式
本地SPAN
也成为PSPAN,指基于端口的SPAN。源端口和目的端口都处于同一交换机,而且源端口能够是一个或多个交换机端口。
远程SPAN 或者RSPAN :
目的地端口和源端口没有位于同一交换机上。这是一项高级功能,要求有专门的VLAN来传送该业务,并由交换机之间的SPAN进行监控,要求中间交换机必须支持RSPAN VLAN技术。因而可知,并不是全部交换机均支持 RSPAN技术,因此应检查各自的版本说明或者配置指南,核实要配置的交换机是否可使用该功能。
VSPAN:
指基于VLAN的SPAN.SPAN的一种变体,源端口不是物理端口,而是VLAN。在给定交换机中,用户可使用单个命令来选择对属于专门VLAN的全部端口进行监控。
SPAN会话中流量监视限制
VLAN或端口应当分别位于不一样的会话中。
能够配置在每一个交换机堆栈上的2个源会话(本地SPAN和RSPAN源会话),在同一台交换机上,能够同时运行一个本地SPAN和RSPAN。本地SPAN和RSPAN目的会话的总数不能超过66个。
在一个SPAN会话中,能够有多个目的端口,可是最多不能超过64个。
建立本地SPAN会话
Switch#config terminal
Switch(config)# no monitor session { session_number| all| local| remote}
第3步
Switch(config)#monitor session session_number source{interface interface-id|
vlan vlan-id} [,|-] [both |rx|tx]
Switch(config)#monitor session session_number destination {interface interface-id [ , | - ] [encapsulation replicate ] }
Switch#show monitor [session session_number]
Switch#show running-config
Switchz#copy running-config startup-config
详细的介绍能够查看如下文章:
思科官方介绍: