一、引言:为何需要清空配置与恢复密码?
在网络运维工作中,交换机作为核心网络设备,其配置管理至关重要。然而,管理员可能会遇到忘记设备管理密码、或因配置错误导致设备无法正常工作的情况。此时,能够熟练地进行出厂配置清空和密码恢复,是每一位网络工程师必备的核心技能。本文将带领读者通过实战演练,掌握这两种关键操作。
二、准备工作:工具与连接方式
在进行任何配置操作前,正确的准备工作是成功的前提。主要需要以下工具和连接方式:
#publish-mermaid-0-1793638109460{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-0-1793638109460 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-0-1793638109460 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-0-1793638109460 .error-icon{fill:#552222;}#publish-mermaid-0-1793638109460 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-0-1793638109460 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-0-1793638109460 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-0-1793638109460 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-0-1793638109460 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-0-1793638109460 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-0-1793638109460 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-0-1793638109460 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-0-1793638109460 .marker.cross{stroke:#333333;}#publish-mermaid-0-1793638109460 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-0-1793638109460 p{margin:0;}#publish-mermaid-0-1793638109460 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-0-1793638109460 .cluster-label text{fill:#333;}#publish-mermaid-0-1793638109460 .cluster-label span{color:#333;}#publish-mermaid-0-1793638109460 .cluster-label span p{background-color:transparent;}#publish-mermaid-0-1793638109460 .label text,#publish-mermaid-0-1793638109460 span{fill:#333;color:#333;}#publish-mermaid-0-1793638109460 .node rect,#publish-mermaid-0-1793638109460 .node circle,#publish-mermaid-0-1793638109460 .node ellipse,#publish-mermaid-0-1793638109460 .node polygon,#publish-mermaid-0-1793638109460 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-0-1793638109460 .rough-node .label text,#publish-mermaid-0-1793638109460 .node .label text,#publish-mermaid-0-1793638109460 .image-shape .label,#publish-mermaid-0-1793638109460 .icon-shape .label{text-anchor:middle;}#publish-mermaid-0-1793638109460 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-0-1793638109460 .rough-node .label,#publish-mermaid-0-1793638109460 .node .label,#publish-mermaid-0-1793638109460 .image-shape .label,#publish-mermaid-0-1793638109460 .icon-shape .label{text-align:center;}#publish-mermaid-0-1793638109460 .node.clickable{cursor:pointer;}#publish-mermaid-0-1793638109460 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-0-1793638109460 .arrowheadPath{fill:#333333;}#publish-mermaid-0-1793638109460 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-0-1793638109460 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-0-1793638109460 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-0-1793638109460 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-0-1793638109460 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-0-1793638109460 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-0-1793638109460 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-0-1793638109460 .cluster text{fill:#333;}#publish-mermaid-0-1793638109460 .cluster span{color:#333;}#publish-mermaid-0-1793638109460 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-0-1793638109460 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-0-1793638109460 rect.text{fill:none;stroke-width:0;}#publish-mermaid-0-1793638109460 .icon-shape,#publish-mermaid-0-1793638109460 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-0-1793638109460 .icon-shape p,#publish-mermaid-0-1793638109460 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-0-1793638109460 .icon-shape .label rect,#publish-mermaid-0-1793638109460 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-0-1793638109460 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-0-1793638109460 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-0-1793638109460 .node .neo-node{stroke:#9370DB;}#publish-mermaid-0-1793638109460 [data-look=\”neo\”].node rect,#publish-mermaid-0-1793638109460 [data-look=\”neo\”].cluster rect,#publish-mermaid-0-1793638109460 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-0-1793638109460 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-0-1793638109460 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-0-1793638109460 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-0-1793638109460 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-0-1793638109460 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-0-1793638109460 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-0-1793638109460 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-0-1793638109460 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-0-1793638109460 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
准备工具
连接 Console 线
打开终端软件
配置串口参数
成功连接交换机
上图展示了建立带外管理连接的基本流程。首先准备好所有必要的硬件和软件,然后通过 Console 线物理连接设备,接着在终端软件中配置正确的串口参数(如波特率 9600,数据位 8,停止位 1,无校验),最终实现与交换机的通信。
三、实战一:交换机出厂配置清空
清空出厂配置,即将交换机的启动配置文件(startup-config)删除,使设备在下次重启后恢复到出厂默认状态。这通常用于设备回收、测试或彻底重置配置。
#publish-mermaid-1-1793638109486{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-1-1793638109486 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-1-1793638109486 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-1-1793638109486 .error-icon{fill:#552222;}#publish-mermaid-1-1793638109486 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-1-1793638109486 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-1-1793638109486 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-1-1793638109486 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-1-1793638109486 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-1-1793638109486 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-1-1793638109486 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-1-1793638109486 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-1-1793638109486 .marker.cross{stroke:#333333;}#publish-mermaid-1-1793638109486 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-1-1793638109486 p{margin:0;}#publish-mermaid-1-1793638109486 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-1-1793638109486 .cluster-label text{fill:#333;}#publish-mermaid-1-1793638109486 .cluster-label span{color:#333;}#publish-mermaid-1-1793638109486 .cluster-label span p{background-color:transparent;}#publish-mermaid-1-1793638109486 .label text,#publish-mermaid-1-1793638109486 span{fill:#333;color:#333;}#publish-mermaid-1-1793638109486 .node rect,#publish-mermaid-1-1793638109486 .node circle,#publish-mermaid-1-1793638109486 .node ellipse,#publish-mermaid-1-1793638109486 .node polygon,#publish-mermaid-1-1793638109486 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1-1793638109486 .rough-node .label text,#publish-mermaid-1-1793638109486 .node .label text,#publish-mermaid-1-1793638109486 .image-shape .label,#publish-mermaid-1-1793638109486 .icon-shape .label{text-anchor:middle;}#publish-mermaid-1-1793638109486 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-1-1793638109486 .rough-node .label,#publish-mermaid-1-1793638109486 .node .label,#publish-mermaid-1-1793638109486 .image-shape .label,#publish-mermaid-1-1793638109486 .icon-shape .label{text-align:center;}#publish-mermaid-1-1793638109486 .node.clickable{cursor:pointer;}#publish-mermaid-1-1793638109486 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-1-1793638109486 .arrowheadPath{fill:#333333;}#publish-mermaid-1-1793638109486 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-1-1793638109486 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-1-1793638109486 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1-1793638109486 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-1-1793638109486 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1-1793638109486 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-1-1793638109486 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-1-1793638109486 .cluster text{fill:#333;}#publish-mermaid-1-1793638109486 .cluster span{color:#333;}#publish-mermaid-1-1793638109486 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-1-1793638109486 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-1-1793638109486 rect.text{fill:none;stroke-width:0;}#publish-mermaid-1-1793638109486 .icon-shape,#publish-mermaid-1-1793638109486 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1-1793638109486 .icon-shape p,#publish-mermaid-1-1793638109486 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-1-1793638109486 .icon-shape .label rect,#publish-mermaid-1-1793638109486 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1-1793638109486 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-1-1793638109486 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-1-1793638109486 .node .neo-node{stroke:#9370DB;}#publish-mermaid-1-1793638109486 [data-look=\”neo\”].node rect,#publish-mermaid-1-1793638109486 [data-look=\”neo\”].cluster rect,#publish-mermaid-1-1793638109486 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1-1793638109486 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-1-1793638109486 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1-1793638109486 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1-1793638109486 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-1-1793638109486 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1-1793638109486 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-1-1793638109486 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1-1793638109486 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1-1793638109486 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
进入特权模式
进入全局配置
删除启动配置
保存配置
重启设备
完成,恢复出厂状态
上图清晰地展示了清空配置的步骤流程。执行完 reload 命令后,交换机将重启并加载空的启动配置,所有自定义配置将被清除。
交换机用户交换机用户#publish-mermaid-2-1793638109516{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-2-1793638109516 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-2-1793638109516 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-2-1793638109516 .error-icon{fill:#552222;}#publish-mermaid-2-1793638109516 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-2-1793638109516 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-2-1793638109516 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-2-1793638109516 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-2-1793638109516 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-2-1793638109516 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-2-1793638109516 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-2-1793638109516 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-2-1793638109516 .marker.cross{stroke:#333333;}#publish-mermaid-2-1793638109516 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-2-1793638109516 p{margin:0;}#publish-mermaid-2-1793638109516 .actor{stroke:#9370DB;fill:#ECECFF;stroke-width:1;}#publish-mermaid-2-1793638109516 rect.actor.outer-path[data-look=\”neo\”]{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793638109516 rect.note[data-look=\”neo\”]{stroke:#aaaa33;fill:#fff5ad;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793638109516 text.actor>tspan{fill:black;stroke:none;}#publish-mermaid-2-1793638109516 .actor-line{stroke:#9370DB;}#publish-mermaid-2-1793638109516 .innerArc{stroke-width:1.5;stroke-dasharray:none;}#publish-mermaid-2-1793638109516 .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#publish-mermaid-2-1793638109516 .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#publish-mermaid-2-1793638109516 [id$=\”-arrowhead\”] path{fill:#333;stroke:#333;}#publish-mermaid-2-1793638109516 .sequenceNumber{fill:white;}#publish-mermaid-2-1793638109516 [id$=\”-sequencenumber\”]{fill:#333;}#publish-mermaid-2-1793638109516 [id$=\”-crosshead\”] path{fill:#333;stroke:#333;}#publish-mermaid-2-1793638109516 .messageText{fill:#333;stroke:none;}#publish-mermaid-2-1793638109516 .labelBox{stroke:#9370DB;fill:#ECECFF;filter:none;}#publish-mermaid-2-1793638109516 .labelText,#publish-mermaid-2-1793638109516 .labelText>tspan{fill:black;stroke:none;}#publish-mermaid-2-1793638109516 .loopText,#publish-mermaid-2-1793638109516 .loopText>tspan{fill:black;stroke:none;}#publish-mermaid-2-1793638109516 .sectionTitle,#publish-mermaid-2-1793638109516 .sectionTitle>tspan{fill:black;stroke:none;}#publish-mermaid-2-1793638109516 .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:#9370DB;fill:#9370DB;}#publish-mermaid-2-1793638109516 .note{stroke:#aaaa33;fill:#fff5ad;}#publish-mermaid-2-1793638109516 .noteText,#publish-mermaid-2-1793638109516 .noteText>tspan{fill:black;stroke:none;font-weight:normal;}#publish-mermaid-2-1793638109516 .activation0{fill:#f4f4f4;stroke:#666;}#publish-mermaid-2-1793638109516 .activation1{fill:#f4f4f4;stroke:#666;}#publish-mermaid-2-1793638109516 .activation2{fill:#f4f4f4;stroke:#666;}#publish-mermaid-2-1793638109516 .actorPopupMenu{position:absolute;}#publish-mermaid-2-1793638109516 .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#publish-mermaid-2-1793638109516 .actor-man circle,#publish-mermaid-2-1793638109516 line{fill:#ECECFF;stroke-width:2px;}#publish-mermaid-2-1793638109516 g rect.rect{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));stroke:#9370DB;}#publish-mermaid-2-1793638109516 .node .neo-node{stroke:#9370DB;}#publish-mermaid-2-1793638109516 [data-look=\”neo\”].node rect,#publish-mermaid-2-1793638109516 [data-look=\”neo\”].cluster rect,#publish-mermaid-2-1793638109516 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793638109516 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-2-1793638109516 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-2-1793638109516 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793638109516 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-2-1793638109516 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793638109516 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-2-1793638109516 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793638109516 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793638109516 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}进入特权模式 (enable)进入全局配置 (configure terminal)删除启动配置 (erase startup-config)保存配置 (write erase)重启设备 (reload)重启完成,提示是否保存运行配置不保存重启完毕,进入用户模式
时序图展示了用户与交换机之间的完整交互过程。在重启过程中,交换机会询问是否保存当前的运行配置,此时应选择不保存,以确保启动配置文件为空。
四、实战二:交换机密码恢复
当忘记交换机密码时,可以通过中断启动过程,进入特殊的 ROMMON 模式来绕过密码验证,从而重置密码。以 Cisco 交换机为例,步骤如下:
#publish-mermaid-3-1793638109535{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-3-1793638109535 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-3-1793638109535 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-3-1793638109535 .error-icon{fill:#552222;}#publish-mermaid-3-1793638109535 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-3-1793638109535 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-3-1793638109535 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-3-1793638109535 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-3-1793638109535 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-3-1793638109535 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-3-1793638109535 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-3-1793638109535 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-3-1793638109535 .marker.cross{stroke:#333333;}#publish-mermaid-3-1793638109535 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-3-1793638109535 p{margin:0;}#publish-mermaid-3-1793638109535 defs [id$=\”-barbEnd\”]{fill:#333333;stroke:#333333;}#publish-mermaid-3-1793638109535 g.stateGroup text{fill:#9370DB;stroke:none;font-size:10px;}#publish-mermaid-3-1793638109535 g.stateGroup text{fill:#333;stroke:none;font-size:10px;}#publish-mermaid-3-1793638109535 g.stateGroup .state-title{font-weight:bolder;fill:#131300;}#publish-mermaid-3-1793638109535 g.stateGroup rect{fill:#ECECFF;stroke:#9370DB;}#publish-mermaid-3-1793638109535 g.stateGroup line{stroke:#333333;stroke-width:1;}#publish-mermaid-3-1793638109535 .transition{stroke:#333333;stroke-width:1;fill:none;}#publish-mermaid-3-1793638109535 .stateGroup .composit{fill:white;border-bottom:1px;}#publish-mermaid-3-1793638109535 .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px;}#publish-mermaid-3-1793638109535 .state-note{stroke:#aaaa33;fill:#fff5ad;}#publish-mermaid-3-1793638109535 .state-note text{fill:black;stroke:none;font-size:10px;}#publish-mermaid-3-1793638109535 .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#publish-mermaid-3-1793638109535 .edgeLabel .label rect{fill:#ECECFF;opacity:0.5;}#publish-mermaid-3-1793638109535 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-3-1793638109535 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-3-1793638109535 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-3-1793638109535 .edgeLabel .label text{fill:#333;}#publish-mermaid-3-1793638109535 .label div .edgeLabel{color:#333;}#publish-mermaid-3-1793638109535 .stateLabel text{fill:#131300;font-size:10px;font-weight:bold;}#publish-mermaid-3-1793638109535 .node circle.state-start{fill:#333333;stroke:#333333;}#publish-mermaid-3-1793638109535 .node .fork-join{fill:#333333;stroke:#333333;}#publish-mermaid-3-1793638109535 .node circle.state-end{fill:#9370DB;stroke:white;stroke-width:1.5;}#publish-mermaid-3-1793638109535 .end-state-inner{fill:white;stroke-width:1.5;}#publish-mermaid-3-1793638109535 .node rect{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-3-1793638109535 .node polygon{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-3-1793638109535 [id$=\”-barbEnd\”]{fill:#333333;}#publish-mermaid-3-1793638109535 .statediagram-cluster rect{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-3-1793638109535 .cluster-label,#publish-mermaid-3-1793638109535 .nodeLabel{color:#131300;}#publish-mermaid-3-1793638109535 .statediagram-cluster rect.outer{rx:5px;ry:5px;}#publish-mermaid-3-1793638109535 .statediagram-state .divider{stroke:#9370DB;}#publish-mermaid-3-1793638109535 .statediagram-state .title-state{rx:5px;ry:5px;}#publish-mermaid-3-1793638109535 .statediagram-cluster.statediagram-cluster .inner{fill:white;}#publish-mermaid-3-1793638109535 .statediagram-cluster.statediagram-cluster-alt .inner{fill:#f0f0f0;}#publish-mermaid-3-1793638109535 .statediagram-cluster .inner{rx:0;ry:0;}#publish-mermaid-3-1793638109535 .statediagram-state rect.basic{rx:5px;ry:5px;}#publish-mermaid-3-1793638109535 .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#f0f0f0;}#publish-mermaid-3-1793638109535 .note-edge{stroke-dasharray:5;}#publish-mermaid-3-1793638109535 .statediagram-note rect{fill:#fff5ad;stroke:#aaaa33;stroke-width:1px;rx:0;ry:0;}#publish-mermaid-3-1793638109535 .statediagram-note rect{fill:#fff5ad;stroke:#aaaa33;stroke-width:1px;rx:0;ry:0;}#publish-mermaid-3-1793638109535 .statediagram-note text{fill:black;}#publish-mermaid-3-1793638109535 .statediagram-note .nodeLabel{color:black;}#publish-mermaid-3-1793638109535 .statediagram .edgeLabel{color:red;}#publish-mermaid-3-1793638109535 [id$=\”-dependencyStart\”],#publish-mermaid-3-1793638109535 [id$=\”-dependencyEnd\”]{fill:#333333;stroke:#333333;stroke-width:1;}#publish-mermaid-3-1793638109535 .statediagramTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].statediagram-cluster rect{fill:#ECECFF;stroke:#9370DB;stroke-width:1;}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].statediagram-cluster rect.outer{rx:5px;ry:5px;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793638109535 .node .neo-node{stroke:#9370DB;}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].node rect,#publish-mermaid-3-1793638109535 [data-look=\”neo\”].cluster rect,#publish-mermaid-3-1793638109535 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793638109535 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793638109535 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}物理重启 + 按住 Break 键confreg 0x2142重启 (reset)进入配置模式,修改密码
正常运行
ROMMON
绕过配置
密码重置
状态图展示了密码恢复过程中交换机状态的转换。从正常运行状态,通过物理干预进入 ROMMON,修改配置寄存器,然后重启进入一个临时的“绕过配置”状态,最终在密码重置后回到正常的可管理状态。
#publish-mermaid-4-1793638109579{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-4-1793638109579 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-4-1793638109579 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-4-1793638109579 .error-icon{fill:#552222;}#publish-mermaid-4-1793638109579 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-4-1793638109579 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-4-1793638109579 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-4-1793638109579 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-4-1793638109579 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-4-1793638109579 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-4-1793638109579 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-4-1793638109579 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-4-1793638109579 .marker.cross{stroke:#333333;}#publish-mermaid-4-1793638109579 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-4-1793638109579 p{margin:0;}#publish-mermaid-4-1793638109579 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-4-1793638109579 .cluster-label text{fill:#333;}#publish-mermaid-4-1793638109579 .cluster-label span{color:#333;}#publish-mermaid-4-1793638109579 .cluster-label span p{background-color:transparent;}#publish-mermaid-4-1793638109579 .label text,#publish-mermaid-4-1793638109579 span{fill:#333;color:#333;}#publish-mermaid-4-1793638109579 .node rect,#publish-mermaid-4-1793638109579 .node circle,#publish-mermaid-4-1793638109579 .node ellipse,#publish-mermaid-4-1793638109579 .node polygon,#publish-mermaid-4-1793638109579 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-4-1793638109579 .rough-node .label text,#publish-mermaid-4-1793638109579 .node .label text,#publish-mermaid-4-1793638109579 .image-shape .label,#publish-mermaid-4-1793638109579 .icon-shape .label{text-anchor:middle;}#publish-mermaid-4-1793638109579 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-4-1793638109579 .rough-node .label,#publish-mermaid-4-1793638109579 .node .label,#publish-mermaid-4-1793638109579 .image-shape .label,#publish-mermaid-4-1793638109579 .icon-shape .label{text-align:center;}#publish-mermaid-4-1793638109579 .node.clickable{cursor:pointer;}#publish-mermaid-4-1793638109579 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-4-1793638109579 .arrowheadPath{fill:#333333;}#publish-mermaid-4-1793638109579 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-4-1793638109579 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-4-1793638109579 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-4-1793638109579 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-4-1793638109579 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-4-1793638109579 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-4-1793638109579 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-4-1793638109579 .cluster text{fill:#333;}#publish-mermaid-4-1793638109579 .cluster span{color:#333;}#publish-mermaid-4-1793638109579 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-4-1793638109579 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-4-1793638109579 rect.text{fill:none;stroke-width:0;}#publish-mermaid-4-1793638109579 .icon-shape,#publish-mermaid-4-1793638109579 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-4-1793638109579 .icon-shape p,#publish-mermaid-4-1793638109579 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-4-1793638109579 .icon-shape .label rect,#publish-mermaid-4-1793638109579 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-4-1793638109579 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-4-1793638109579 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-4-1793638109579 .node .neo-node{stroke:#9370DB;}#publish-mermaid-4-1793638109579 [data-look=\”neo\”].node rect,#publish-mermaid-4-1793638109579 [data-look=\”neo\”].cluster rect,#publish-mermaid-4-1793638109579 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793638109579 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-4-1793638109579 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-4-1793638109579 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793638109579 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-4-1793638109579 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793638109579 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-4-1793638109579 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793638109579 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793638109579 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
物理重启
进入 ROMMON
修改配置寄存器
重启设备
跳过初始配置
复制运行配置
修改密码
完成
此流程图详细分解了密码恢复的每一步操作,从物理重启到最终修改密码,为管理员提供了清晰的指引。
五、常见问题与最佳实践
在执行上述操作时,可能会遇到一些问题。了解常见问题及其解决方案,并遵循最佳实践,可以大大提高成功率。
常见问题排查:
| 无法进入特权模式 | 密码错误或未设置 | 使用密码恢复流程 |
| erase startup-config 命令无效 | 未进入全局配置模式 | 确认当前模式,输入 configure terminal |
| 重启后配置未清除 | 配置未正确删除或保存 | 重新执行 erase startup-config 和 reload |
| 无法进入 ROMMON 模式 | 按键时机不对 | 精确掌握设备启动时的按键窗口 |
最佳实践:
#publish-mermaid-5-1793638109614{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-5-1793638109614 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-5-1793638109614 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-5-1793638109614 .error-icon{fill:#552222;}#publish-mermaid-5-1793638109614 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-5-1793638109614 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-5-1793638109614 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-5-1793638109614 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-5-1793638109614 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-5-1793638109614 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-5-1793638109614 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-5-1793638109614 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-5-1793638109614 .marker.cross{stroke:#333333;}#publish-mermaid-5-1793638109614 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-5-1793638109614 p{margin:0;}#publish-mermaid-5-1793638109614 .pieCircle{stroke:black;stroke-width:2px;opacity:0.7;}#publish-mermaid-5-1793638109614 .pieCircle.highlighted{scale:1.05;opacity:1;}#publish-mermaid-5-1793638109614 .pieCircle.highlightedOnHover:hover{transition-duration:250ms;scale:1.05;opacity:1;}#publish-mermaid-5-1793638109614 .pieOuterCircle{stroke:black;stroke-width:2px;fill:none;}#publish-mermaid-5-1793638109614 .pieTitleText{text-anchor:middle;font-size:25px;fill:black;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}#publish-mermaid-5-1793638109614 .slice{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;fill:#333;font-size:17px;}#publish-mermaid-5-1793638109614 .legend text{fill:black;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:17px;}#publish-mermaid-5-1793638109614 .node .neo-node{stroke:#9370DB;}#publish-mermaid-5-1793638109614 [data-look=\”neo\”].node rect,#publish-mermaid-5-1793638109614 [data-look=\”neo\”].cluster rect,#publish-mermaid-5-1793638109614 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-5-1793638109614 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-5-1793638109614 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-5-1793638109614 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-5-1793638109614 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-5-1793638109614 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-5-1793638109614 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-5-1793638109614 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-5-1793638109614 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-5-1793638109614 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}45%30%15%10%网络设备访问问题分布密码遗忘配置错误物理连接故障其他
上图饼图展示了网络管理员在日常工作中遇到的主要设备访问问题的比例分布,其中密码遗忘和配置错误是两大主要原因,凸显了掌握本文所述技能的必要性。
六、总结
本文通过实战演练,详细介绍了交换机出厂配置清空和密码恢复的完整流程。无论是为了彻底重置设备,还是为了找回遗忘的密码,掌握这些核心技能都是网络运维人员的必备能力。通过正确的准备、规范的步骤和良好的习惯,可以确保网络设备的稳定运行和高效管理。希望本文能对您的网络运维工作提供实质性的帮助。


