51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1762|回复: 1
打印 上一主题 下一主题

JunOS 快速查看某部分路由的方法

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2009-4-28 10:23:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
路由数量小的时候直接show route 让我们消耗的时间或许并不多,但对于Juniper的M/T系列来说,本身面向的就是Internet骨干路由器,很多情况下都会收全球路由,甚至本AS内所有的明细路由,这些量都是很大的,少则数万,多则数百万.在这时候我们还show route来慢慢找的话是相当浪费时间的,或许有些人会说match,其实这是最笨的方法,和show route 慢慢按空格差不多,只不过不用你的眼睛去盯着.下面简单介绍一下我自己的一些体会:

1.根据路由所在的路由表来查找show route logical-router 163 table inet.0 terse

root@j72r42> show route logical-router 163 table inet.0 terse
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
* 0.0.0.0/0 S 5 Discard
* 1.0.0.0/16 B 170 100 >1.0.1.1 1 I
B 170 100 0 >1.0.1.1 1 I
B 170 100 0 >1.0.1.1 1 I
B 170 100 0 >163.0.2.2 4809 1 I
B 170 100 0 >163.0.1.2 65000 1 I

看起来这和直接show route 并没有什么区别,但如果你要看的ipv6路由或者组播路由,那你可能要把之前的几十万空格完了才能看到,由于在JunOS中,ipv4/ipv6/mpls路由都是分在不同的路由表中,这样使用table routing-table-name 的方式来查看ipv4以外的路由是相当方便的.


2.根据路由协议来查找show route logical-router 163 protocol bgp terse

root@j72r42> show route logical-router 163 protocol bgp terse
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
* 1.0.0.0/16 B 170 100 >1.0.1.1 1 I
B 170 100 0 >1.0.1.1 1 I
B 170 100 0 >1.0.1.1 1 I
B 170 100 0 >163.0.2.2 4809 1 I
B 170 100 0 >163.0.1.2 65000 1 I

一般来说,一个规划得好的网络是不会存在太多不同的路由协议的,但就骨干网来说,通常至少会有两种:BGP和ISIS,BGP的路由数量显然是最多的,但由于ISIS主要承担接口地址的互通,网络规模大了以后ISIS路由的数量也不可小看.区分协议来查看很有必要.


3.根据收到该路由的协议及邻居来查看show route logical-router 163 receive-protocol bgp 163.0.0.11

root@j72r42> show route logical-router 163 receive-protocol bgp 163.0.0.11
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
Prefix Nexthop MED Lclpref AS path
1.0.0.0/16 1.0.1.5 0 100 1 I
1.0.1.0/30 1.0.1.5 0 100 1 I
1.0.1.8/30 1.0.1.5 0 100 1 I
1.0.1.12/30 1.0.1.5 0 100 1 I

这里需要主意的是:这种方法对链路状态路由协议无效(原因?自己想),支持bgp,dvmrp,msdp,pim,rip,ripng等集中协议.


4.查看通告给相应邻居对应协议的路由show route logical-router 163 advertising-protocol bgp 163.0.0.11

root@j72r42> show route logical-router 163 advertising-protocol bgp 163.0.0.11
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
Prefix Nexthop MED Lclpref AS path
* 0.0.0.0/0 Self 0 100 8888 9999 9999 9999 9999 9999 I
* 1.0.0.0/16 1.0.1.1 0 100 1 I
* 1.0.1.4/30 1.0.1.1 0 100 1 I
* 1.0.1.8/30 1.0.1.1 0 100 1 I

和3一样,这里也仅支持那集中协议.


5.根据BGP路由的AS-Path属性来查看show route logical-router 163 terse aspath-regex .*9808

root@j72r42> show route logical-router 163 terse aspath-regex .*9808
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
* 211.103.0.0/17 B 170 100 0 >163.0.1.6 9808 I
B 170 100 0 >163.0.1.10 9808 I
B 170 100 0 >163.0.2.2 4809 9808 I
B 170 100 0 >163.0.1.2 65000 4809 9808 I
* 211.103.0.0/18 B 170 100 0 >163.0.1.6 9808 I
B 170 100 0 >163.0.1.10 9808 I
B 170 100 0 >163.0.2.2 4809 9808 I
B 170 100 0 >163.0.1.2 65000 4809 9808 I

需要注意的是:当aspath-regex参数后跟的正则表达式中含有某些cli已用的或其他特殊字符时需要用""括起来,例如

root@j72r42> show route logical-router 163 terse aspath-regex "()"
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
* 0.0.0.0/0 S 5 Discard
* 1.0.1.0/30 D 0 >fxp2.80
* 1.0.1.2/32 L 0 Local
* 58.30.0.0/15 I 165 10 >163.0.1.6
B 170 100 0 >163.0.1.6 I

6.根据community来查看show route logical-router 163 terse community 4134:1631

root@j72r42> show route logical-router 163 terse community 4134:1631
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
58.30.0.0/15 B 170 100 0 >163.0.1.6 I
58.32.0.0/13 B 170 100 0 >163.0.1.6 I
58.40.0.0/15 B 170 100 0 >163.0.1.6 I
58.42.0.0/17 B 170 100 0 >163.0.1.6 I
58.42.128.0/17 B 170 100 0 >163.0.1.6 I

可以更细化的根据这条路由的来源来查找(前提当然是这条路由是BGP且打了community)


7.与6相反,查看没有community的路由show route logical-router 163 terse no-community

root@j72r42> show route logical-router 163 terse no-community
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
* 0.0.0.0/0 S 5 Discard
* 1.0.1.0/30 D 0 >fxp2.80
* 1.0.1.2/32 L 0 Local
* 58.30.0.0/15 I 165 10 >163.0.1.6
* 58.32.0.0/13 I 165 10 >163.0.1.6
* 58.40.0.0/15 I 165 10 >163.0.1.6

8.根据下一跳查找show route logical-router 163 terse next-hop 163.0.2.2

root@j72r42> show route logical-router 163 terse next-hop 163.0.2.2
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
* 58.43.192.0/18 B 170 100 0 >163.0.2.2 4809 I
* 58.49.108.0/24 B 170 100 0 >163.0.2.2 4809 I
58.154.0.0/15 B 170 100 0 >163.0.2.2 4809 4538 I
58.192.0.0/12 B 170 100 0 >163.0.2.2 4809 4538 I
58.192.0.0/14 B 170 100 0 >163.0.2.2 4809 4538 I


9.根据路由的出接口查找show route logical-router 163 output interface fxp1.5

root@j72r42> show route logical-router 163 output interface fxp1.5
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
+ = Active Route, - = Last Active, * = Both
1.0.0.0/16 [BGP/170] 4d 01:23:29, MED 0, localpref 100
AS path: 4809 1 I
> to 163.0.2.2 via fxp1.5
1.0.1.0/30 [BGP/170] 4d 07:35:14, MED 0, localpref 100
AS path: 4809 1 I
> to 163.0.2.2 via fxp1.5
1.0.1.4/30 [BGP/170] 4d 07:35:14, MED 0, localpref 100
AS path: 4809 1 I
> to 163.0.2.2 via fxp1.5
1.0.1.8/30 [BGP/170] 4d 07:35:14, MED 0, localpref 100
AS path: 4809 1 I
> to 163.0.2.2 via fxp1.5

10.直接查看show route logical-router 163 terse 211.139.0.0

root@j72r42> show route logical-router 163 terse 211.139.0.0
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
* 211.139.0.0/20 B 170 100 0 >163.0.1.6 9808 I
B 170 100 0 >163.0.1.10 9808 I
B 170 100 0 >163.0.2.2 4809 9808 I
B 170 100 0 >163.0.1.2 65000 4809 9808 I

可以带掩码查看,不带掩码为最长匹配该地址的路由


11.使用range参数 show route logical-router 163 terse range 211.139.0.0/18

root@j72r42> show route logical-router 163 terse range 211.139.0.0/18
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
* 211.139.0.0/20 B 170 100 0 >163.0.1.6 9808 I
B 170 100 0 >163.0.1.10 9808 I
B 170 100 0 >163.0.2.2 4809 9808 I
B 170 100 0 >163.0.1.2 65000 4809 9808 I
* 211.139.16.0/20 B 170 100 0 >163.0.1.6 9808 I
B 170 100 0 >163.0.1.10 9808 I
B 170 100 0 >163.0.2.2 4809 9808 I
B 170 100 0 >163.0.1.2 65000 4809 9808 I
* 211.139.32.0/19 B 170 100 0 >163.0.1.6 9808 I
B 170 100 0 >163.0.1.10 9808 I
B 170 100 0 >163.0.2.2 4809 9808 I
B 170 100 0 >163.0.1.2 65000 4809 9808 I

查看指定网段(支持VLSM)包含的路由,不加掩码表示/32


12.查看指定路由的详细信息show route logical-router 163 210.40.32.1 extensive

root@j72r42> show route logical-router 163 210.40.32.1 extensive
inet.0: 3349 destinations, 10672 routes (3348 active, 0 holddown, 3 hidden)
210.40.0.0/18 (4 entries, 1 announced)
TSI:
KRT in-kernel 210.40.0.0/18 -> {163.0.2.2}
Page 0 idx 0 Type 1 val 87c02b8
Nexthop: Self
MED: 0
AS path: 4809 4538 I
Communities: 4538:1
Page 0 idx 1 Type 1 val 86e3fd8
Nexthop: 163.0.2.2
MED: 0
Localpref: 100
AS path: 4809 4538 I
Communities: 4538:1
Page 0 idx 3 Type 1 val 88d9540
Nexthop: Self
MED: 0
AS path: 4809 4538 I
Communities: 4538:1
Path 210.40.0.0 from 163.0.2.2 Vector len 4. Val: 0 1 3
*BGP Preference: 170/-101
Next-hop reference count: 6484
Source: 163.0.2.2
Next hop: 163.0.2.2 via fxp1.5, selected
State: <Active Ext>
Local AS: 4134 Peer AS: 4809
Age: 4d 7:42:59 Metric: 0
Task: BGP_4809.163.0.2.2+179
Announcement bits (3): 0-KRT 4-BGP.0.0.0.0+179 5-Resolve tree 2
AS path: 4809 4538 I
Communities: 4538:1
Localpref: 100
Router ID: 59.0.0.1
BGP Preference: 170/-101
Next-hop reference count: 2258
Source: 163.0.1.2
Next hop: 163.0.1.2 via fxp1.10, selected
State: <Ext>
Inactive reason: AS path
Local AS: 4134 Peer AS: 65000
Age: 4d 7:42:59 Metric: 0
Task: BGP_65000.163.0.1.2+179
AS path: 65000 4809 4538 I
Communities: 4538:1
Localpref: 100
Router ID: 200.0.0.1

在BGP选路时这条命令很有用,从其中的Inactive reason可以看出这条路由没有被优选的原因。还可以看到该路由的AS Path,Communities,MED,LocalPref等属性值。
带extensive参数时最好指定最长匹配的地址,否则stdout输出太多反而得不偿失。

经过上边这些参数的应用,相信能给路由查找节约不少的时间,同时也尽量的减轻了RE的负担
show route | match操作很占CPU的,我在qemu中做的一个测试,同时ssh登陆三个用户,执行show route logical-router all terse | match / | count ,查看load,接近5.3
CPU使用率也很高。

以上不能说是原创,因为这都是JunOS中固有的参数,只不过是稍加灵活的运用了一下。这些参数大家都知道的,只是在实际应用中可能没太在意。

虽然条条大路通罗马,但毕竟都希望能尽快的到达目的地.
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2009-4-28 14:18:29 | 只看该作者
本身面向的就是Internet骨干路由器,很多情况下都会收全球路由
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-13 08:40 , Processed in 0.069240 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表