admin管理员组

文章数量:1576958

路由器       路由器引导方式配置     Router(config)#boot system flash [IOS文件名] //从flash中引导 Router(config)#boot system fttp [tftp地址] [IOS文件名] //从TFTP中引导 Router(config)#boot syste rom //从rom中引导 说明:若有多条加载路径,启动时按顺序加载,若第一条加载失败则试图从随后路径中加载。   用户名与口令     router(config)#username tang password bang   本地登录认证     router(config)#line vty 0 4 router(config)# login //使用enable密码进行登录验证,也可以通过password语句设置密码。 router(config-line)#login local  //使用已建立的用户名和密码进行验证   接口配置     router(config)#interface s0 router(config-if)#ip address 192.168.1.1 255.255.255.0   timeout时间设置     router(config)#line console 0 router(config-line)#exec-timeout [min] [sec] //无动作时超时 router(config-line)#session-timeout [min] //会话超时 router(config-line)#absolute-time //绝对超时   权限设置     router(config)#privilege exec level [0-15] [命令]   //[命令]为当前权限下允许执行的命令,如:show run   静态路由     router(config)#ip route [目的网络] [掩码] [下一跳地址|出口] [管理距离] [不通是否删除] router(config)#ip route [目的网络] [掩码] [null 0|loopback 0]   //目的网络对应的IP包被丢弃。 说明:可以设置null接口参数,使路由器向客户端返回或不返回“目标不可达”的ICMP包。默认情况下要返回ICMP。如: Router(config)#int null 0 Router(config-if)#ip unreachables //向客户端返回目标不可达信息 Router(config-if)#no ip unreachables   //不返回目标不可达信息,客户端显示超时。   route-map设置     router(config)#route-map Engineers [permit|deny] [序号] //定义标记为Engineers的route-map。 router(config-route-map)#match ip address [访问列表号] //设置访问列表定义的匹配条件 router(config-route-map)#set ip next-hop 10.15.27.1 //匹配后设置下一跳地址 router(config-if)#ip policy route-map Engineers //在接口上应用Engineers.   OSPF路由     OSPF路由基本配置 router(config)#router ospf 10 router(config-router)#network 192.168.2.0 0.0.0.255 area 0 OSPF认证 区域明文认证模式命令: Router(config-router)# area area-id authentication Router(config-if)# ip ospf authentication-key key 区域MD5认证模式命令: Router(config-router)# area area-id authentication message-digest Router(config-if)# ip ospf message-digest-key key-id md5 md5key 接口明文认证模式命令: Router(config-if)# ip ospf authentication Router(config-if)# ip ospf authentication-key key 接口MD5认证模式命令: Router(config-if)# ip ospf authentication message-digest Router(config-if)# ip ospf message-digest-key key-id md5 md5key 虚链路上的认证 Router(config-router)#area [区域号] virtual-link [对端路由器ID] authentication [authentication-key 密码|message-disgest |null ] 如:router(config-router)#area 1 vir 2.2.2.2 authe me //在虚链路上启用MD5认证          Router(config-router)#area 1 vir 2.2.2.2 me 1 md5 cisco //认证认证参数 OSPF Stub区域 stub区域内部路由器: area area-id stub   stub区域ABR:       area area-id stub   totally stubby区域内部路由器: area area-id stub   totally stubby区域ABR:       area area-id stub no-summary 说明:stub区域配置需要在区域内所有路由器上配置,边界路由器会将静态路由和内部网 关路由信息传递到区域内,而不将自治系统外部路由传入。完全stub区域配置只需在边界路由器上配置,区域内其它路由器只配置成stub区域。边界路由器 只将静态路由传入区域内部路由器,而不传递内部和外部路由信息到区域内。 OSPF cost值修改 router(config)#int s1/0 router(config-if)#ip ospf cost 10 直接修改ospf cost的值 router(config-router)#auto-cost reference-bandwidth 1000 //修改带宽参考值,单位Mb/s,默认参考带宽为100。 OSPF区域路由汇总和在接口上禁用OSPF router(config-router)#area [区域号] rang 192.168.0.0 255.255.0.0(子网范围) router(config-router)#passive-interface f0/1 //在接口f0/1上禁用ospf,尤其是有多个路由协议时,通过在接口上禁用某种路由协议,防止路由环路形成。 router(config-router)#passive-interface default //所有接口都被动接收,若要使某个接口发送ospf信息,可以使用下面的命令: router(config-router)#no passive-interface f0/1  路由重发布 Router(config-router)#default-information generate [always| metric|metric-type]  //在区域内产生默认路由并广播到区域内,此命令用于ASBR。Always用于防止缺省链路抖动,metric用于修改重发布路由的metric值。 Metric-type是通告路由的类型。 Router(config-router)#redistribute rip [subnets] //重发布rip协议的路由,有subnets参数时支持变长子网,否则只支持有类路由。 Router(config-router)#redistribute static [subnets] //重发布静态路由 Router(config-router)#redistribute connected //重发布直接相连网络 说明:重发布路由时还应指定metric,rip协议中重发布OSPF时,默认metric为16,这样,rip协议的路由器就无法学习到ospf的路由,要解决这个问题,要么设置默认metric,要么在重发布路由时指定metric。如下: Router(config)#router rip Router(config-router)#redistribute ospf 10 metric 1 //metric范围为1-15 或: Router(config-router)#default-metric 1  //指定学习到的路由信息默认metric为1 OSPF路由策略 router(config-router)#redistribute static route-map Engineers //在重发布路由时,根据router-map进行路由过滤。此例为重发布静态路由,route-map名为Engineers。 Router(config-router)#distribute-list [访问列表号|访问列表名] in|out //根据访问列表进行路由过滤   lookback设置     router(config)#interface lookback 0 router(config-if)#ip add 1.1.1.1 255.255.255.255    访问列表     标准访问列表: router(config)#access-list 20 [deny|permi] host 192.168.4.3 一个地址 router(config)#access-list 20 [deny|permi] 192.168.2.0 255.255.255.0 一个地址段 router(config)#int s1/4 router(config-if)#ip access-group 20 [in|out] 将访问列表加入到接口中 扩展访问列表: router(config)#access-list 110 deny tcp any host 192.168.2.1 eq www router(config)#acc 110 permit ip any any router(config)#acc 120 permit ip any any time-range [时间范围名] //根据时间范围进行过滤。时间范围在全局配置模式下使用time-range [时间范围名] 命令进行定义。 说明:需要注意的是,访问列表默认是阻止所有!如果仅禁用WWW,则应该在后面添加一句permit ip any any。   telnet登录地址限制     router(config)#access-list 11 per 192.168.1.34 router(config-line)#lin vty 0 4 router(config-line)#access-class 11 in 说明:只允许IP地址为192.168.1.34的telnet登录到路由器 Router(config-line)#rotary 25 //添加一个登录端口3000+25   Chap和pap认证     chap认证 router(config)#username r1 password pass router(config-if)#encapsulation ppp router(config-if)#ppp authentication chap 说明:使用chap验证的双方在配置用户名和密码时,密码必须一致。服务端要求验证的用户名是对端路由器名。 pap认证 router(config)#username r2 password pass2 router(config)#interface s0 router(config-if)#encapsulation ppp router(config-if)#ppp pap sent-username  r1 password pass1 说明:两端交叉配置,发送对方所设置的用户名和密码。   帧中继配置     router(config)#frame-relay switching //启用PVC交换 router(config)#int s1/0 router(config-if)#ip add 192.168.1.1 255.255.255.0 router(config-if)#encapsulation frame-relay router(config-if)#fr intf-type dce//另一端默认定义DTE ,也可以两端都设成NNI ,设成nni时可动态生成frame-relay map ip ,但生成map的速度较慢。 router(config-if)#fr interface-dlci 100 //定义DLCI号,DTE需要使用DLCI号 router(config-if)#fr map ip 192.168.1.2 100 broadcast router(config-if)#fr lmi-type ansi router(config-if)#no sh 如果使用OSPF协议,帧中继默认的网络类型是NBMA。需要在定义ospf路由信息时 使用neighbor 192.168.1.2 语句,否则OSPF生成的路由表中没有通过帧中继网的路由信息。也可以在接口模式下,将网络类型改变为广播、点对点、点对多点,这样就不必在定义OSPF 路由neighbor。 router(config-if)#ip ospf network point-to-point //更改OSPF网络类型,可以改为broadcast, point-to-multicast, non-broadcast router#show frame-relay map //此语句可显示DLCI与IP地的映射,如果两端显示的状态均为active,则可正常通信。   SNMP协议     router(config)#snmp-server community public ro router(config)#snmp-server host 192.168.1.2 traps public 说明:public是一个范围的名称 host 192.168.1.2是一个snmp的服务器,可以通过该服务器对此路由器进行snmp的管理   组播协议(域内路由协议PIM的配置)     启用多播路由 router(config)# ip multicast-routing 路由器之间接口配置为稀疏模式: Router(config-if)#ip pim sparse-mode 路由器与主机相连的接口配置成被动模式 Router(config-if)# ip pim passive //3640上没有此命令 候选RP、BSR配置 全局配置模式下配置候选BSR,候选RP ,这两个接口都应当连接到路由器 Router(config)# ip pim bsr-candidate Ethernet 1/3 Router(config)# ip pim rp-candidate Ethernet 1/1



本文转自 yhw85 51CTO博客,原文链接:http://blog.51cto/yanghuawu/932188,如需转载请自行联系原作者

本文标签: 路由器Cisco