收藏 分销(赏)

思科指令汇总.docx

上传人:仙人****88 文档编号:9490899 上传时间:2025-03-28 格式:DOCX 页数:50 大小:7.81MB 下载积分:10 金币
下载 相关 举报
思科指令汇总.docx_第1页
第1页 / 共50页
思科指令汇总.docx_第2页
第2页 / 共50页


点击查看更多>>
资源描述
交换机、路由器一般设置 让交换机恢复到出厂设置 SW#erase startup-config SW#delete vlan.dat SW#reload 配置控制端口console,不用认证直接进入 R(config)#line console 0 R(config-line)#no login 配置控制端口console密码 R(config)#line console 0 R(config-line)#password lab R(config-line)#login 配置控制端口console,使用“用户名+密码”本地认证 R(config)#username yangbang password ccna R(config)#line console 0 R(config-line)#login local 配置虚拟端口VTY,不用认证直接进入 R(config)#line vty 0 4 R(config-line)#no login 配置虚拟端口VTY,密码 R(config)#line vty 0 4 R(config-line)#password lab R(config-line)#login 配置虚拟端口VTY,使用“用户名+密码”本地认证 R(config)#username yangbang password ccna R(config)#line vty 0 4 R(config-line)#login local 开启R的telnet服务 R(config)#username yangbang password ccna R(config)#line vty 0 4 R(config-line)#login local R(config-line)#transport input telnet 开启R的ssh服务 R(config)#username yangbang password ccna R(config)#line vty 0 4 R(config-line)#login local R(config-line)#transport input ssh 配置明文特权密码 R(config)#enable password cisco 配置密文特权密码 R(config)#enable secret cisco123 设置密码加密 R(config)#service password-encryption 配置寄存器值改成0x2142 R(config)#config-register 0x2142 //启动时不加载startup-config 配置寄存器值配置为0x2102 R(config)#config-register 0x2102 //启动时加载startup-config 设置端口为默认配置 R(config)#default interface #/# 设置控制台会话时间,并重新显示中断的控制台输入 R(config)#line console 0 R(config-line)#exec-timeout 20 30 R(config-line)#logging synchronous SW#show controller s0/0 //可显示设备的串行接口是DTE还是DCE Frame-relay, HDLC, PPP Ø 知识点Ethernet:以太网2层协议,具有ARP、IP与MAC; Ø 知识点Frame Relay:帧中继,2层协议,具有IARP、IP与DLCI; 配置帧中继交换机(server端)接口 FRSW(config)#frame-relay switching //设置为帧中继交换机 FRSW(config-if)#encapsulation frame-relay FRSW(config-if)#frame-relay intf-type dce FRSW(config-if)#clock rate # FRSW(config-if)#frame-relay route INPUT_DLCI# interface OUTPUT_INTERFACE OUTPUT_DLCI# R#show frame-relay route Ø 知识点LMI:本地管理接口:1、ANSI:附件D;2、ITU-T:Q933A,附件A;3、CISCO; Ø 知识点DLCI:数据链路链接标识,10字节,0~1023,其中DLCI16~1007à客户端,DLCI0àLMI Q933A、LMI ANSI,DLCI1023àCISCO LMI; FRSW(config-if)#ip split-horizon //开启水平分割,一般交换机是默认自动开启的,但是帧中继交换机是默认关闭的,这样进入这个接口的路由信息,不会再次流出这个接口 Ø 知识点: FRSW(config-if)#frame-relay lmi-type [cisco | ansi | q933a] //思科设备默认为cisco,当帧中继交换机接口选择一种lmi类型后,则客户端接口会自动配置跟随这种lmi类型 Ø 知识点: 一、在动态映射的帧中继上,实施 OSPF R(config-if)#encapsulation frame-relay R(config-if)#frame-relay inverse-arp R(config-if)#ip address x.x.x.x m.m.m.m R(config-if)#ip ospf network [broadcast | point-to-point | point-to-multipoint] 二、在静态映射(非广播)的帧中继上,实施 OSPF R(config-if)#encapsulation frame-relay R(config-if)#no frame-relay inverse-arp R(config-if)#ip address x.x.x.x m.m.m.m R(config-if)#frame-relay map ip y.y.y.y DLCI# //y.y.y.y为对端ip地址 R(config-if)#ip ospf network point-to-multipoint non-broadcast R(config)#router ospf ProID# R(config-router)#neighbor y.y.y.y 三、点对点子接口的帧中继上,实施 OSPF R(config-if)#encapsulation frame-relay R(config-if)#no frame-relay inverse-arp R(config-if)#interface serial X/X.X point-to-point R(config-if)#ip address x.x.x.x m.m.m.m R(config-if)#frame-relay interface-dlci DLCI# 配置帧中继客户端静态映射 R(config-if)#no frame-relay inverse-arp //关闭端口的反向ARP功能 R(config-if)#frame-relay map ip 对端1x.x.x.x 本地dlci#1 [broadcast] R(config-if)#frame-relay map ip 对端2x.x.x.x 本地dlci#2 [broadcast] //如果此设备对着多台设备 …. …. …. …. …. …. R(config-if)#frame-relay map ip 对端nx.x.x.x 本地dlci#n [broadcast] 配置帧中继客户端的point-to-point子接口静态映射 R(config)#interface serial #/# R(config-if)#encapsulation frame-relay R(config-if)#no frame-relay inverse-arp R(config-if)#no shutdown R(config-if)#interface serial #/#.# point-to-point R(config-subif)#ip address x.x.x.x n.n.n.n R(config-subif)#frame-relay interface-dlci 本地dlci# //对于点对点类型接口,不需要说明对端的地址,因为对端只有一台设备,因此不用静态映射,只要给出此接口DLCI号 配置帧中继客户端的multipoint子接口静态映射 R(config)#interface serial #/# R(config-if)#encapsulation frame-relay R(config-if)#no frame-relay inverse-arp R(config-if)#no shutdown R(config-if)#interface serial #/#.# multipoint R(config-subif)#ip address x.x.x.x n.n.n.n R(config-subif)#frame-relay map ip 对端1x.x.x.x 本地dlci#1 [broadcast] R(config-subif)#frame-relay map ip 对端2x.x.x.x 本地dlci#2 [broadcast] …. …. …. …. …. …. R(config-subif)#frame-relay map ip 对端nx.x.x.x 本地dlci#n [broadcast] R#show frame-relay pvc Ø 知识点HDLC:高级数据链路控制,是设备串行接口的默认数据封装模式,2层协议,具有Address与Protocol,没有2层地址,具有压缩功能,链路之间使用keepalive为此链接,keepavlie默认为10秒,死亡时间为30秒; 1、 ISO HDLC,基于IBM; 2、 CISCO HDLC; R(config-if)#encapsulation hdlc //开启HDLC R(config-if)#keepavlie # //设置keepavlie时间,两个接口之间的keepavlie要一样 R(config-if)#compress stac //开启压缩,对端也必须开启 Ø 知识点PPP:Point to Point Protocol,支持压缩、认证(PAP与CHAP),一般用于远程接入,要向ISP申请租用或Dialer,比如电信拨号上网使用PPPoE(这里o为over,E为Ethernet); 1、 LCP:Link Control Protocol,用于建立PPP; 2、 NCP:Network Control Protocol,PPP建立好后,NCP告知对端自己的端口地址; R(config-if)#encapsulation ppp //开启PPP封装 R(config-if)#no peer neighbor-route //在PPP封装中,会将对端接口的地址作为一个32位主机地址存放在自己的路由表中,比如本设备接口地址10.10.10.1/24,对端接口地址10.10.10.2/24,启用ppp封装后,设备路由表会显示10.10.10.0/24网段路由,同时也显示对端接口的地址作为一个32位主机地址10.10.10.2/32 配置PPP服务器端的PAP认证开启 R(config)#username user001 password yangbang R(config-if)#ppp authentication pap //pap为明文的 配置PPP客户端的的PAP验证 R(config-if)#ppp pap sent-username user001 password yangbang 一、chap单向认证: 服务器端R1配置: R1(config)#username aaa password yangbang R1(config)#interface s#/# R1(config-if)#encapsulation ppp R1(config-if)#ppp authentication chap 客户端R2配置: R2(config)#interface s#/# R2(config-if)#encapsulation ppp R2(config-if)#ppp chap hostname aaa R2(config-if)#ppp chap password yangbang 二、chap双向认证1: 服务器端R1配置: R1(config)#username aaa password yangbang1 R1(config)#interface s#/# R1(config-if)#encapsulation ppp R1(config-if)#ppp authentication chap R1(config-if)#ppp chap hostname bbb R1(config-if)#ppp chap password yangbang2 客户端R2配置: R2(config)#username bbb password yangbang2 R2(config)#interface s#/# R2(config-if)#encapsulation ppp R2(config-if)#ppp authentication chap R2(config-if)#ppp chap hostname aaa R2(config-if)#ppp chap password yangbang1 三、chap双向认证2:(在CHAP认证中,也可以在双方设置认证的用户名为对方设备的hostname,并设置相同的密码。这样,就不需要在端口上使用命令ppp chap hostname和ppp chap password) 服务器端R1配置: R1(config)#username R2 password yangbang R1(config)#interface s#/# R1(config-if)#encapsulation ppp R1(config-if)#ppp authentication chap 客户端R2配置: R2(config)#username R1 password yangbang R2(config)#interface s#/# R2(config-if)#encapsulation ppp R2(config-if)#ppp authentication chap PPP 认证监控 R#debug ppp [authentication | negotiation | packet] PPP over Frame-relay实例: R1(config)#username R2 password yangbang R1(config)#interface virtual-template 1 //创建虚拟模版 R1(config-if)#ip address 12.1.1.1 255.255.255.0 R1(config-if)#encapsulation ppp //默认就是ppp封装 R1(config-if)#ppp authentication chap //ppp的chap认证 R1(config)#interface s1/0 R1(config-if)#encapsulation frame-relay R1(config-if)#no frame-relay inverse-arp R1(config-if)#frame-relay interface-dlci 102 ppp virtual-template 1 //在物理接口s1/0上绑定DLCI102,绑定PPP,绑定virtual-template 1 R1(config-if)#frame-relay map ip 12.1.1.2 102 broadcast R2(config)#username R1 password yangbang R2(config)#interface virtual-template 1 R2(config-if)#ip address 12.1.1.2 255.255.255.0 R2(config-if)#encapsulation ppp R2(config-if)#ppp authentication chap R2(config)#interface s1/0 R2(config-if)#encapsulation frame-relay R2(config-if)#no frame-relay inverse-arp R2(config-if)#frame-relay interface-dlci 201 ppp virtual-template 1 R2(config-if)#frame-relay map ip 12.1.1.1 201 broadcast EtherChannel, Trunk Ø 知识点EtherChannel的2种模式: 1、 pagp:思科私有,desirable主动协商,auto被动协商,两端不能同时为auto; 2、 lacp:国际共有,active主动协商,passive被动协商,两端不能同时为passive; Ø 知识点Trunk的4种状态: 1、 off:关闭,端口为access,无DTP信息; 2、 on:主动状态,一般使用这种状态,使用指令switchport mode trunk定义,系统默认状态; 3、 desirable:主动状态,自动进行协商,使用指令switchport mode dynamic desirable定义; 4、 auto:被动状态,两端不能同时autoS,使用指令switchport mode dynamic auto定义; 配置无动态协商的EtherChannel SW(config)#interface range Fa#/#-# SW(config-if-range)#switchport trunk encapsulation [dot1q | isl | nonegotiate] //isl思科私有 SW(config-if-range)#switchport mode [trunk | dynamic desirable | dynamic auto] SW(config-if-range)#switchport nonegotiate //两端确定都是trunk时,禁止DTP交换信息,达到节约带宽的目的 SW(config-if-range)#channel-group 虚拟端口号 mode on 配置基于pagp的EtherChannel SW(config)#interface range Fa#/#-# SW(config-if-range)#switchport trunk encapsulation [dot1q | isl | nonegotiate] SW(config-if-range)#switchport mode [trunk | dynamic desirable | dynamic auto] SW(config-if-range)#switchport nonegotiate SW(config-if-range)#channel-protocol pagp SW(config-if-range)#channel-group 虚拟端口号 mode auto | desirable 配置基于LACP的EtherChannel SW(config)#interface range Fa#/#-# SW(config-if-range)#switchport trunk encapsulation [dot1q | isl | nonegotiate] SW(config-if-range)#switchport mode [trunk | dynamic desirable | dynamic auto] SW(config-if-range)#switchport nonegotiate SW(config-if-range)#channel-protocol lacp SW(config-if-range)#channel-group 虚拟端口号 mode active | passive 在虚拟端口中,指定native vlan为10,允许除了99以外的所有vlan SW(config)#interface port-channel虚拟端口号 SW(config-if)#switchport trunk native vlan 10 //接口的native vlan设置为vlan10 SW(config-if)#switchport trunk allowed vlan except 99 将交换机的EtherChannel的负载均衡模式改为基于源目的MAC地址 SW(config)#port-channel load-balance src-dst-mac 配置SW的Po1,指定IP地址为192.168.100.1/24 SW(config)#interface port-channel 1 SW(config-if)#ip address 192.168.100.1 255.255.255.0 配置多层交换机的路由功能,实现vlan间路由 SW(config)#ip routing SW(config)#interface vlan #1 SW(config-if)#ip address x.x.x.x m.m.m.m SW(config)#interface vlan #2 SW(config-if)#ip address y.y.y.y m.m.m.m 配置交换机的路由接口 SW(config-if)#no switchport SW(config-if)#ip address x.x.x.x m.m.m.m 配置三层的EtherChannel SW(config)#interface range 端口号#a/#1-#2 SW(config-if-range)#no switchport SW(config-if-range)#channel-protocol lacp | pagp SW(config-if-range)#channel-group #b mode active | passive | auto | desirable SW(config-if-range)#exit SW(config)#interface port-channel #b SW(config-if)#ip address x.x.x.x m.m.m.m Vlan, VTP, SPAN 进入vlan数据库管理模式 SW#vlan database Ø 知识点:当与交换机SW连接的路由器R使用虚拟子接口时,交换机接口必须使用trunk模式; R(config)#int f0/0 //配置两个子接口f0/0.12 与f0/0.13 R(config-if)#no shut R(config-if)#int f0/0.12 R(config-subif)# encapsulation dot1Q 10 //10为vlan10, R(config-if)#int f0/0.13 R(config-subif)# encapsulation dot1Q 20 //20为vlan20 SW(config-if)#switchport trunk encapsulation dot1q //在交换机的一个接口上,可以通过多个vlan,就必须配置为trunk模式 SW(config-if)#switchport mode trunk SW(config-if)#switchport trunk allowed vlan 10,20 //设置Trunk规则,只允许vlan 10,20 通信 SW(config-if)#duplex full SW(config-if)#speed 100 指定交换机VTP域名yangbang SW#delet flash:vlan.dat //删除之前的VTP数据库 SW(config)#vtp domain yangbang //VTP域名yangbang SW(config)#vtp password ccie //VTP密码ccie 指定交换机VTP 模式为Server | Client SW(config)#vtp mode server | client | transparent SW(config)#vtp pruning //启用VTP修剪,必须在server上启用 SW(config)#macro name SETVLAN//创建名为SETVLAN文本作为脚本,必须在server上使用,在交换机上输入一下文本实现以脚本方式创建vlan 1到vlan n vlan 1 name XXX1 vlan 2 name XXX2 … … … vlan n name XXXn end @ SW(config)#macro global apply SETVLAN //应用名为SETVLAN文本,必须在server上使用 SW#show vtp status 子接口连入vlan100 R(config-subif)#encapsulation dot1Q 100 Ø 知识点:在CCIE中,SW1一般连接内部的设备,SW2连接外部的用户 Ø 知识点SPAN:用来监控交换机上的数据流。把交换机上某些想要被监控端口的数据流COPY或MIRROR一 份,发送给连接在监控端口上的流量分析仪,比如CISCO的IDS或是装了SNIFFER工具的PC。被监控端口和监控端口在同一台交换机上为Local Switched Port Analyzer (LSPAN),在不同的交换机上为Remote Switched Port Analyzer (RSPAN)。RSPAN需要类型为Remote SPAN的vlan用来被监控端口与流量分析仪之间通讯。 SW1(config)#vlan 60 //SW1为server SW1(config-vlan)#remote-span //将vlan 60设置为RSPAN,必须在server上设置 SW2(config)#moniter session 1 source int f0/0 //1为ID号,可任取。f0/0为被监控端口 SW2(config)#moniter session 1 destination remote vlan 60 //链接流量分析仪的监控端口在SW3上,通过vlan 60通讯 SW3(config)#moniter session 1 source remote vlan 60 SW3(config)#moniter session 1 destination int f0/1 //f0/1为链接流量分析仪的监控端口 STP Ø 知识点:STP是把整个交换网络当成一个生成树实例,而PVST是为每个VLAN当作一个生成树实例。PVST+是使用通用的802.1Q中继协议来实现PVST功能的,是PVST的改进版本。但它仍不能在非Cisco设备上支持。Rapid-PVST+又是在PVST+和RSTP两种协议基础上开发的,可以在每个VLAN中有一个快速生成树(RST)实例,并且在VLAN 1上运行的是STP协议,在其他VLAN上运行PVST协议。 将模式设为rapid-pvst(每vlan一个快速生成树) SW(config)#spanning-tree mode [rapid-pvst | pvst | mst] //pvst与pvst+是思科私有的,必须系统中所有的设备上开启。rapid-pvst集成了uplinkfast、backbonefast与portfast。 配置SW 为vlan1的根 SW(config)#spanning-tree vlan 1 root primary 配置SW 为vlan1 的备份根 SW(config)#spanning-tree vlan 1 root secondary 更改SW的vlan1 生成树优先级为0,确保SW成为根 SW(config)#spanning-tree vlan 1 priority 0 更改SW的vlan1的port-priority为18(默认为128) SW(config-if)#spanning-tree vlan 1 port-priority 18 Ø 知识点接口优先级:由两部分组成,1、Port ID,以16为倍数,最大值128,越小越优先,必须在如接口的对端的改;2、Cost Priority,在相同的Port Priority,越小越优先。 SW1(config-if)#spanning-tree vlan 1 port-priority //此端口为SW2入端口的对端 SW2(config-if)#spanning-tree vlan 1 cost 18 //此端口为SW2的入端口 SW(config)#spanning-tree vlan 10 forward-time 6 //将forward delay改为12秒,forward delay=forward time×2=6×2=12 Ø 知识点:当使用SW#show spanning-tree vlan #检查vlan #的生成树,看到某个端口带了“Edge”标记,说明这个接口开启了portfast,并处于access模式。 Ø 知识点portfast:用于交换机接口与主机之间,当交换机配置了portfast属性的接口连接了另一台交换机,收到了bpdu报文,则端口将失去portfast属性。 SW(config-if)#spanning-tree portfast //在接口模式下开启 SW(config)#spanning-tree portfast default //在全局配置模式下开启,使所有access模式的接口成为portfast特性 Ø 知识点uplinkfast:一般是用在具有一个处于block状态端口和一个处于root状态端口的非root bridge交换机上的处于block状态端口。当这个非root bridge交换机通向root bridge的root端口失效了,block端口不要经过50秒直接变为forward状态。 SW(config-if)#spanning-tree uplinkfast Ø 知识点backbonefast:用在系统中所有的交换机上,某个非root bridge交换机A具有一个处于desinated状态端口和一个处于root状态端口,当这个非root bridge交换机A通向root bridge的root端口失效了,则另一个非root bridge交换机B上的block端口不要经过50秒直接变为forward状态。 SW(config)#spanning-tree backbonefast Ø 知识点guard root:当接口开启根防护时,禁止此端口成为root port,使此端口对面的交换机不可能成为root bridge。对于违反规定的接口,接口状态变为root-inconsistent状态,只要接口不再违规,根防护可以自动重新开放接口。 SW(config-if)#spanning-tree guard root //用于非root bridge交换机上的处于block状态端口 Ø 知识点LoopGuard:当由于单向故障时,交换机处于Blocking状态的端口没有收到从对端来的BPDU报文时,Blocking状态的端口立刻改为Loop Inconsistent状态;处于Loop Inconsistent状态的接口再次收到BPDU报文时,接口会自动恢复。 SW(config-if)#spanning-tree loopguard SW(config)#spanning-tree loopguard default Ø 知识点BPDUGuard:只要端口收到BPDU报文,端口就会进入errdisable状态。因此配置了BPDUGuard的端口只能接非交换设备。一旦触发,需要手动进行恢复,除非打开自动恢复机制。 SW(config-if)#spanning-tree bpduguard enable //可以配置或没有配置PortFast特性的接口下开启bpduguard SW(config)#spanning-tree portfast bpduguard default //在全局配置模式下开启,使所有已经配置了PortFast特性的接口成为bpduguard特性 SW(config)#errdisable recovery cause bpduguard //打开由bpduguard产生错误后自动恢复机制 SW(config)#errdisable recovery interval 30 //每隔30秒自动恢复一次 Ø 知识点BPDUFilter:阻止该端口参与任何BPDU报文接收和发送。如果端口收到BPDU报文,这个端口将失去PortFast状态,成为普通端口参与STP。 SW(config-if)#spanning-tree bpdufilter enable //可以配置或没有配置PortFast特性的接口下开启bpdufilter,可以过滤掉进入或出去端口的bpdu SW(config)#spanning-tree portfast bpdufilter default //在全局配置模式下开启,使所有已经配置了PortFast特性的接口成为bpdufilter特性,全局下只能过滤掉出去的 检查接口的生成树详细信息、生成树汇总信息 SW#show spanning-tree 端口号 detail SW#show spanning-tree summary Ø 知识点:1. 共有的MST(IEEE802.1S)à思科的MISTP;2. 共有的CST(IEEE802.1D)à 思科的PVST;3. 共有的RSTP(IEEE802.1W)à思科的PVR
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服