收藏 分销(赏)

思科路由器及交换机各种命令大全.doc

上传人:仙人****88 文档编号:8885936 上传时间:2025-03-06 格式:DOC 页数:18 大小:615.50KB 下载积分:10 金币
下载 相关 举报
思科路由器及交换机各种命令大全.doc_第1页
第1页 / 共18页
思科路由器及交换机各种命令大全.doc_第2页
第2页 / 共18页


点击查看更多>>
资源描述
交换机支持的命令:(注:交换机支持命令对应的为思科2系列交换机。) 交换机基本状态: switch: ;交换机的ROM态 rommon> ;路由器的R状态 switch > ;用户模式 switch# ;特权模式 switch(config)# ;全局配置模式 switch(vlan)# 交换机VLAN配置模式 switch(config-if)# ;端口配置模式 switch(config-line)# ; 指定连接状态(console连接 telnet连接) 交换机显示命令: switch#write ;保存配置信息 switch#show running ;查看当前配置信息 switch#show startup 查看交换机NVROM配置信息 switch#show vlan ;查看vlan配置信息 switch#show vlan-switch 同样为查看vlan配置信息(一些高端交换机比如3系列的交换机必须用这个命令才能查看vlan配置信息) switch#show vtp status 查看VTP配置信息 switch#show interface ;查看所有的端口信息 switch#show interface f0/3 ;查看指定的f0/3快速以太网端口信息 switch#show interfacef0/3 switchport 查看指定的f0/3快速以太网端口trunk信息 switch #show spanning-tree 查看交换机生成树协议情况 switch #show spanning-tree vlan 2 查看交换机VLAN2的生成树协议情况 switch #show spanning-tree interface f0/1 查看交换机F0/1端口生成树协议情况 switch #show cdp 显示交换机当前邻居更新信息 switch #show cdp neighbor ;显示邻居直连路由信息 switch #show cdp neighbor detail 显示邻居直连路由详细信息 switch #show cdp interface 显示所有端口是否开启cdp功能 switch (config-if)#no cdp enable 关闭指定端口的cdp功能 switch (config-if)#cdp enable 打开指定端口的cdp功能 switch (config)#no cdp run 关闭所有端口的cdp功能 switch (config)#cdp run 打开所有端口的cdp功能 switch#show version 查看交换机版本信息 switch#show flash 查看flash里面的IOS信息 switch#show mac-address-table 查看交换机所有端口的MAC 地址信息 交换机口令设置: switch>enable ;进入特权模式 switch#config terminal ;进入全局配置模式 switch(config)#hostname <hostname> 设置交换机的主机名 switch(config)#enable secret xxx ;设置特权加密口令(真正进入enable特权模式需要输入这个口令) switch(config)#enable password xxa ;设置特权非密口令 switch(config)#line console 0 ;进入控制台口 switch(config-line)#login ;允许登录 switch (config-line)# password xx 设置登陆控制台口口令 switch (config-line)#exec-timeout 0 0 设置控制台口多长时间不操作会自动退出,前面一个0表示分钟 后面一个0表示秒 两个都是0表示一直不会自动退出。 switch(config-line)#logging sy switch(config-line)#no ip domain-lookup 关闭域名查找功能(如果你输错了命令,switch会认为你输入的是域名,就会查找。。。浪费时间。no ip domain-lookup就是取消这种查找) switch(config-line)#line vty 0 4 ;进入虚拟终端 switch(config-line)#login ;允许登录 switch(config-line)#password xx ;设置登录虚拟终端口令xx switch#exit ;返回命令 交换机常规配置 switch(config)#no mac-address-table static (需要删掉的mac地址) fastethernet f0/7 清除掉交换机F0/7端口的MAC地址 switch(config-if)#duplex full/halt/auto ;设置交换机端口工作方式 (full全双工 halt半双工模式 auto自动检测) switch(config-if)#speed 10/100/1000/auto ;设置交换机对应端口局域网交换速度 switch(config)#interface f0/1 进入快速以太网端口端口f0/1 switch(config)#interface vlan 1 ;进入vlan 1 switch(config)#interface range f0/1 – 24 进入快速以太网端口f0/1到f0/24 交换机文件操作: switch#copy running-config startup-config 将RAM的当前配置存储到NVRAM switch#copy running-config tftp 备份RAM存储的配置信息到tftp switch#copy startup-config tftp 备份NVRAM配置备份到tftp switch#copy flash tftp ;备份路由器的flash文件IOS到tftp switch#copy tftp startup-config ;恢复NVRAM配置文件 switch#copy tftp running-config 恢复NVRAM配置文件 switch#copy tftp flash: 将flash文件IOS从tftp恢复到路由器 switch#erase startup-config 清除NVRAM存储的配置文件 交换机生成树协议配置 switch(config)#spanning-tree 开启交换机生成树协议 switch(config)#no spanning-tree 关闭交换机生成树协议 switch(config-if)#spanning-tree port-priority 32 设定这个端口的优先级为32(端口优先级取值范围为0~240 之间的16 倍数,即取值范围为 0、16、32、48…240.设定数值越小,优先级越高) switch(config)#spanning-tree priority 4096 设定这个交换机STP优先级为4096(取值范围为0~61440 之间的4096 的倍数,即取值范围为0、4096、8192…61440. 设定数值越小,优先级越高) 交换机端口镜像配置 Switch (config)# monitor session 1 destination interface f0/1 配置f0/1为镜像端口。 Switch (config)# monitor session 1 source interface f0/2 both 配置f0/2为被镜像端口,且出入双向数据均被镜像。 Switch (config)# monitor session 1 source interface f0/2-f0/10 both 配置f0/1到f0/10为被镜像端口,且出入双向数据均被镜像。 Switch (config)# monitor session 1 source vlan2 both 配置整个vlan2为被镜像端口,且出入双向数据均被镜像。 Switch (config)# no monitor session 1 去掉镜像1。 交换机VLAN设置: switch#vlan database ;进入VLAN设置 switch(vlan)#vlan 2 ;建VLAN 2 switch(vlan)#vlan 2 name <name> ; 设置VLAN 2的名字 switch(vlan)#no vlan 2 ;删vlan 2 switch(vlan)#vtp domain <name> ;设置发vtp域名 switch(vlan)#vtp password <word> ;设置发vtp密码 switch(vlan)#vtp server ;设置发vtp服务模式 switch(vlan)#vtp client ;设置发vtp客户模式 switch(vlan)#vtp pruning ;设置vtp 允许 switch(config)#ip routing 启动三层交换机路由转发 switch(config-if)#switchport access vlan 2 ;当前端口加入vlan 2 switch(config-if)#switchport mode trunk ;设置为干线(开启trunk干线功能) switch(config-if)#switchport trunk encap dot1q ;设置vlan 中继(开启vlan封装的802.1q协议) switch(config-if)#switchport trunk allowed vlan all ;设置允许的vlan(这个命令为允许所有的vlan从这个干线进行传递) switch(config-if)#switchport trunk allowed vlan 2 3 设置允许的vlan(这个命令为允许vlan 2和 vlan 3从这个干线进行传递) 交换机设置IP地址: switch(config-if)#ip address <IP> <mask> ;设置IP地址 switch(config)#ip default-gateway <IP> ;设置默认网关 switch#dir flash: ;查看闪存 3750#show arp 查看IP与MAC对应 Address Age (min) Hardware Addr Type Interface --------------- ---------- -------------- ------ -------------------- 10.0.0.2 31 0090.0b09.622e arpa Gi1/1 192.168.100.3 0 00e0.6109.5e90 arpa VL10 192.168.100.49 15 0019.21bd.b6cd arpa VL10 192.168.100.50 0 00e0.b0ef.97d8 arpa VL10 192.168.100.51 1 0019.21cf.dcdb arpa VL10 看MAC地址从哪个端口学习上来 3750#show mac-address-table Vlan MAC Address Type Interface ---------- -------------------- -------- ------------------- 1 001e.ecbf.8744 DYNAMIC Gi1/22 1 00d0.f87b.f7a5 DYNAMIC Gi1/23 1 00d0.f88b.a04d DYNAMIC Gi1/24 交换机名(config)# interface fastethernet 0/1 /*进入接口0/1的配置模式 交换机名(config-if)# speed 10                /*设置该端口的速率为10Mb/s 交换机名(config-if)# duplex full              /*设置该端口为全双工 交换机名(config-if)# end                      /*退回到特权模式 交换机名# show interface fastethernet 0/1     /*查询端口0/1的配置结果 1、duplex auto;  自适应双工模式 2、duplex full;  全双工模式 3、duplex half;  半双工模式 路由器支持的命令: 建立本地数据库用户名CNTC 密码123 router(config)#username CNTC password 123 进入控制台接口,配置路由器以本地数据库的方式进行认证 router(config)#line console 0 router(config-line)#login local router(config-line)# 进入VTY接口,设置远程登录时用本地数据库认证 router(config)#line vty 0 4 router(config-line)#login local router(config-line)# router#Clear line vty 0 永久性清除telent登录 查看路由器当前配置show running-config 可以通过“default”命令修改快速还原以前的封装协议 向192.168.1.1发送150个大小为200字节的数据包 router(config)#line console 0 router(config-line)#exec-timeout 0 0 设置路由器console永不超时 router(config-line)#logging synchronous 阻止控制台口信息妨碍CLI操作(console口信息同步) No ip domain-lookup 关闭域名解析功能 no auto-summary关闭自动汇总 路由器基本状态: router: ;路由器的ROM态 rommon> ;路由器的R状态 router> ;用户模式 router# ;特权模式 router(config)# ;全局配置模式 router(config-if)# ;端口配置模式 router(config-line)# ; 指定连接状态(console连接 telnet连接) router(config-router)# 路由状态配置模式(动态路由配置模式) router(dhcp-config)# 路由器DHCP配置模式 路由器显示命令: router#show running ;显示配置信息 router#show startup 查看交换机NVROM启动配置信息 router#show interface ;显示接口信息 router#show ip int brief 显示接口ip地址 router#show interface f0/0 ;查看指定端口信息 router#show ip route ;显示路由表信息 router #show cdp 显示路由器当前邻居更新信息 router#show cdp neighbor ;显示邻居直连路由信息 router#show cdp neighbor detail 显示邻居直连路由详细信息 router#show cdp interface 显示所有端口是否开启cdp功能 router#show access-lists router (config-if)#no cdp enable 关闭指定端口的cdp功能 router (config-if)#cdp enable 打开指定端口的cdp功能 router(config)#no cdp run 关闭所有端口的cdp功能 router(config)#cdp run 打开所有端口的cdp功能 router(config)#no ip domain lookup 关掉域名解析 router#reload     ;重新起动 router#show version 查看路由器版本信息 router#show flash 查看flash里面的IOS信息 路由器口令设置: router>enable ;进入特权模式 router#config terminal ;进入全局配置模式 router(config)#hostname <hostname> 设置路由器的主机名 router(config)#enable secret xxx ;设置特权加密口令(真正进入enable特权模式需要输入这个口令) router(config)#enable password xxx ;设置特权非密口令 router(config)#line console 0 ;进入控制台口 router(config-line)#login ;要求口令验证 router(config-line)# password xx 设置登陆控制台口口令 router(config-line)#exec-timeout 0 0 设置控制台口多长时间不操作会自动退出,前面一个0表示分钟 后面一个0表示秒 两个都是0表示一直不会自动退出。 router(config-line)#logging sy router(config-line)#no ip domain-lookup 关闭域名查找功能(如果你输错了命令,router会认为你输入的是域名,就会查找。。。浪费时间。no ip domain-lookup就是取消这种查找) router(config-line)#line vty 0 4 ;进入虚拟终端 router(config-line)#login ;要求口令验证 router(config-line)#password xx 设置登录虚拟终端口令xx router(config)#(Ctrl+z) ; 返回特权模式 router#exit ;返回命令 路由器常规配置: router#clock set 18:10:53 20 march 2010 设定路由器时钟,例子设定的为2010年3月20日18点10分53秒 router(config)#interface s0/0 ;进入Serail接口(串口) router(config)#interface f0/0 进入快速以太网接口f0/0 router(config-if)#no shutdown ;激活当前接口 router(config-if)#bandwidth 64 ;设定指定串口带宽 router(config-if)#clock rate 64000 ;设置同步时钟 router(config-if)#ip address <ip> <netmask> ;设置IP地址 router(config-if)#ip address <ip> <netmask> second ;设置第二个IP router(config-if)#interface f0/0.1 ;进入子接口 router(config-subif.1)#ip address <ip> <netmask> ;设置子接口IP router(config-subif.1)#encapsulation dot1q <n> ;绑定vlan中继(802.1q)协议 router(config)#config-register 0x2142 ;跳过配置文件 router(config)#config-register 0x2102 ;正常使用配置文件 router#reload ;重新引导 路由器文件操作: router#copy running-config startup-config 将RAM的当前配置存储到NVRAM router#copy running-config tftp 备份RAM存储的配置信息到tftp router#copy startup-config tftp 备份NVRAM配置备份到tftp router#copy flash tftp ;备份路由器的flash文件IOS到tftp router#copy tftp startup-config ;恢复NVRAM配置文件 router#copy tftp running-config 恢复NVRAM配置文件 router#copy tftp flash: 将flash文件IOS从tftp恢复到路由器 router#erase startup-config 清除NVRAM存储的配置文件 ROM状态: 如果需要将路由器恢复到出厂设置要求在先启动计算机的超级终端,还原为9600波特率,在路由器上电60秒内按计算机的 Ctrl+Break 键,你将会看到rommon> Ctrl+Break ;进入ROM监控态 rommon>confreg 0x2142 ;跳过配置文件 rommon>confreg 0x2102 ;恢复配置文件 rommon>reset ;重新引导 rommon>copy xmodem:<sname> flash:<dname> ;从console文件 rommon>IP_ADDRESS=10.65.1.2 ;设置路由器IP rommon>IP_SUBNET_MASK=255.255.0.0 ;设置路由器码 rommon>TFTP_SERVER=10.65.1.1 指定TFTP服务器IP rommon>TFTP_FILE=c2600.bin 指定下载的文件 rommon>tftpdnld ;从tftp下载 rommon>dir flash: ;查看闪存内容 rommon>boot ;引导IOS 静态路由: ip route <ip-address> <subnet-mask> <gateway> ;命令格式 router(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.2 ;静态路由举例 默认缺省路由 router(config)#ip route 0.0.0.0 0.0.0.0 192.168.10.5 ;默认缺省路由举例 动态路由:(特指RIPV2动态路由协议) router(config)#ip routing ;启动路由转发 router(config)#router rip ;启动RIP动态路由协议。 router(config-router) #version 2 设置启用RIP动态路由协议为RIPV2版本 router(config-router)#network <netid> ;设置发布路由 router(config-router)#neighbor <ip> ;点对点帧中继用。 动态路由:(特指EIGRP动态路由协议) router(config)#router eigrp <autonomous-system> 启用EIGRP动态路由协议 router(config-router)#network <netid> ;设置发布路由 router#show ip eigrp neighbor 显示EIGRP协议的邻居信息 router#show ip eigrp topology 显示EIGRP协议的拓扑表信息 router#show ip route eigrp 显示EIGRP协议的路由表信息 帧中继命令: router(config)#frame-relay switching ;使能帧中继交换 router(config-s0)#encapsulation frame-relay ;使能封装帧中继 router(config-s0)#frame-relay lmi-type cisco ;设置lmi本地接口管理类型(11.2以上的IOS不用配置会自动分配一个lmi类型) router(config-s0)#frame-relay intf-type DCE ;设置为DCE router(config-s0)#frame-relay dlci 16 ; router(config-s0)#frame-relay local-dlci 130 ;设置本地虚电路号 router(config-s0)#frame-relay interface-dlci 120 ;设置本地虚电路号 router(config-s0)#frame-relay map 10.35.35.1 110 broadcast 手动指派本地虚电路号 router(config-if)#frame-
展开阅读全文

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


开通VIP      成为共赢上传

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

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

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

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

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

gongan.png浙公网安备33021202000488号   

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

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

客服