电脑技术学习

CCNA认证培训辅导:路由器的管理

dn001

  提问 希望获得相连网络设备的信息

  回答

  Router1#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router1(config)#cdp run

  Router1(config)#interface Serial0/0

  Router1(config-if)#cdp enable

  Router1(config-if)#exit

  Router1(config)#interface FastEthernet0/0

  Router1(config-if)#no cdp enable

  Router1(config-if)#exit

  Router1(config)#interface FastEthernet1/0

  Router1(config-if)#cdp enable

  Router1(config-if)#end

  Router1#

  注释 CDP(Cisco Discovery Protocol)是思科专有的协议,用于发现相连的思科设备,帮助了解网络拓朴,缺省是启用的,使用show cdp neighbor detail 命令可以查看相连设备的详细信息

  2.6. 禁止CDP协议

  提问 为了安全期间不想让邻近设备发现自己设备的信息

  回答

  Router1#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router1(config)#cdp run

  Router1(config)#interface FastEthernet0/0

  Router1(config-if)#no cdp enable

  Router1(config-if)#end

  Router1#

  注释 为了安全期间可以在边界设备上禁止CDP

  2.7. 小服务的开启

  提问 开启或者禁用一些类似finger的小服务

  回答

  Router1#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router1(config)#service tcp-small-servers (no service tcp-small-servers)

  Router1(config)#service udp-small-servers (no sercie udp-small-servers)

  Router1(config)#end

  Router1#

  Router1#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router1(config)#ip finger (no ip finger)

  Router1#

  注释 tcp和udp的小服务指开启路由器的echo,discard,daytime和chargen服务,为了安全期间都建议将其关闭

  2.8. 启用路由器HTTP访问

  提问 通过浏览器来配置和管理路由器

  回答

  Router1#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router1(config)#access-list 75 permit 172.25.1.1

  Router1(config)#access-list 75 deny any

  Router1(config)#ip http server

  Router1(config)#ip http access-class 75

  Router1(config)#end

  Router1#

  注释 由于IOS 12.1(5)之前存在HTTP访问的高危漏洞,所以如果你的IOS版本小于此版本建议不要开启此服务

  2.9. 启用路由器安全HTTPS访问

  提问 通过加密的访问HTTP访问路由器

  回答

  Core#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Core(config)#ip http secure-server

  Core(config)#end

  Core#

  注释 IOS 12.2(14)S之后引入此特性,建议先用no ip http server命令关闭非加密的HTTP访问,然后开启安全的访问,同时可以使用ip http secure-port 8080

  命令来更改访问端口
  2.10. 使用静态主机名映射

  提问 在路由器上配置静态的主机映射表,从而使用主机名而不是IP地址来访问设备

  回答

  Router1#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router1(config)#ip host freebsd 172.25.1.1

  Router1(config)#ip host router2 10.1.1.1 172.22.1.4

  Router1(config)#end

  Router1#

  注释 可以对一个主机名映射很多IP地址来提供冗余访问,show hosts命令来验证

  2.11. 启用DNS服务

  提问 路由器使用DNS服务器来解析主机名

  回答

  Router1#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router1(config)#ip domain-lookup

  Router1(config)#ip domain-name oreilly.com

  Router1(config)#ip name-server 172.25.1.1

  Router1(config)#ip name-server 10.1.20.5

  Router1(config)#end

  Router1#

  注释 从IOS 12.2开始,思科使用了ip domain lookup.来代替ip domain-lookup 类似的ip domain-name 被 ip domain name代替

  2.12. 禁用域名解析

  提问 禁用域名解析,防止路由器自动对打错的命令的进行DNS查询

  回答

  Router1#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router1(config)#no ip domain-lookup

  Router1(config)#end

  Router1#

  如果需要启用DNS查询主机名,但是又为了避免打错命令查询的情况可以使用如下的变通方法

  Router1#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router1(config)#line vty 0 4

  Router1(config-line)#transport preferred none

  Router1(config-line)#end

  Router1#

  注释 对后一个命令的稍微解释一下,正常情况下都知道可以直接使用主机名回车路由器会认为时telnet 到此设备,可以省略掉telnet的命令,原因是因为transport preferred缺省是telnet,如果配置为none就必须使用telnet命令来进行设备登录,命令打错也不会出现地址解析的问题了。

  2.13. 配置路由器特定时间重启

  提问 需要路由器在特定时间自动重启

  回答

  Router1#reload in 20

  Reload scheduled for 11:33:53 EST Sat Feb 1 2003 (in 20 minutes)

  Proceed with reload? [confirm]

  Router1#

  Router1#reload at 14:00 Feb 2

  Reload scheduled for 14:00:00 EST Sun Feb 2 2003 (in 26 hours and 44 minutes)

  Proceed with reload? [confirm]

  Router1#

  注释 很有用的命令,当你在对路由器配置进行修改前可以先行输入此命令,然后进行修改但是不保存配置,这样可以防止把自己锁在路由器之外。可以使用reload cancel命令来取消定时重启
  2.14. 定时执行配置命令

  提问 周期性的定时执行某个命令

  回答

  Router#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router(config)#kron policy-list NEOSHI

  Router(config-kron-policy)#cli write memory

  Router(config-kron-policy)#exit

  Router(config)#kron occurrence DAILYat5 at 17:00 recurring

  Router(config-kron-occurrence)#policy-list NEOSHI

  Router(config-kron-occurrence)#end

  Router#

  注释 从IOS12.3(1)开始引入了这个类似Unix Cron的特性,不过也有一些缺点,只能运行EXEC模式下的命令,不能运行配置模式下的命令,同时输入的命令不能是交互性的,比如不能输入copy running-config startup-config来保存配置,因为是需要确认的,必须使用write memory来代替

  2.15. 显示路由器CPU利用率的历史数据

  提问 显示历史的路由器CPU利用率

  回答

  Router# show processes cpu history

  Router 03:48:18 PM Monday Apr 17 2006 EDT

  555559999999999999999

  5 444449999999999999999

  100 ******************

  90 ******************

  80 ******************

  70 ******************

  60 ******************

  50 ***********************

  40 ***********************

  30 ***********************

  20 ***********************

  10 * ***********************

  0....5....1....1....2....2....3....3....4....4....5....5....

  0 5 0 5 0 5 0 5 0 5

  CPU% per second (last 60 seconds)

  99 1 9999

  99 1 4 9999

  100 ** ***#*#

  90 ** **##*#

  80 #* *###*#

  70 #* *###*#

  60 #* *###*#

  50 #* *#####

  40 #* *#####

  30 #* ######

  20 ## ######

  10 ## * ######

  0....5....1....1....2....2....3....3....4....4....5....5....

  0 5 0 5 0 5 0 5 0 5

  CPU% per minute (last 60 minutes)

  * = maximum CPU% # = average CPU%

  ……………………………….(由于显示问题省去此图).

  CPU% per hour (last 72 hours)

  * = maximum CPU% # = average CPU%

  注释 从IOS12.2(2)T以后思科为show process cpu命令增加了history的选项,这样可以看到最长3天的CPU利用率,而以前最多可以看到5分钟的。输出图很不容易看懂,简单的说最左边是最新的数据,然后历史数据会向右移,在每分钟和每小时的会有峰值和平均值,峰值为现在每列的上端,不过是竖着排列的。
  2.16. 生成意外导出文件(Exception Dump Files)

  提问 在路由器发生意外当机的情况下生成导出文件发给TAC进行处理

  回答

  Router1#configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Router1(config)#ip ftp source-interface Loopback0

  Router1(config)#ip ftp username ijbrown

  Router1(config)#ip ftp password ijpassword

  Router1(config)#exception protocol ftp

  Router1(config)#exception region-size 65536

  Router1(config)#exception dump 172.25.1.3

  Router1(config)#end

  Router1#

  注释 缺省情况下路由器会使用tftp命令进行传送,不过TFTP有16M的限制所以建议换为FTP协议。另外为了防止当机导致文件不能生成,所以使用了exception region-size 65536 来提前保留部分内存给该命令使用。可以先使用write core命令来提前实验下生成此文件

  2.17. 生成接口信息报告

  2.18. 生成路由表报告

  2.19. 生成ARP表报告

  2.20. 生成主机表报告

  以上都是使用perl脚本来进行命令输出的汇总操作,脚本略去

标签: