思科交换机常用命令.docx

上传人:小飞机 文档编号:5287343 上传时间:2023-06-22 格式:DOCX 页数:33 大小:263.63KB
返回 下载 相关 举报
思科交换机常用命令.docx_第1页
第1页 / 共33页
思科交换机常用命令.docx_第2页
第2页 / 共33页
思科交换机常用命令.docx_第3页
第3页 / 共33页
思科交换机常用命令.docx_第4页
第4页 / 共33页
思科交换机常用命令.docx_第5页
第5页 / 共33页
亲,该文档总共33页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《思科交换机常用命令.docx》由会员分享,可在线阅读,更多相关《思科交换机常用命令.docx(33页珍藏版)》请在三一办公上搜索。

1、Cisco交换机命令大总结cisco交换机还是比较常用的,于是我研究了一下Cisco交换机命令的大总结,在这里 拿出来和大家分享一下,希望对大家有用。我所针对的都是Cisco的设备而言的,华为的可 以跟据手册来查,配置都是差不多的,这里华子就不多写华为的设备了,了解的也不是很多。Cisco交换机命令之使用Telnet远程式管理switch(config)#interface vlan 1 进入 vlan 1switch(config-if)#ip address 设置 IP 地址switch(config-if)#ip default-gateway 设置默认网关switch(config)#

2、line vty 0 4 进入虚拟终端switch(config-line)#login 允许登录switch(config-line)#password xx 设置登录口令switch#exit 返回命令Cisco交换机命令之控制台口令switch(config)#line console 0 进入控制台口switch(config-line)#login 允许登录switch(config-line)#password xx 设置登录口令switch#exit 返回命令Cisco交换机命令之基本接口配置switch(config)#interface f0/1 进入 f0/1 接口swit

3、ch(config-if)#duplex full 配置全双工模式switch(config-if)#speed 100 配置速率switch(config-if)#description to * 接口描述switch(config)#ip domain-name *.com 设置或名服务器switch(config)#mac-address-table aging-time 设置 mac 表超时时间switch#write保存配置信息switch#copy running-config startup-config 保存当前配置 nvramswitch#erase startup-conf

4、ig 清除配置文件Cisco交换机命令之交换机VLAN设置: switch#vlan database 进入 VLAN 设置switch(vlan)#vlan 2 建 VLAN 2switch(vlan)#name 名字建 VLAN 2 的名称 switch(vlan)#no vlan 2 删 vlan 2注:删除vlan时原属于此vlan的端口处于非激活状态,直到重新分配为止。 switch(config)#int f0/1 进入端口 1switch(config-if)#switchport mode access 当前端口工作莫试 switch(config-if)#switchport

5、 access vlan 2 当前端口加入 vlan 2 switch(config-if)#switchport mode trunk 设置为干线 switch(config-if)#switchport trunk encapsulation dot1q 设置 vlan 中继协议 switch(config-if)#no switchport mode 或(switchport mode access)禁用干线 switch(config-if)#switchport trunk allowed vlan add 1, 2 ;从 Trunk 中添加 vlans switch(config-

6、if)#switchport trunk allowed vlan remove 1, 2 从 Trunk 中删除 vlans switch(config-if)#switchport trunk pruning vlan remove 1, 2 ;从 Trunk 中关闭局部 修剪Cisco交换机命令之以太网通道配置switch(config)#interface range fasternet0/1 - 2 将 fasternet0/1 和 0/2 口捆绑 switch(config-if)#channel-group 1 mode on 配置以太通道模式 switch(config-if)

7、#port-channel load-balance dst-mac | src-mac在链路间实现负载 均衡switch#show etherchannel 1 summary 查看通道信息 switch#show etherchannel load-balance 查看通道信息Cisco交换机命令之vtp配置switch(config)#vtp domain 设置 vtp 域名switch(config)#vtp password 设置 vtp 密码switch(config)#vtp mode server 设置 vtp 服务器模式 switch(config)#vtp mode cli

8、ent 设置 vtp 客户机模式 switch(config)#vtp mode transparent 设置 vtp 透明模式 switch(config)#vtp version 设置 vtp 版本switch(config)#vtp pruning 启用 vtp 修解switch(config)#no vtp pruning 关闭 vtp 修解注:要想从vtp中减少一台交换机只需将该交换机vtp名更改Cisco交换机命令之生成树stp:switch(config)#spanning-tree vlan 启用 stp 生成树(基于 vlan)switch(config)#spanning-

9、tree vlan root primary 指定根交换机(基于 vlan) switch(config)#spanning-tree vlan root secondary 指定备用根交换机(基于 vlan) switch(config)#spanning-tree vlan priority 指定交换机优先级(基于 vlan) switch(config)#no spanning-tree vlan priority将交换机的优先级恢复默认值(基于 vlan)switch(config-if)#spanning-tree vlan cost 指定端口成本(起用 trunk 的端口模式下)

10、switch(config-if)#spanning-tree vlan port-prioty 指定交换机端口优先级(基于 vlan) switch(config-if)#spanning-tree portfast配置速端口(连接终端设备的端口状态)如pc 机switch(config)#spanning-tree uplinkfast 配置上行速端口switch(config)#spanning-tree vlan hello-time 配置交换机 hello 时间(基于 vlan) switch(config)#spanning-tree vlan forward-time 修改转发延

11、迟计时器(基于 vlan) switch(config)#spanning-tree vlan max-time 修改最大老化时间(基于 vlan) switch#show spanning-tree summery 检测 vlan 生成树配置switch#show spanning-tree vlan detail 浏览详细生成树配置信息switch#show spanning-tree interface detail 浏览详细生成树端口配置信息Cisco交换机命令之交换机显示命令:switch#show vtp status 查看 vtp 配置信息switch#show running-

12、config 查看当前配置信息switch#show vlan 查看 vlan 配置信息switch#show interface 查看端口信息switch#show int f0/0查看指定端口信息switch#dir flash:查看闪存switch#show version 查看当前版本信息switch#show mac-address-table aging-time 查看 mac 超时时间switch#show cdp cisco设备发现协议(可以查看聆接设备)switch#show cdp traffic杳看接收和发送的cdp包统计信息switch#show cdp neighbo

13、rs查看与该设备相邻的cisco设备switch#show interface f0/1 switchport 查看有关 switchport 的配置switch#show cdp neighbors查看与该设备相邻的cisco设备交换机口令设置:(我所针对的都是cisco的设备而言的,华为的可以跟据手册来查,配置都是差不多的, 这里华子就不多写华为的设备了,了解的也不是很多)switchenable进入特权模式switch#config terminal进入全局配置模式switch(config)#hostname设置交换机的主机名switch(config)#enable secret x

14、xx 设置特权加密口令switch(config)#enable password xxa 设置特权非密口令使用Telnet远程式管理switch(config)#interface vlan 1 进入 vlan 1switch(config-if)#ip address 设置 IP 地址switch(config-if)#ip default-gateway 设置默认网关switch(config)#line vty 0 4 进入虚拟终端switch(config-line)#login 允许登录switch(config-line)#password xx 设置登录口令switch#exi

15、t返回命令控制台口令switch(config)#line console 0 进入控制台口switch(config-line)#login 允许登录switch(config-line)#password xx 设置登录口令switch#exit返回命令基本接口配置switch(config)#interface f0/1 进入 f0/1 接口switch(config-if)#duplex full 配置全双工模式switch(config-if)#speed 100 配置速率switch(config-if)#description to * 接口描述switch(config)#ip

16、 domain-name *.com 设置或名服务器switch(config)#mac-address-table aging-time 设置 mac 表超时时间switch#write保存配置信息switch#copy running-config startup-config 保存当前配置 nvramswitch#erase startup-config 清除配置文件交换机VLAN设置:switch#vlan database 进入 VLAN 设置switch(vlan)#vlan 2 建 VLAN 2switch(vlan)#name 名字建 VLAN 2 的名称switch(vlan

17、)#no vlan 2 册。vlan 2注:删除vlan时原属于此vlan的端口处于非激活状态,直到重新分配为止switch(config)#int f0/1 进入端口 1switch(config-if)#switchport mode access 当前端口工作莫试switch(config-if)#switchport access vlan 2 当前端口加入 vlan 2switch(config-if)#switchport mode trunk 设置为干线switch(config-if)#switchport trunk encapsulation dot1q 设置 vlan 中

18、继协议switch(config-if)#no switchport mode 或(switchport mode access)禁用干 线switch(config-if)#switchport trunk allowed vlan add 1, 2 ;从 Trunk 中添加 vlansswitch(config-if)#switchport trunk allowed vlan remove 1 2 ;从 Trunk 中删 除 vlansswitch(config-if)#switchport trunk pruning vlan remove 1 2 ;从 Trunk 中关 闭局部修剪以

19、太网通道配置switch(config)#interface range fasternet0/1 - 2 将 fasternet0/1 和 0/2 口捆绑(成双不成单)switch(config-if)#channel-group 1 mode on 配置以太通道模式switch(config-if)#port-channel load-balance dst-mac | src-mac在 链路间实现负载均衡switch#show etherchannel 1 summary 查看通道信息switch#show etherchannel load-balance 查看通道信息vtp配置swi

20、tch(config)#vtp domain 设置 vtp 域名switch(config)#vtp password 设置 vtp 密码switch(config)#vtp mode server 设置 vtp 服务器模式switch(config)#vtp mode client 设置 vtp 客户机模式switch(config)#vtp mode transparent 设置 vtp 透明模式switch(config)#vtp version 设置 vtp 版本switch(config)#vtp pruning 启用 vtp 修解switch(config)#no vtp prun

21、ing 关闭 vtp 修解注:要想从vtp中减少一台交换机只需将该交换机vtp名更改生成树stp :switch(config)#spanning-tree vlan 启用 stp 生成树(基于 vlan)switch(config)#spanning-tree vlan root primary 指定根交换机(基于 vlan)switch(config)#spanning-tree vlan root secondary 指定备用根交换机(基于 vlan)switch(config)#spanning-tree vlan priority 指定交换机优先级(基于 vlan)switch(co

22、nfig)#no spanning-tree vlan priority 将交换机的优先级恢复默认值 (基于vlan)switch(config-if)#spanning-tree vlan cost 指定端口成本(起用 trunk 的端口模式 下)switch(config-if)#spanning-tree vlan port-prioty 指定交换机端口优先级(基于 vlan)switch(config-if)#spanning-tree portfast 配置速端口(连接终端设备的端口状态) 如pc机switch(config)#spanning-tree uplinkfast 配置上

23、行速端口注:在配置上行速端口前要先将基于vlan上的网桥优先级,网桥成本恢复默认值。起 用了该命令后在进行优先级更改,switch(config)#spanning-tree vlan hello-time 配置交换机 hello 时间(基于 vlan)switch(config)#spanning-tree vlan forward-time 修改转发延迟计时器(基于 vlan)switch(config)#spanning-tree vlan max-time 修改最大老化时间(基于 vlan)注:vlan为可选参数,当没有该参数时将修改所有vlan网桥的优先级及所有的vlan 端口成本s

24、witch#show spanning-tree summery 检测 vlan 生成树配置switch#show spanning-tree vlan detail 浏览详细生成树配置信息switch#show spanning-tree interface detail 浏览详细生成树端口配置信息交换机显示命令:switch#show vtp status 查看 vtp 配置信息switch#show running-config 查看当前配置信息switch#show vlan 查看 vlan 配置信息switch#show interface 查看端口信息switch#show int

25、 f0/0查看指定端口信息switch#dir flash:查看闪存switch#show version查看当前版本信息switch#show mac-address-table aging-time 查看 mac 超时时间switch#show cdp cisco设备发现协议(可以查看聆接设备)switch#show cdp traffic杳看接收和发送的cdp包统计信息switch#show cdp neighbors 查看与该设备相邻的cisco设备switch#show interface f0/1 switchport 查看有关 switchport 的配置switch#show

26、cdp neighbors 查看与该设备相邻的cisco设备2950交换机密码恢复拨下交换机的电源线用手按在mode按键上,插上电源线。看到出现 flash_init load_helper boot switch:画面时松开 mode 键在switch:后执行flash_init命令查看flash中的文件把config.text 文件改名为config.old rename flash:config.text flash:config.old执行boot命令启动交换机交换机出现是否进入配置的对话,执行no命令进入特权模式查看flash文件 执行enable在switch#show flash

27、:把 config.old 改为 config.text rename flash:config.old flash:config.text把 config.text 考入系统的 running-configcopy flash:config.text system:running-config重新设置密码并存盘sw2912_a#erase nvram全部清除交换机的所有配置 sw2912_a#reload 重新启动交换机(初始提示符为switch ) sw2912_a#int vlan 1 进入vlan 1特殊接口配置模式 sw2912_a#ip address 192.168.15.1 2

28、55.255.255.0 设置交换机的管理IP地址 sw2912_a#ip default-gateway 192.168.198.2 设置交换机的网关地址 sw2912_a#ip domain-name 设置交换机所连域的域名 sw2912_a#ip name-server 218.87.18.230 设置交换机所连域的域名服务器IP sw2912_a#show int vlan 1查看交换机的VLAN 1特殊接口配置信息 sw2912_a#show run 查看交换机的当前运行配置等全部信息交换机的端口和MAC地址表的设置 1924交换机配置端口属性sw1924_b#conf t sw19

29、24_b#interface ethernet 0/1 进入第1个端口 sw1924_b#description sw1924_b-e0/1-pc1 给端口写入注释信息 sw1924_b#duplex auto/full/full-flow-control/half 设置端口的工作模式 sw1924_b#port secure 启用端口安全性 sw1924_b#port secure max-mac-count 1设置该端口允许对应的MAC地址数(默认132个) sw1924_b#sh mac-address-table security 查看端口安全性2912交换机配置端口属性sw1912_

30、a#conf t 进入全局配置模式 sw1912_a#interface fastethernet 0/1 进入第1个端口 sw1912_a#description sw2912_a-f0/1-pc1 给端口写入注释信息sw1912_a#duplex auto/full/half 设置端口的工作模式 sw1912_a#port security 启用端口安全性 sw1912_a#port security max-mac-count 1 设置该端口允许对应的MAC地址数(默认132个) sw1912_a#end 返回特权模式 sw1912_a#sh port security 查看端口安全性配

31、置和查看MAC地址表1924交换机配置MAC地址表sw1924_b#mac-address-table aging-time 600 设置动态地址超时时间sw1924_b#mac-address-table permanent 0000.0cdd.5a4d e0/3 定义永久MAC地址(绑定MAC地址)sw1924_b#mac-address-table restricted static 0000.0cdd.aaed e0/6 e0/7定义受限MAC地址sw1924_b#address-violation disable/ignore/suspend 定义地址安全违规 sw1924_b#sh

32、ow mac-address-table 查看上述配置 sw1924_b#clear mac-addr restric static 清除受限MAC地址表项2912交换机配置MAC地址表sw2912_a#mac-address-table aging-time 700 设置动态地址超时时间sw2912_a#mac-address-table static 0000.0cdd.5a4d e0/3定义永久MAC地址(绑定MAC地址) sw2912_a#mac-address-table secure 00d0.f80d.3333 f0/3 vlan 1 定义受限MAC地址 sw2912_a#por

33、t security action shutdown/trap 定义地址安全违规 sw2912_a#show port security 查看上述配置配置 VTP、VLAN、VLAN Trunk 和 STP 配置VTPsw1924_a#conf t sw1924_a#vtp server定义VTP的工作模式sw1924_a#vtp domain cisco定义VTP的域名sw1924_a#trunk on启用干道sw1924_b#vtp domain cisco加入VTP域sw1924_b#vtp client定义VTP的工作模式sw1924_b#trunk on启用干道sw1924_a#sh

34、ow trunk bsw1924_a#show trunk b allowed-vlans 查看干道信息配置VLANsw1924_a#vlan 10 dept1 sw1924_a#vlan 20 dept2 sw1924_a#vlan 30 dept3 sw1924_a#vlan 40 dept4定义所需VLANsw1924_a#show vlan查看VLAN信息sw1924_b#show vlansw1924_b#show vtp查看VTP的信息 sw1924_b#int e0/1 sw1924_b#vlan-membership static 10 sw1924_b#int e0/2 sw

35、1924_b#vlan-membership static 20sw1924_b#int e0/3sw1924_b#vlan-membership static 30 sw1924_b#int e0/4sw1924_b#vlan-membership static 40 把接口划入各自VLAN配置 spanning treesw1924_b#spantree 1 启用生成树协议 sw1924_b#sh spantree 1查看生成树信息 sw1924_b#no spantree 1 关闭生成树协议 sw1924_b#sh spantree 1查看生成树信息交换机上屏蔽个别MAC地址方法conf

36、igure terminalinterface gigabitEthernet 0/20 switchport sw mode acc sw port-secsw port-sec mac-add macaddresssw port-sec max 1sw port-sec violation restrict部分命令缩写要看详细安tabCisco Catalyst交换机删除startup-config并重启后,vlan信息仍存在的原因与解决今天在一个国外站点上看到这么一篇文章。作者介绍说,当你删除Cisco Catalyst交换机的startup-config配置文件之后,再reload交换

37、机,你会发现交换机上的vlan信息仍然存在,并没有被 删除。我用Packet Tracer 5.0亲自做了下实验假设有三个用户自建vlan 10/20/30,结果如下:AS01#show vlan briefVLAN NameStatus Ports1 defaultactive Fa0/4, Fa0/5, Fa0/6, Fa0/7Fa0/8, Fa0/9, Fa0/10, Fa0/11Fa0/12, Fa0/13, Fa0/14, Fa0/15Fa0/16, Fa0/17, Fa0/18, Fa0/19Fa0/20, Fa0/21, Fa0/22, Fa0/2310 dianjixiacti

38、ve Fa0/120 caihuaxiactive Fa0/230 zihuanxiactive Fa0/3100 adminactive1002 fddi-defaultactive1003 token-ring-defaultactive1004 fddinet-defaultactive1005 trnet-defaultactiveAS01#erase startup-config (PS:这里用 write erase 命令效果一样!)Erasing the nvram filesystem will remove all configuration files! Continue?

39、 confirmOKErase of nvram: complete%SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvramAS01#reloadProceed with reload? confirm%SYS-5-RELOAD: Reload requested by console. Reload Reason: Reload Command.SwitchenSwitch#show vlan briefVLAN NameStatus Ports1 defaultactive Fa0/1, Fa0/2, Fa0/3, Fa0/4Fa0/5

40、, Fa0/6, Fa0/7, Fa0/8Fa0/9, Fa0/10, Fa0/11, Fa0/12Fa0/13, Fa0/14, Fa0/15, Fa0/16Fa0/17, Fa0/18, Fa0/19, Fa0/20Fa0/21, Fa0/22, Fa0/23, Fa0/24Gig1/210 dianjixiactive20 caihuaxiactiveactive30 zihuanxi100 adminactive1002 fddi-defaultactive1003 token-ring-defaultactive1004 fddinet-defaultactive1005 trnet

41、-defaultactive不过,startup-config文件删除,没有任何端口加入vlan,因此对于vlan 10/20/30没有相关端口 信息。但是,从以上例子中,可以清楚地看到之前创建并激活的vlan并没有随startup-config的删除而 删除。这是为什么呢?文章作者解释,自建的vlan信息实际上保存在交换机Flash的vlan.dat文件内, 该文件不会在删除startup-config的时候被删除,也不会在reload之后清空内容或被删除。以致当重 启交换机后,仍然可以从该文件中读取之前保存的vlan信息。该文件需要被手工删除。这里还需要注意的是,删除该文件时,需要确认两遍

42、,提示是否删除文件时,无需输入y,直接 按回车即可。如果你输入y,则相当于告诉系统你要删除的是名为y的文件,删除会失败。如下所示: Switch#delete vlan.datDelete filename vlan.dat?yDelete flash:/y? confirm%Error deleting flash:/y (No such file or directory)正确的做法就是:Switch#delete vlan.datDelete filename vlan.dat?Delete flash:/vlan.dat? confirm好了,现在重启,之后再来show 一把:Swit

43、ch#sh vlan bVLAN NameStatus Ports1 defaultactive Fa0/1, Fa0/2, Fa0/3, Fa0/4Fa0/9, Fa0/10, Fa0/11, Fa0/12Fa0/13, Fa0/14, Fa0/15, Fa0/16Fa0/17, Fa0/18, Fa0/19, Fa0/20Fa0/21, Fa0/22, Fa0/23, Fa0/24Gig1/21002 fddi-defaultactive1003 token-ring-defaultactive1004 fddinet-defaultactive1005 trnet-defaultacti

44、ve此时,vlan 10/20/30才真正被删除了。老实说,关于这个问题,本人以前也从来没有考虑过, 注意细小的地方,往往会帮助你更多地了解设备,希望本文对大家的日常工作以及备考思科认证有所 帮助。Cisco IOS基本命令集(1)一、基本路由器的检验命令show versionshow processesshow protocolsshow memshow ip routeshow startup-configshow running-configshow flashshow interfaces二、基本路由配置命令进入:config terminal/memory/network配置网络时

45、常采用的命令:copy和load1. 标识:hostname标识名2. 启动标识:banner启动标识3. 接口: interface 端口号4. 密码:line 0 6loginpasswd 口令enable password/secret 口令5. 接口:1)配置端口interface 端口号clock rate时钟速率(64000) /*在串口中配置*/bandwidth带宽(缺省56) /*在串口中配置*/media-type介质类型/*在以太网口上*/early-token release /* 在令牌环网口上 */ring-speed 16 /*在令牌环网口上*/no shutdo

46、wnwrite memory2)检验端口show interfacesshow controllers6. 配置环境1)引导方式 boot system flash IOS-filenameboot system tftp lOS-filename tftp-address boot system rom2)配置 Register 值config-register 0x21027. 查看邻居路由show cdp interfaceshow cdp neighbors detailshow cdp entry routerA8. IP Address 配置Ip address网络地址掩码Ip h

47、ost 主机名 addressIp name-server服务器地址1服务器地址2。Ip domain-lookup nsapShow hostsPing主机名/IP地址Trace主机名/IP地址一、基本路由器的检验命令show versionshow processesshow protocolsshow memshow ip routeshow startup-configshow running-config show flashshow interfaces 二、基本路由配置命令进入:config terminal/memory/network配置网络时常采用的命令:copy和load1. 标识:hostname标识名2. 启动标识:banner启动标识3. 接口: interface 端口号4. 密码:line 0

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号