JNCIP案例分析 – Juniper/Cisco OSPF互操作 Part3

2. JUNOS与IOS OSPF路由策略及数据库信息交互

kangaroo

  1. R1/R2之间的10.0.5/24网段路由以外部路由的形式在区域0出现;
  2. 将10.0.5/24路由的初始Metric设置为10,贴上420标签,同时所有OSPF会根据内部开销自动调节该路由在本地的Metric值;
  3. 保证R1不会产生Network LSA(LSA-2);

通过在R1/R2上设置OSPF导出策略,指定初始化Metric,标签,并且将其外部路由类型设置为类型1,以便在路由转发的过程中通过累链路开销而自动调节Metric值。我们很容易的使他们的直连网段10.0.5/24以外部路由的形式进入骨干区域。因为该网段直接从直连路由注入OSPF,我们没有必要将该接口在区域1内通告。另外,将R1上所有OSPF接口的优先级设置为0,强迫其退出DR/BDR选举,因此R1将不会产生只能由DR/BDR通告的LSA-2。

nigel@junos7.2# show r1 protocols ospf
export external;
area 0.0.0.1 {
    interface lo0.1;
    interface fxp1.13 {
        priority 0;
    }
    interface fxp1.12 {
        priority 0;
    }
}

[edit logical-routers]
nigel@junos7.2# show r1 policy-options
policy-statement external {
    term 1 {
        from {
            protocol direct;
            route-filter 10.0.5.0/24 exact;
        }
        then {
            metric 10;
            tag 420;
            external {
                type 1;
            }
            accept;
        }
    }
    term 2 {
        then reject;
    }
}

查看R1接口状态,我们可以确认R1退出OSPF的DR/BDR选举,而其状态显示为DRother。

nigel@junos7.2# run show ospf interface logical-router r1
Interface State    Area    DR ID    BDR ID  Nbrs
fxp1.12   DRother  0.0.0.1 10.0.6.2 0.0.0.0    1
fxp1.13   DRother  0.0.0.1 10.0.3.3 0.0.0.0    1
lo0.1     DR       0.0.0.1 10.0.6.1 0.0.0.0    0

继续查看R4/R5的OSPF数据库,验证通过external策略设置的10.0.5/24外部路由的各项属性,包括LSA类型,外部路由类型,初始化Metric以及Tag,均能够被JUNOS以及IOS的OSPF数据库识别。并查看路由表进一步确认该路由的Metric值在初始为10的基础上被不断累加。留意在JUNOS的OSPF数据库中Tag使用IP分段格式显示,0.0.1.164 = 256+164,得出结果同样为420。

nigel@junos7.2# run show ospf database logical-router
r5 extern advertising-router 10.0.6.1 detail

    OSPF AS SCOPE link state database
 Type       ID      Adv Rtr  Seq       Age Opt Cksum Len
Extern   10.0.5.0 10.0.6.1 0x80000002 2565 0x2 0x2260 36
  mask 255.255.255.0
  Type 1, TOS 0x0, metric 10, fwd addr 0.0.0.0,
  tag 0.0.1.164
r4#show ip ospf database external 10.0.5.0 adv-router
10.0.6.1

		OSPF Router with ID (10.0.3.4) (Process ID 64)

		Type-5 AS External Link States

  LS age: 2230
  Options: (No TOS-capability, No DC)
  LS Type: AS External Link
  Link State ID: 10.0.5.0 (External Network Number )
  Advertising Router: 10.0.6.1
  LS Seq Number: 80000002
  Checksum: 0x2260
  Length: 36
  Network Mask: /24
	Metric Type: 1 (Comparable directly to link state
	metric)
	TOS: 0
	Metric: 10
	Forward Address: 0.0.0.0
	External Route Tag: 420
nigel@junos7.2# run show route logical-router r5
10.0.5/24 

inet.0: 23 destinations, 23 routes (23 active,
0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.0.5.0/24     *[OSPF/150] 00:15:30, metric 12, tag 420
                 > to 10.0.2.2 via fxp2.35
                   to 10.0.2.10 via fxp2.45
r4#sh ip route ospf
     10.0.0.0/8 is variably subnetted, 18 subnets,
     3 masks
<!-- Output omitted -->
O E1    10.0.5.0/24 [110/20] via 10.0.4.10, 00:00:01,
     FastEthernet0/0.24

查看两者的路由表可以确认Metric在初始为10的基础上被不断累加。有趣的地方在于IOS对于OSPF的外部路由与内部路由在管理距离上并没有区分,均为110;而JUNOS则对OSPF的内部路由与外部路由分别设置了不同的Preference 10与150。尽管如此,IOS的路由表内通过“O E1”标识出该路由为类型1的外部路由,同时虽然采用相同的管理距离,IOS内部的选路机制也存在针对域内、域间、域外路由的优先区分。对于不习惯看Preference的工程师来说这种标识更为明确。而其实JUNOS也提供类似的输出命令,个人觉得还是IOS更为直观,习惯问题。人必有痴,而后有成。

nigel@junos7.2# run show ospf route extern logical-router 
r5
Prefix      Path Route   NH   Metric NextHop   Nexthop
            Type Type    Type        Interface addr/label

10.0.5.0/24 Ext1 Network IP   12     fxp2.35   10.0.2.2
  area 0.0.0.0, origin 10.0.6.2

相应的,对于上面在R1/R2将直连网段注入OSPF并且设置相关路由属性信息的策略,在IOS上也能够得到反映。我们在R4上新增测试接口fa0/0.47,将该测试接口的IP网段172.16.47.0/30使用相同的属性注入OSPF。

r4#wr t
!
router ospf 64
 router-id 10.0.3.4
 log-adjacency-changes
 redistribute connected subnets route-map external
 network 10.0.2.4 0.0.0.3 area 0
 network 10.0.2.8 0.0.0.3 area 0
 network 10.0.3.4 0.0.0.0 area 0
 network 10.0.4.8 0.0.0.3 area 1
!
access-list 1 permit 172.16.47.0 0.0.0.3
!
route-map external permit 10
 match ip address 1
 set metric 10
 set metric-type type-1
 set tag 420
!

LSA进入JUNOS的OSPF数据库中,同样的属性也能够被显示出来。相比较而言,似乎JUNOS的Policy设置更为简便,无需先制定access-list后再绑定到route-map里面去。而实际上是JUNOS的route-filter机制带来简便的体验,假如无需对特定的路由进行过滤,IOS可以直接使用redistribute命令捆绑相关注入路由属性:Metric值,Metric类型,tag等而无需引用route-map

nigel@junos7.2# run show ospf database logical-router r5 
lsa-id 172.16.47.0 detail
    OSPF AS SCOPE link state database
 Type       ID      Adv Rtr  Seq       Age Opt Cksum Len
Extern 172.16.47.0 10.0.3.4 0x80000001 31  0x2 0x7e0d 36
  mask 255.255.255.252
  Type 1, TOS 0x0, metric 10, fwd addr 0.0.0.0,
  tag 0.0.1.164

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s