路由器命令总结

路由器命令状态
>> 路由器处于rxboot状态,开机60秒内按ctrl+break可进入此状态用于软件升级和手工引导.
router>用户命令状态,只能查看一些基本信息
router#特权命令状态
router(config)#全局设置状态
router(config-if)#接口设置状态
路由器口令设置
router>enable 进入特权模式
router#config terminal 进入全局配置模式
router(config)#hostname  设置交换机的主机名
router(config)#enable secret xxx 设置特权加密口令
router(config)#enable password xxx 设置特权非密口令
控制台口令
router(config)#line console 0 进入控制台口
router(config-line)#login 要求口令验证
router(config-line)#password xx 设置登录口令
使用Telnet远程式管理
router(config)#line vty 0 4 进入虚拟终端
router(config-line)#login 要求口令验证
router(config-line)#password xx 设置登录口令
路由器基本配置
router(config)#int s0/0  进入Serail接口
router(config-if)#ip address   设置IP地址
router(config-if)#ip address  second 设置第二个IP
router(config-if)#description to ***** 接口描述
router(config-if)#no shutdown 激活当前接口
router(config-if)#clock rate 64000 设置同步时钟 (仅用于串口)
router(config-if)#clock rate 64 设置带宽 (仅用于串口)
router(config-if)#ip ospf authentication-key 口令 为ospf设置认证(不加密)
router(config-if)#ip ospf message-digest-key md5 口令 为ospf设置md5认证
router(config-if)#no ip ospf message-digest-key md5 口令 为ospf设置md5认证
router(config)#int f0/0.1 进入子接口
router(config-subif.1)#ip address  设置子接口IP
router(config-subif.1)#encapsulation dot1q 序号 绑定vlan中继协议 (vlan三层路由)
注: dot1q 为IEEE802.1Q标准 isl为 思科专用
router#write 保存配置信息
router#copy running-config startup-config 保存当前配置nvram
router#debug ip rip 监测配置
router#no debug ip all 关闭监测配置
router#reload 重新起动
router#erase startup-config 清除配置文件

路由器显示命令:

router#show run 显示配置信息
router#show interface 显示接口信息
router#show ip route 显示路由信息
router#show ip arp 显示arp缓存
router#show cdp nei 显示邻居信息
静态路由:
router(config)#ip route    命令格式
注: distance 改变默认管理开销
router(config)#ip route 0.0.0.0 0.0.0.0  默认路
router(config)#ip classless 数据包不能转发时匹配给默认路由
router(config)#no ip classless 数据包不能转发时弃掉
动态路由rip:
router(config)#ip routing 启动路由转发
router(config)#router rip 启动RIP路由协议。
router(config-router)#network  设置发布路由
router(config-router)#version  设置rip版板
router(config-router)#no auto-summary 禁用自动聚合(当子网不连续时)v2版本
router(config-if)#ip rip send version 1 允许v2给v1发送报文(运行v2的接口模式下)
router(config-if)#ip rip receive version 1 允许v2接收v1的报文(运行v2的接口模式下)
router(config-if)#ip rip send version 1 2 同时发送v1, v2报文(在运行v2的接口模式下)
注: 当运行rip version 2 的路由器和运行rip version 1的路由器相联时,可以通过接口兼容性开关来实现
也可以在一个接口上同时发送和接收v1, v2 两个版本
动态路由ospf:
router(config)#router ospf  启用ospf进程
router(config-router)#network  area  启用ospf进程
例: network 192.168.10.2 0.0.0.0 area 0只在某一接口上启用sopf
network 192.168.0.0 0.0.255.255 area 0将属于192.168.0.0网段的所有接口启用ospf
router(config-router)#network redistribute rip metric  将rip路由重分发到ospf区域
router(config-router)#area  authentication message-digest 在区域中启用md5认证
router(config-router)#area  authentication 在区域中启用认证(不加密)
router(config-router)#area  stub 使该区域成为stub区域
router(config-router)#area  default-cost  改变ABR通告的默认路由(默认为1)
router(config-router)#area  stub no-summary 使该区域成为完全stub区域(在ABR上配置)
router(config-router)#area  nass 使该区域成为nass区域
router(config-router)#area  nass no-summary 使nass区域不接收lsa3,lsa4(在ABR上配置)
router(config-router)#area  stub no-redistribution default-information-originate
注: 使nass区域不接收lsa5,lsa7 但接收lsa3,lsa4,(在ABR上配置)
router(config-router)#area  stub no-redistribution no-summary
注: 使nass区域不接收lsa3,lsa4,lsa5,lsa7(在ABR上配置)
router(config-router)#area  range  区域间汇总
router(config-router)#area  range  null0 防止汇总过大而导至错误
注: 地址汇总可以减少LSA泛滥的数量,屏蔽一些网络不稳定的细节,从而节省资源
router(config-router)#summary-address   外部路由汇总(不同自治系统间汇总)
router(config-router)#area  virtual-link  虚链路配置(中间区域两个ASB上配置
router(config-router)#summary-address
router#show ip interface  查看指定接口信息
router#show ip interface  查看指定接口信息
router#show ip ospf neighbor  查看邻居结构信息
router#show ip ospf database router  查看路由器
router#show ip interface  查看指定接口信息
router#show ip ospf neighbor  查看邻居结构信息
router#show ip ospf database router  查看路由器lsa1通告
router#show ip ospf database network  路由器网络lsa2通告(所有于DR相连的route)
router#show ip ospf database summary  查看路由器lsa3汇总通告
router#show ip ospf database asbr-summary 查看路由器lsa4(通告ASBR主机地址)
router#show ip ospf database external  查看lsa5通告(在整个ospf区中泛滥)
router#show ip ospf database nass-summary 查看路由器lsa7(在nass区中泛滥)
router#show ip ospf database border-rourters 路由器条目(只显示到达ABR和ASBR的路由)
router#show ip ospf virtual-link 查看虚链路配置
router#show ip route 查看网络条目(数据包要转发的目的网络)
注: 区域内( i ) 区域间( I ) (IA) 类型1的外部路由(E1 )计算到达asbr的价值) 类型2外部路由(E2 忽略)
router#debug ip adj 查看邻接关系的建立
热备份路由协议HRSP:
router(config-if)#standby  ip  将接口加入备份组
router(config-if)#no standby  ip  将接口从备份组中脱离
注: 需要加入备份组的所有接口起用相同的virtual-ip-address 且在同一网段内
router(config-if)#standby  priority  设置优先级(默认为100)
router(config-if)#standby  preempt 设置占先权
router(config-if)#standby  time   更改hello消息计时器
注: hello间隔默认为3秒 保持时间最少应该为hello时间的3倍 可以在(1-255之间变化)
router(config-if)#standby  track   
注: 利用端跟踪,活跃路由器的优先级可以基于路由器端口的可用性自动进行调整,当跟踪的端口不可用时活跃路由器的优先级将被降低 (默认为10) 例:standby 48 track interface  fastethernet 0/1 100
router#show standby 查看备份组状态
基本访问控制列表:
router(config)#ip access-list { standard | extended } name 命名访问列表
router(config)#access-list  permit  
router(config)#access-list  deny  
注: 0.0.0.0 255.255.255.255 简写为any 允许或拘绝所有网络
0.0.0.0 简写为host 允许或拘绝某个主机返掩码
router(config-if)#ip access-group  in/out 在接口上定义access-list的方向
router(config-if)#ip access-group name in/out 在接口上定义命名access-list的方向
扩展访问控制列表:
router(config)#access-list  {permit|deny } protocol  [precedence][tos 基于ip的访问列表
注: 扩展列表范围为100-199之间。protocol是个变量包括(eigrp gre icmp igrp ip ipinip nos ospf tcp udp)
precedence和tos 是可选变量,它们可以在ip报头的优先级字段和服类类型字段建寻找匹配。
router(config)#access-list  {permit|deny }tcp [operator port]  [operator port] [established] [precedence] [tos  基于tcp的访问列表
注: operaor是指定逻辑操作,可选项是(eq等于 neq不等于 gt 大于lt 小于range指明包括的端口范围
port指明端口号,常用端口号telnet(23) ftp(20 21) smtp(25) snmp(169) dns(53) tftp(69) www(80)
established 检查ack 和 rst标记
router(config)#access-list  {permit|deny }udp [operator port]  [operator port] [precedence] [tos  基于udp的访问列表
router(config)#access-list  {permit|deny }icmp  [icmp-type] [icmp-code] [precedence] [tos  基于icmp的访问列表
注: 多个接口可以调用相同的访问列表,但是在任意一个接口上,对每种协议仅能有一个进入和离开的访问列表。
安全过滤通常是做为入站过滤,流量过滤通常是出站过滤。标准访问列表尽可能被放置在靠近目标的地方,扩展访问列表应该放置在靠近源点的地方。
router(config)#no access-list 102 删除访问控制例表:
router(config-if)#no ip access-group 101 in 删除访问控制例表
路由器的nat配置
Router(config-if)#ip nat inside ;当前接口指定为内部接口
Router(config-if)#ip nat outside ;当前接口指定为外部接口
Router(config)#ip nat inside source static   静态nat配置
Router(config)#access-list  permit 192.168.100.0 0.0.0.255 定义访问列表(动态nat)
Router(config)#ip nat pool   netmask定义合法ip地址池(动态nat)
Router(config)#ip nat inside destination list  pool  访问列表与地址池邦定(动态nat)
Router(config)#ip nat inside source list  interface  overload 复用外部接口地址
tcp负载均衡配置
Router(config)#access-list  permit  定义访问列表
Router(config)#ip nat pool   prefix-length  type rotary
注: 需要实现负载的几个主机地址
Router(config)#ip nat inside destination list  pool  访问列表与地址池邦定
Router#show ip nat translation
rotary 参数是轮流的意思,地址池中的IP轮流与NAT分配的地址匹配。
overload参数用于PAT 将内部IP映射到一个公网IP不同的端口上。
配置PPP验证:
RouterA(config)#usename  password
RouterA(config)#int s0
RouterA(config-if)#ppp authentication {chap|pap}
路由器认证:
步骤:
定义一个带名字的钥匙链
定义在钥匙链上的钥匙
在接口上启动认证并指定使用的钥匙链
指定这个接口合用名文还是MD5认证
可选地配置钥匙的管理
config)#key chain 钥匙链名
config-keychain)#key 1
config-keychain-key)#key-string 口令
config-keychain-key)#interface ethernet 0
config-if)#ip rip authentication key-chain 钥匙链名
config-if)#ip rip authentication mode md5
cisco2600 路由器密码恢复(如此类的,密码恢复都不相差无几)
重启路由器,在启动过程中按下ctrl+break键,使路由器进入rom monitor模式
在提示符下输入命令修改配置寄存器的值,然后重器路由器
router>confreg 0x2142 跳过配置文件
router>reload 重新引导
重新起动后为了路由器恢复密码后配置不变,把startup-config保存到running-config中然后重新设置密码。
将配置寄存器的值改回来router(config)#config-register 0x2102
保存当前配置文件到startup-config

(注明现在2960已停止生产使用)
个人总结如有意见请留言提示。
希望能供现在的同事以及读者查看,呵呵或许在你们眼里只是一些皮毛但俺真的尽力了。华子加油。
接下来的将是一些网络排障的一些方法。期待自己的总结。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/79887/showart_2067615.html
posted @ 2010-10-18 21:49  .小武.  阅读(4792)  评论(0编辑  收藏  举报