Cisco正则表达式可以用来简化查询,因而看起来比较直观明了,前面的配置过程就省略了,拓扑如下:
KC1——KC2——KC3
在网络中启用了RIP协议,结合命令show run来测试下。
这是完整版的sh run输出:
KC1#sh run Building configuration… Current configuration : 958 bytes ! version 12.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname KC1 ! boot-start-marker boot-end-marker ! ! no aaa new-model memory-size iomem 5 ! ! ip cef no ip domain lookup ! ! interface Loopback0 ip address 1.1.1.1 255.255.255.0 ! interface FastEthernet0/0 no ip address shutdown duplex auto speed auto ! interface Serial1/0 ip address 172.16.12.1 255.255.255.0 serial restart-delay 0 clock rate 64000 ! interface Serial1/1 no ip address shutdown serial restart-delay 0 ! interface Serial1/2 no ip address shutdown serial restart-delay 0 ! interface Serial1/3 no ip address shutdown serial restart-delay 0 ! router rip network1.0.0.0 network 172.16.0.0 ! ip http server no ip http secure-server ! ! control-plane ! ! line con 0 exec-timeout 0 0 logging synchronous line aux 0 line vty 0 4 ! ! end |
使用简化查询,想看什么就看什么,不用杂杂乱乱地找了:(下面输出即以router rip开始了)
KC1#sh run | b r r/使用正则表达式 router rip network 1.0.0.0 network 172.16.0.0 ! ip http server no ip http secure-server ! ! control-plane ! ! line con 0 –More– |
可以来看看正则表达式的参数信息,以及命令格式:
KC1#sh run | ? appendAppend redirected output to URL (URLs supporting append operation only) beginBegin with the line that matches/上面b即begin excludeExclude lines that match includeInclude lines that match redirectRedirect output to URL sectionFilter a section of output teeCopy output to URL |
好像有点明白了,begin r r即以匹配r r字段(routerrip)信息开始输出
KC1#sh run | begin ? LINERegular Expression |
当然,也可以结合其他命令来查询信息,用sh iproute来看看
KC1#sh ip route | includeR Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP D -EIGRP, EX - EIGRP external, O -OSPF, IA - OSPF inter area o - ODR, P - periodic downloaded static route R172.16.23.0 [120/1] via 172.16.12.2, 00:00:19, Serial1/0 |
只能看到output有关RIP的路由了:)
