Cisco命令大全(清除配置和恢复口令) |
您所在的位置:网站首页 › 思科交换机保存配置命令 › Cisco命令大全(清除配置和恢复口令) |
Cisco清除配置使用:erase startup-config(删除NVRAM中的内容),然后重启路由器 reload;华为清除配置使用:reset saved-configuration,重启路由器 reboot; Cisco路由器、交换机口令恢复专题: 选择性通告路由: 如在RIP设置中,让S0端口只收不发RIP通告。 Router(config)#router rip Router(config-router)#passive-interface serial 0
关于快捷键:ctrl+b(backward) 光标左移一个字符ctrl+f(foreward) 光标右移一个字符ctrl+a(a是?????) 光标移到命令开头ctrl+e(end) 光标移到命令末端esc+b (backward) 光标左移一个词esc+f (foreward) 光标右移一个词ctrl+z 一次性退出特权模式 Router# 关于模式:用户模式(user execution mode),特权模式(privilege execution mode),全局配置模式(global configuration mode),以及在全局配置模式下的具体配置模式(如路由接口配置模式,路由子接口配置模式,路由协议配置模式,line配置模式等)模式的转换:连接路由后首先进入的是用户模式,特征是有符号">",用户模式只能查找路由的配置和状态,不能配置路由,需要配置路由必须进入特权模式,进入特权模式的命令是:enable 若有密码,需要正确密码才能进入,进入特权模式,其特征是有符号"#".从特权模式进入路由全局配置模式命令是:configure terminal 从全局配置模式进入各个具体配置模式的命令如下: 特权模式--->路由接口配置模式interface serial??(串口)interface ethernet??(以太网口)特权模式--->路由子接口配置模式subinterface特权模式--->路由协议配置模式route rip特权模式--->line配置模式line vty ? ? 以下是各个模式下的命令以及用法:用户模式:Router>show ping telnet connect的用法和特权模式一样 特权模式:Router#show users 查看连接到路由器的所有用户show hosts 查看ip和名字的映射表show arp 查看ip地址解释show protocol 查看路由器的协议show version 查看ISO的版本,内存show flash 查看flash使用状况show clock 查看路由器的时间show history 查看最近输入的十个命令show ip interface brief 查看接口的ip设置和状态show interfaces 查看路由器所有端口的状态show interfaces 具体端口 查看路由器特定端口的状态 show running-config 查看在RAM中的配置文件show startup-config 查看在NVRAM中的配置文件 show cdp 查看cdp的信息show cdp entry ??(router) 查看特定的邻近连接的路由器show cdp neighbors 查看所有邻近连接的路由器show cdp neighbors detail 查看所有邻近连接的路由器详细信息show cdp traffic 查看cdp数据包的信息show cdp ??(端口号) 查看特定端口的cdp信息show session 远程登陆下查看原路由器的状态clear cdp counters 清除CDP计数器clear cdp table 清除CDP信息copy running-config startup-config 把在RAM中的配置文件复制到NVRAM中copy startup-config running-config 把在NVRAM中的配置文件复制到RAM中copy tftp running-config 把tftp服务器的配置文件传到RAM中copy running-config tftp 把RAM中的配置文件传到tftp服务器ping ??(名字或ip) 检查路由器与远端路由器的连通性telnet ??(名字或ip) 远程登陆路由器(需要登陆密码)connect ??(名字或ip) 和telnet一样traceroute ??(名字或ip) 查看经过的路由 全局配置模式:Router(config)#hostname ???(名字) 更改路由名字enable password ?? 修改进入特权模式的password密码enable secret ?? 修改进入特权模式的secret密码clock set hour:miniute:second day month year 修改路由器的时间ip host ??(名字) ??(ip地址) 添加ip与名字的映射service password-encryption 将各种密码加密(secret已经加密)cdp run 打开所有接口的cdpcdp timer 设置cdp的timecdp holdtime 设置cdp的holdtimeend 从全局配置模式退出到用户模式exit 一步一步的退出,即逐层地推出,输入一个exit则推出一层 接口配置模式:Router(config-if)#ip address ??(ip地址) 修改接口的ip地址 no shutdown 打开接口shutdowm 关闭端口clock rate ?? 设置DCE的同步时间(DTE不需要)cdp enable 打开端口的cdp line配置模式:Router(config-line)#line vty 0 4password ??login 设置最大用户登陆数并且设置登陆密码 收录最常用的Cisco命令分类如下: 1. switch配置命令(1)模式转换命令用户模式----特权模式,使用命令"enable"特权模式----全局配置模式,使用命令"config t"全局配置模式----接口模式,使用命令"interface+接口类型+接口号"全局配置模式----线控模式,使用命令"line+接口类型+接口号"注:用户模式:查看初始化的信息.特权模式:查看所有信息、调试、保存配置信息全局模式:配置所有信息、针对整个路由器或交换机的所有接口接口模式:针对某一个接口的配置线控模式:对路由器进行控制的接口配置(2)配置命令show running config 显示所有的配置show versin 显示版本号和寄存器值shut down 关闭接口no shutdown 打开接口ip add +ip地址 配置IP地址secondary+IP地址 为接口配置第二个IP地址show interface+接口类型+接口号 查看接口管理性show controllers interface 查看接口是否有DCE电缆show history 查看历史记录show terminal 查看终端记录大小hostname+主机名 配置路由器或交换机的标识config memory 修改保存在NVRAM中的启动配置exec timeout 0 0 设置控制台会话超时为0service password-encryptin 手工加密所有密码enable password +密码 配置明文密码ena sec +密码 配置密文密码line vty 0 4/15 进入telnet接口password +密码 配置telnet密码line aux 0 进入AUX接口password +密码 配置密码line con 0 进入CON接口password +密码 配置密码bandwidth+数字 配置带宽no ip address 删除已配置的IP地址 show startup-config 查看NVRAM中的配置信息,即查看启动配置文件 show running-config 查看现行配置文件copy running-config startup-config 将现行配置好的信息保存到启动配置文件里,这样下次路由器启动的时候就是这次配置的结果write 保存信息到NVRAM,即保存到启动配置文件里erase startup-config 清除NVRAM中的配置信息,即清除启动配置文件show ip interface brief 查看接口的谪要信息banner motd # +信息 + # 配置路由器或交换机的描素信息description+信息 配置接口听描素信息vlan database 进入VLAN数据库模式vlan +vlan号+ 名称 创建VLANswitchport access vlan +vlan号 为VLAN为配接口interface vlan +vlan号 进入VLAN接口模式ip add +ip地址 为VLAN配置管理IP地址vtp+service/tracsparent/client 配置SW的VTP工作模式vtp +domain+域名 配置SW的VTP域名vtp +password +密码 配置SW的密码switchport mode trunk 启用中继no vlan +vlan号 删除VLANshow spamming-tree vlan +vlan号 查看VLA怕生成树议 2. 路由器配置命令ip route+非直连网段+子网掩码+下一跳地址 配置静态/默认路由show ip route 查看路由表show protocols 显示出所有的被动路由协议和接口上哪些协议被设置show ip protocols 显示了被配置在路由器上的路由选择协议,同时给出了在路由选择协议中使用的定时器等信息router rip 激活RIP协议network +直连网段 发布直连网段interface lookback 0 激活逻辑接口passive-interface +接口类型+接口号 配置接口为被动模式debug ip +协议 动态查看路由更新信息undebug all 关闭所有DEBUG信息router eigrp +as号 激活EIGRP路由协议network +网段+子网掩码 发布直连网段show ip eigrp neighbors 查看邻居表show ip eigrp topology 查看拓扑表show ip eigrp traffic 查看发送包数量router ospf +process-ID 激活OSPF协议network+直连网段+area+区域号 发布直连网段show ip ospf 显示OSPF的进程号和ROUTER-IDencapsulation+封装格式 更改封装格式no ip admain-lookup 关闭路由器的域名查找ip routing 在三层交换机上启用路由功能show user 查看SW的在线用户clear line +线路号 清除线路 3. 三层交换机配置命令配置一组二层端口configure terminal 进入配置状态nterface range {port-range} 进入组配置状态配置三层端口configure terminal 进入配置状态interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} | {port-channel port-channel-number} 进入端口配置状态no switchport 把物理端口变成三层口ip address ip_address subnet_mask 配置IP地址和掩码no shutdown 激活端口 例: Switch(config)# interface gigabitethernet0/2 Switch(config-if)# no switchport Switch(config-if)# ip address 192.20.135.21 255.255.255.0 Switch(config-if)# no shutdown配置VLANconfigure terminal 进入配置状态vlan vlan-id 输入一个VLAN号, 然后进入vlan配态,可以输入一个新的VLAN号或旧的来进行修改。name vlan-name 可选)输入一个VLAN名,如果没有配置VLAN名,缺省的名字是VLAN号前面用0填满的4位数,如VLAN0004是VLAN4的缺省名字mtu mtu-size (可选) 改变MTU大小 例 Switch# configure terminal Switch(config)# vlan 20 Switch(config-vlan)# name test20 Switch(config-vlan)# end 或 Switch# vlan database Switch(vlan)# vlan 20 name test20 Switch(vlan)# exit将端口分配给一个VLANconfigure terminal 进入配置状态interface interface-id 进入要分配的端口switchport mode access 定义二层口switchport access vlan vlan-id 把端口分配给某一VLAN 例 Switch# configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)# interface fastethernet0/1 Switch(config-if)# switchport mode access Switch(config-if)# switchport access vlan 2 Switch(config-if)# end Switch#配置VLAN trunkconfigure terminal 进入配置状态interface interface-Id 进入端口配置状态switchport trunk encapsulation {isl | dot1q | negotiate}配置trunk封装ISL 或 802.1Q 或自动协商switchport mode {dynamic {auto | desirable} | trunk} 配置二层trunk模式。dynamic auto—自动协商是否成为trunkdynamic desirable—把端口设置为trunk如果对方端口是trunk, desirable, 配置Native VLAN(802.1q)或自动模式,trunk—设置端口为强制的trunk方式,而不理会对方端口是否为trunkswitchport access vlan vlan-id 可选) 指定一个缺省VLAN, 如果此端口不再是trunkswitchport trunk native vlan vlan-id 指定802.1Q native VLAN号 例: Switch# configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)# interface fastethernet0/4 Switch(config-if)# switchport mode trunk Switch(config-if)# switchport trunk encapsulation dot1q Switch(config-if)# end定义TRUNK允许的VLANconfigure terminal子进入配置状态interface interface-id 进入端口配置switchport mode trunk 配置二层口为trunkswitchport trunk allowed vlan {add | all | except | remove} vlan-list可选) 配置trunk允许的VLAN.使用add, all, except, remove关健字no switchport trunk allowed vlan 允许所有VLAN通过 例 Switch(config)# interface fastethernet0/1 Switch(config-if)# switchport trunk allowed vlan remove 2 Switch(config-if)# end配置Native VLAN(802.1q)configure terminal 进入配置状态interface interface-id 进入配置成802.1qtrunk的端口switchport trunk native vlan vlan-Id 配置native VLAN号no switchport trunk native vlan 端口配置命令回到缺省的状态配置基于端口权值的负载均衡configure terminal 进入Switch 1配置状态vtp domain domain-name 配置VTP域vtp mode server 将Switch 1配置成VTP server.show vtp status 验证VTP的配置show vlan 验证VLANconfigure terminal 进入配置状态interface fastethernet 0/1 进入F0/1端口switchport trunk encapsulation {isl | dot1q | negotiate}配置trunk封装switchport mode trunk 配置成trunkshow interfaces fastethernet0/1 switchport 验证VLAN配置按以上步骤对想要负载均衡的接口进行配置在另一个交换机上进行此配置show vlan 当trunk已经起来,在switch2上验证已经学到相的vlan配置configure terminal 在Switch 1上进入配置状态interface fastethernet0/1 进入要配置的端口spanning-tree vlan 8 port-priority 10 将端口权值10赋与VLAN 8.spanning-tree vlan 9 port-priority 10 将端口权值10赋与VLAN 9.spanning-tree vlan 10 port-priority 10 将端口权值10赋与VLAN 10.interface fastethernet0/2 进入F0/2spanning-tree vlan 3 port-priority 10 将端口权值10赋与VLAN 3.spanning-tree vlan 4 port-priority 10 将端口权值10赋与VLAN 4spanning-tree vlan 5 port-priority 10 将端口权值10赋与VLAN 5spanning-tree vlan 6 port-priority 10 将端口权值10赋与VLAN 10end 退出show running-config 验证配置copy running-config startup-config 保存配置 配置STP路径值的负载均衡Trunk1走VLAN8-10,Trunk2走VLAN2-4 configure terminal 进入 Switch 1配置状态interface fastethernet 0/1 进入F0/1switchport trunk encapsulation {isl | dot1q | negotiate}配置封装switchport mode trunk 配置Trunk,缺省是ISL封装exit 退回在F0/2口上重复2-4步骤exit 退回show running-config 验证配置show vlan验证switch1 已经学到Vlanconfigure terminal 进入配置状态interface fastethernet 0/1 进入F0/1spanning-tree vlan 2 cost 30 设置Vlan2生成树路径值为30spanning-tree vlan 3 cost 30 设置Vlan3生成树路径值为30spanning-tree vlan 4 cost 30 设置Vlan4生成树路径值为30end 退出在switch1的F0/2上重复9-11步骤设置VLAN8,9,10生成树路径值为30end 退出show running-config 验证配置copy running-config startup-config 保存配置 补充:CISCO命令集——路由选择协议及排障 *ip route命令 Router(config)# ip route [子网掩码] [管理距离0~255,默认为1] (注:静态地址配置) *ip default-network命令 Router(config)# ip default-network (注:配合路由协使用,用其中的一个动态路由号作默认路由配置)Router(config)# ip route 0.0.0.0 0.0.0.0 (注:只有一个公网地址时,在出口路由器上的配置) *内部路由选择协议 *使用router和network命令 Router(config)# router [自主系统号]Router(config-router)# network Router(config-router)# network *路由信息协议RIP Router(config)# router ripRouter(config-router)# network Router# show ip protocolsRouter# show ip routeRouter# debug ip rip *内部网关路由协议IGRP Router(config)# router igrp Router(config-router)# network Router# show ip interfaceRouter# show ip protocolsRouter# show ip routeRouter# debug ip rip *排除网络故障 排除网络故障的一个总体模型 Router# ping Router# show ip routeRouter# show interface Router# show run *IP的故故障排除 检查可用的路由 Router# show ip route 27.4.4 跟踪路由(Tracing the Route)SUN-A> traceroute C:\windows\> winipcfgC:\windows\> ipconfigC:\windows\> ipconfig / allC:\windows\> tracert 使用扩展的ping来跟踪连接性 Router# ping *其它可能的故障 一个地址解析(ARP)的故障 Router# show arpRouter# show interface C:\windows\> arp -aSUN-A> arp –a 验证终端系统的路由表C:\windows\> netstat –rnC:\windows\> route –f add 0.0.0.0 mask 0.0.0.0 C:\windows\> route [–f ] [[print | add | delete | change] [destination] [mask netmask] [gateway]]C:\windows\> route add mask C:\windows\> route delete mask C:\windows\> nbtstat SUN-A> netstat -rn路由器 ====================================================================== Router1>enable --路由器特权用户enable ====================================================================== 路由器帮助的使用 Router1#delete ? Router1#erase ? ====================================================================== Router1#erase startup-config --删除路由器以前的所有配置 Router1#erase nvram Router1#reload --重启路由器 ====================================================================== 路由器的模式 Router>enable --用户模式 Router#config terminal --特权模式 Router(config)#interface ethernet 0 --全局配置模式 Router(config-if)#exit --接口模式 Router(config)#line vty 0 4 --终端配置模式 Router(config-line)#exit --exit退出当前模式 Router(config)#exit Router#disable Router>logout ====================================================================== 路由器时钟的设置 Router#show clock --显示路由器时钟 *00:10:30.291 UTC Mon Mar 1 1993 Router#clock ? Router#clock set ? Router#clock set 11:50:40 21 august 2004 --配置路由器时钟 Router#show clock 11:50:49.435 UTC Sat Aug 21 2004 Router#write --保存路由器的配置 或者 Router#copy running-config startup-config ====================================================================== 路由器常见命令 Router#show running-config --显示路由器的当前配置 Router#show startup-config --显示路由器的启动配置 Router#show flash --显示路由器的*作系统信息 Router#show version --显示路由器的软硬件配置 Router#copy running-config startup-config --保存配置 Router#copy startup-config running-config --将NVRAM中的启动配置拷到DRAM中 Router#show interface --显示接口信息 Router#show interface Ethenet 0 Router#show interface Serial 0 Router#config terminal Router(config)#hostname Router2 --为路由器取名字 ====================================================================== 为路由器的以太口配置IP地址 Router2>en Router2#config t Router2(config)#interface ethernet 0 Router2(config-if)#ip address 192.168.0.101 255.255.255.0 --配置IP地址 Router2(config-if)#no shutdown --启用以太口 Router2(config-if)#exit Router2(config)#exit Router2#ping 192.168.0.101 Router2#ping 192.168.0.199 Router2#config t Router2(config)#int e0 --路由器一个接口可同时配置多个IP,其他IP必须加secondary Router2(config-if)#ip address 131.107.0.101 255.255.0.0 secondary Router2(config-if)#ip address 200.100.100.101 255.255.255.0 secondary Router2(config-if)#exit Router2(config)#exit Router2#ping 131.107.0.101 Router2#ping 200.100.100.101 Router2#show running-configure Router2#config t Router2(config)#int e0 Router2(config-if)#ip address 192.168.0.101 255.255.255.0 Router2(config-if)#no shutdown Router2(config-if)#exit Router2(config)#exit Router2#write ====================================================================== DCE端的配置 RA#show controller serial 1 --显示接口为DCE还是DTE RA#config t RA(config)#interface serial 1 RA(config-if)#ip address 10.0.0.1 255.0.0.0 --为串口配置IP地址 RA(config-if)#clock rate 64000 --在DCE端需要指定时钟频率,DTE端无需指定 RA(config-if)#no shut RA(config-if)#exit DTE端的配置 RB(config)#interface serial 1 RB(config-if)#ip address 10.0.0.2 255.0.0.0 --两个路由器的串口的IP地址应该在一个网段 RB(config-if)#no shut RB(config-if)#exit RB(config)#exit RB#ping 10.0.0.1 --两个路由器的串口必须都配置了IP地址,并使用了no shutdown命令才能PING通 以下命令比较使常用:CCNA试验指导: 启动接口,分配IP地址: router> router> enable router# router# configure terminal router(config)# router(config)# interface Type Port router(config-if)# no shutdown router(config-if)# ip address IP-Address Subnet-Mask router(config-if)# ^z 配置RIP路由协议:30秒更新一次 router(config)# router rip router(config-if)# network Network-Number ,比如10.2.3.0是个网络号,但必须写成network 10.0.0.0 router(config-if)# ^z 配置IGRP路由协议:90秒更新一次 router(config)# router igrp AS-Number router(config-if)# network Network-Number router(config-if)# ^z 配置Novell IPX路由协议:Novell RIP 60秒更新一次 router(config)# ipx routing [node address] router(config)# ipx maximum-paths Paths router(config)# interface Type Port router(config-if)# ipx network Network-Number [encapsulation encapsulation-type] [secondary] router(config-if)# ^z 配置DDR: router(config)# dialer-list Group-Number protocol Protocol-Type permit [list ACL-Number] router(config)# interface bri 0 router(config-if)# dialer-group Group-Number router(config-if)# dialer map Protocol-Type Next-Hop-Address name Hostname Telphone-Number router(config-if)# ^z 配置ISDN: router(config)# isdn swith-type Swith-Type router(config-if)# ^z 配置Frame Relay: router(config-if)# encapsulation frame-relay [cisco | ietf ] router(config-if)# frame-relay lmi-type [ansi | cisco | q933a ] router(config-if)# bandwidth kilobits router(config-if)# frame-relay invers-arp [ Protocol ] [dlci ]
router(config-if)# ^z 配置标准ACL: router(config)# access-list Access-List-Number [ permit | deny ] source [ source-mask ] router(config)# interface Type Port router(config-if)# ip access-group Access-List-Number [ in | out ] router(config-if)# ^z 配置扩展ACL: router(config)# access-list Access-List-Number [ permit | deny ] [ Protocol | Protocol-Number ] source source-wildcard [ Source-Port ] destination destination-wildcard [ Destination-Port ] [ established ] router(config)# interface Type Port router(config-if)# ip access-group Access-List-Number [ in | out ] router(config-if)# ^z 配置命名ACL: router(config)# ip access-list [ standard | extended ] ACL-Name router(config [ std- | ext- ] nacl)# [ permit | deny ] [ IP-Access-List-Test-Conditions ] router(config [ std- | ext- ] nacl)# no [ permit | deny ] [ IP-Access-List-Test-Conditions ] router(config [ std- | ext- ] nacl)# ^z router(config)# interface Type Port router(config-if)# ip access-group [ACL-Name | 1~199 ] [ in | out ] router(config-if)# ^z 配置DCE时钟: router# show controllers Type Port router(confin-if)# clock rate 64000 router(config-if)# ^z
配置PPP协议: router(config)# username Name password Set-Password-Here router(config)# interface Type Port router(config-if)# encapsulation ppp router(config-if)# ppp outhentication [ chap | chap pap | pap chap | pap ] router(config-if)# ppp pap sent-username Name password Password router(config-if)# ^z
PAP单向认证配置实例: 验证方: router-server(config)# username Client password 12345 router-server(config)# interface serial 0 router-server(config-if)# encapsulation ppp router-server(config-if)# ppp authentication pap router-server(config-if)# ^z 被验证方: router-client(config-if)# encapsulation ppp router-client(config-if)# ppp pap sent-username Client password 12345 router-client(config-if)# ^z
PAP双向认证配置实例: 路由器 A: routerA(config)# username B password 12345 routerA(config)# interface serial 0 routerA(config-if)# encapsulation ppp routerA(config-if)# ppp authentication pap routerA(config-if)# ppp pap sent-username A password 54321 routerA(config-if)# ^z 路由器 B: routerB(config)# username A password 54321 routerB(config)# interface serial 1 routerB(config-if)# encapsulation ppp routerB(config-if)# ppp authentication pap routerB(config-if)# ppp pap sent-username B password 12345 routerB(config-if)# ^z
CHAP单向认证配置实例: 验证方: router-server(config)# username router-client password 12345 router-server(config)# interface serial 0 router-server(config-if)# encapsulation ppp router-server(config-if)# ppp authentication chap router-server(config-if)# ^z 被验证方: router-client(config-if)# encapsulation ppp router-client(config-if)# ppp authentication chap router-client(config-if)# ppp chap hostname router-client router-client(config-if)# ppp chap password 12345 router-client(config-if)# ^z
CHAP双向认证配置实例: 路由器 A: routerA(config)# username routerB password 12345 routerA(config)# interface serial 0 routerA(config-if)# encapsulation ppp routerA(config-if)# ppp authentication chap routerA(config-if)# ppp chap hostname routerA routerA(config-if)# ppp chap password 54321 routerA(config-if)# ^z 路由器 B: routerB(config)# username routerA password 54321 routerB(config)# interface serial 1 routerB(config-if)# encapsulation ppp routerB(config-if)# ppp authentication chap routerB(config-if)# ppp chap hostname routerB routerB(config-if)# ppp chap password 12345 routerB(config-if)# ^z
Telnet使用: routerA# terminal monitor routerA# telnet IP-Address [ Router-Name ] routerB# [ exit | logout ] routerB# ++再按 routerA# show sessions routerA# Connect-Number routerA# disconnect IP-Address [ Router-Name ] routerA# show user routerA# clear line [ 0 | 1 | 2 | 3 | 4 ]
禁止任何Telnet到本机: router(config)# line vty 0 4 router(config-line)# access-class ACL-Number router(config)# |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |