a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 59|回复: 0

[综合] 思科认证备考辅导:cisco交换机命令汇总

[复制链接]
发表于 2012-8-3 20:03:30 | 显示全部楼层 |阅读模式
思科认证备考辅导:cisco交换机命令汇总
  R% d" Z: D6 v& ]; w交换机口令设置:; P! i" X5 p4 j  o$ H! T. Q
(我所针对的都是cisco 的设备而言的,华为的可以跟据手册来查,配置都是差不多的,这里华子就不多写华为的设备了,了解的也不是很多)
* f5 B" p$ u8 _% Gswitch》enable 进入特权模式
( Z6 B3 k" @: l! o( S1 W4 o( v1 }switch#config terminal 进入全局配置模式, l* H! \2 W7 o6 K
switch(config)#hostname 设置交换机的主机名; t# l. y7 n2 H7 r; e" n6 L
switch(config)#enable secret xxx 设置特权加密口令; j  G) M- V& G9 e1 @" {
switch(config)#enable password xxa 设置特权非密口令- e+ e$ s4 |3 x( c6 \+ R2 _
使用Telnet远程式管理
% Z7 g# R+ i% ^( s) t8 V4 o$ m+ oswitch(config)#interface vlan 1 进入vlan 15 z5 E5 }. H* D, a' V4 ]
switch(config-if)#ip address 设置IP地址- S( u2 [3 H: _! Z- n1 P( f  J
switch(config-if)#ip default-gateway 设置默认网关
* \0 N) B( B3 J+ n8 X+ F- Vswitch(config)#line vty 0 4 进入虚拟终端8 M3 u3 v. j* |  L5 b
switch(config-line)#login 允许登录
' W0 P( W0 G. {# w1 Fswitch(config-line)#password xx 设置登录口令) e$ @9 G0 S/ P" u, e' \
switch#exit 返回命令
9 W' ]2 w- ^, _控制台口令& u/ z' |" Q9 _# r0 b. [5 \
switch(config)#line console 0 进入控制台口8 r$ C9 _+ ?& ?3 L" O7 ?
switch(config-line)#login 允许登录3 \, R, ~4 P* k; F- p* v
switch(config-line)#password xx 设置登录口令8 }9 U* \$ L8 ]- l- ], H
switch#exit 返回命令8 |, {% L+ D+ Z( `9 M3 E% s
基本接口配置
# _' |7 p8 n6 j1 x, S1 Hswitch(config)#interface f0/1 进入f0/1接口& o  n; n  ~/ U
switch(config-if)#duplex full 配置全双工模式
: m" Z+ o, ~5 n& Aswitch(config-if)#speed 100 配置速率
6 x$ O4 N5 d5 b$ T! Jswitch(config-if)#description to ***** 接口描述
3 [/ q4 O  n' e6 T; z- l" ?" {switch(config)#ip domain-name ***.com 设置或名服务器0 ]8 l" E5 N8 n0 ]6 m% i7 S. f! d) M
switch(config)#mac-address-table aging-time 设置mac表超时时间/ v- E  [; C8 i+ a( @' e
switch#write 保存配置信息9 B& L5 B" P' n% y6 y: j4 z
switch#copy running-config startup-config 保存当前配置nvram
" K- |. w* g/ {6 m3 ^switch#erase startup-config 清除配置文件: p0 L0 J- K9 f' A' U- `6 R! @
$ Y5 K7 a7 a) j9 c+ d) ~' s
- d9 Q6 @$ ~9 O
交换机VLAN设置:
8 b5 @# f) w. J7 o5 @4 Eswitch#vlan database 进入VLAN设置; C: r" g6 _9 B. R% f/ e
switch(vlan)#vlan 2 建VLAN 2
7 n! C1 H" L; Dswitch(vlan)#name 名字 建VLAN 2的名称
9 }8 \4 b  g9 eswitch(vlan)#no vlan 2 删vlan 2
% A; D% K& J8 s& T* T2 ?! C, u注:删除vlan时原属于此vlan的端口处于非激活状态,直到重新分配为止9 D) j' r& t6 T; ]* D
switch(config)#int f0/1 进入端口1
: ^+ r+ Q/ L& S* y7 vswitch(config-if)#switchport mode access 当前端口工作莫试+ E3 M* \+ H0 O9 h' B
switch(config-if)#switchport access vlan 2 当前端口加入vlan 2  L$ B$ }& R, d3 O
switch(config-if)#switchport mode trunk 设置为干线
( m+ O1 K/ f/ Kswitch(config-if)#switchport trunk encapsulation dot1q 设置vlan 中继协议
# q$ p0 O/ z; P5 R  f- L5 sswitch(config-if)#no switchport mode 或 ( switchport mode access) 禁用干线
) M6 F0 B9 P0 j( G. h) F' l: cswitch(config-if)#switchport trunk allowed vlan add 1,2 ;从Trunk中添加vlans
: l3 l& v) N+ p4 C5 |6 h" Tswitch(config-if)#switchport trunk allowed vlan remove 1,2 ;从Trunk中删除vlans* G8 n7 k& l" ^* c6 P, P. M8 f
switch(config-if)#switchport trunk pruning vlan remove 1,2 ;从Trunk中关闭局部修剪
3 ?1 ?1 l: V$ ^5 c  ]$ \) q以太网通道配置
. b! G& y! T# f$ Sswitch(config)#interface range fasternet0/1 - 2 将fasternet0/1和0/2 口捆绑 (成双不成单)# F% v) K4 C. ?% H
switch(config-if)#channel-group 1 mode on 配置以太通道模式
4 H7 e4 g  [, P- uswitch(config-if)#port-channel load-balance {dst-mac | src-mac}在链路间实现负载均衡
3 T5 y: R% U+ t4 t9 c! Kswitch#show etherchannel 1 summary 查看通道信息
% F0 h3 u' x9 [' |# Rswitch#show etherchannel load-balance 查看通道信息8 Q- N" K  s% Y0 z% n9 g
vtp配置
1 U  [1 S8 G5 P/ y% P  b( H$ a( ?; T7 |switch(config)#vtp domain 设置vtp域名
9 q7 i1 V  [9 z, U; \switch(config)#vtp password 设置vtp密码6 C+ M) g% |( b+ E+ A
switch(config)#vtp mode server 设置vtp服务器模式) y, B0 k; H' B8 g8 v2 L
switch(config)#vtp mode client 设置vtp客户机模式- D; ~; `; d. |( Z/ `( C' {; W, v
switch(config)#vtp mode transparent 设置vtp 透明模式  F6 o5 m6 s( j0 }
switch(config)#vtp version 设置vtp版本
$ X0 S0 r$ C8 Y; @$ X# Xswitch(config)#vtp pruning 启用vtp修解
% V3 i  ?1 L& k- Q4 Z; u8 p  rswitch(config)#no vtp pruning 关闭vtp修解; D, C" g" u* H$ G5 [7 W" _
注:要想从vtp中减少一台交换机只需将该交换机vtp 名更改
% W4 M$ A; i+ @% m0 O; x$ @生成树stp:) \' m/ O* z' N8 V  O" j& H
switch(config)#spanning-tree vlan 启用stp生成树(基于vlan)
+ W3 T" m0 _4 }4 Q. e9 dswitch(config)#spanning-tree vlan root primary 指定根交换机(基于vlan)
5 `+ c' M( k/ T+ d  Q. Eswitch(config)#spanning-tree vlan root secondary 指定备用根交换机(基于vlan)& |: c2 d& {) h; w6 Q8 r! X
switch(config)#spanning-tree vlan priority 指定交换机优先级(基于vlan)0 h, O. H2 i! t4 C
switch(config)#no spanning-tree vlan priority 将交换机的优先级恢复默认值(基于vlan)7 w$ D: B7 Y! P7 N& q" t" H$ F+ p
switch(config-if)#spanning-tree vlan cost 指定端口成本(起用trunk的端口模式下)
, M" _: Y" r- f) P$ _6 _switch(config-if)#spanning-tree vlan port-prioty 指定交换机端口优先级(基于vlan)" ], W( W4 I# D  A( z3 A
switch(config-if)#spanning-tree portfast 配置速端口(连接终端设备的端口状态)如pc机+ `" F! g% [2 Q0 D6 n3 P
switch(config)#spanning-tree uplinkfast 配置上行速端口! ^* J; L8 x; ]( {  w
注:在配置上行速端口前要先将基于vlan上的网桥优先级,网桥成本恢复默认值。起用了该命令后在进行优先级更改,
/ x6 p* ]1 r6 wswitch(config)#spanning-tree vlan hello-time 配置交换机hello时间(基于vlan)
8 ^- L) m5 J' P2 e1 _switch(config)#spanning-tree vlan forward-time 修改转发延迟计时器(基于vlan)
+ e, ]6 [; o% U) zswitch(config)#spanning-tree vlan max-time 修改最大老化时间(基于vlan)
; T+ V, ^: [' b) Q. B注:vlan为可选参数,当没有该参数时将修改所有vlan网桥的优先级及所有的vlan端口成本% g& p9 _2 y) g* A9 e
switch#show spanning-tree summery 检测vlan生成树配置; C, X" f( G1 [3 y  f, g. t
switch#show spanning-tree vlan detail 浏览详细生成树配置信息
( Q# H. Y) X" r4 o# J2 |switch#show spanning-tree interface detail 浏览详细生成树端口配置信息: y7 h5 p4 C* K5 y3 m8 c2 \
交换机显示命令:
; W8 O5 K% f8 _, hswitch#show vtp status 查看vtp配置信息
0 L) `8 X% U& z% Y4 f- i; i9 Yswitch#show running-config 查看当前配置信息0 \3 Z: {: x/ L/ v# p$ z( O
switch#show vlan 查看vlan配置信息
+ y! i+ Y( T* a0 `- }3 [! h) Sswitch#show interface 查看端口信息
# T9 S' H  ~/ ]- Sswitch#show int f0/0 查看指定端口信息
+ F5 K+ v" C4 \( J7 P' g' `switch#dir flash: 查看闪存
; L( w; Y4 \( U. I2 _+ }switch#show version 查看当前版本信息
- s; x4 s$ s7 c, P/ A" A. Oswitch#show mac-address-table aging-time 查看mac超时时间; s9 B3 T+ C5 h6 Z( o$ y* ?, k& w
switch#show cdp cisco设备发现协议 (可以查看聆接设备)3 T8 J' q  `* O' b3 T7 Y2 f
switch#show cdp traffic 杳看接收和发送的cdp包统计信息) `; T( q3 \' i& I8 z" j0 j+ j
switch#show cdp neighbors 查看与该设备相邻的cisco设备
" A2 d& }& e) p3 T$ d* kswitch#show interface f0/1 switchport 查看有关switchport的配置. H& ^# x4 k& Y! x. v
switch#show cdp neighbors 查看与该设备相邻的cisco设备0 ]  [! O- m. O! P$ B" q$ ~- G' c4 J
2950交换机密码恢复: B! m# K% Z( R9 e- H3 D' h
拨下交换机的电源线
( C, D4 ?. V: U# I用手按在mode按键上,插上电源线。
4 d) C9 i# @# p; [* {看到出现 flash_init load_helper boot switch: 画面时松开mode键/ ~, n0 ?! ]( Q/ d
在switch:后执行flash_init命令查看flash中的文件# d# r" J( ~& Y' o: Y) y
把config.text 文件改名为“config.old rename flash:config.text flash:config.old
. E6 w7 ?: R7 d% n1 n执行boot命令启动交换机
# L! S; \- J5 S2 {- H交换机出现是否进入配置的对话, 执行no命令
* K% y, Q- S+ r4 a- j( v5 W进入特权模式查看flash文件 执行enable 在switch#show flash:
% D7 t1 B7 `/ ~5 D把config.old改为config.text rename flash:config.old flash:config.text
7 G/ ]2 t# A% h+ t把config.text考入系统的running-config
% z( ]5 K/ B) z; p$ hcopy flash:config.text system:running-config: M: _+ T; r0 _# v' U1 F" d6 b
重新设置密码并存盘
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-26 20:37 , Processed in 0.528082 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表