在路由引入时应用路由策略示例
组网需求
RouterB与RouterA之间通过OSPF协议交换路由信息,与RouterC之间通过IS-IS协议交换路由信息。要求在RouterB上将IS-IS网络中路由引入到OSPF网络后,OSPF网络中路由172.16.1.0/24的选路优先级较低;路由172.16.2.0/24具有标识,方便以后运用路由策略。
配置思路
采用如下的思路配置在路由引入时应用路由策略:
- 在RouterB上配置路由策略,将172.17.1.0/24的路由的开销设置为100,并在OSPF引入IS-IS路由时应用路由策略,实现OSPF网络中路由172.17.1.0/24的选路优先级较低;将172.17.2.0/24的路由的Tag属性设置为20,实现路由172.17.2.0/24具有标识,方便以后运用路由策略。
- 在RouterB上配置路由策略,将172.17.2.0/24的路由的Tag属性设置为20,并在OSPF引入IS-IS路由时应用路由策略,实现路由172.17.2.0/24具有标识,方便以后运用路由策略。
操作步骤
配置OSPF
RouterA
<Huawei>sys
[Huawei]sys RouterA[RouterA]int g0/0/0
[RouterA-GigabitEthernet0/0/0]ip add 192.168.1.1 24
[RouterA-GigabitEthernet0/0/0]q[RouterA]ospf
[RouterA-ospf-1]area 1
[RouterA-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255
[RouterA-ospf-1-area-0.0.0.1]q
[RouterA-ospf-1]q
RouterB
<Huawei>sys
[Huawei]sys RouterB[RouterB]int g0/0/0
[RouterB-GigabitEthernet0/0/0]ip add 192.168.1.2 24
[RouterB-GigabitEthernet0/0/0]q[RouterB]ospf
[RouterB-ospf-1]area 1
[RouterB-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255
[RouterB-ospf-1-area-0.0.0.1]q
[RouterB-ospf-1]q
配置IS-IS
RouterB
[RouterB]isis
[RouterB-isis-1]
[RouterB-isis-1]is-level level-2
[RouterB-isis-1]network-entity 10.1010.1010.1010.00[RouterB]int g0/0/1
[RouterB-GigabitEthernet0/0/1]ip add 192.168.2.1 24
[RouterB-GigabitEthernet0/0/1]isis enable 1
[RouterB-GigabitEthernet0/0/1]q
RouterC
<Huawei>sys
[Huawei]sys RouterC[RouterC]isis
[RouterC-isis-1]is-level level-2
[RouterC-isis-1]network-entity 10.1010.1010.1011.00
[RouterC-isis-1]q[RouterC]int g0/0/0
[RouterC-GigabitEthernet0/0/0]ip add 192.168.2.3 24
[RouterC-GigabitEthernet0/0/0]isis enable 1
[RouterC-GigabitEthernet0/0/0]q[RouterC]int lo1
[RouterC-LoopBack1]ip add 172.16.1.1 24
[RouterC-LoopBack1]isis enable 1
[RouterC-LoopBack1]q[RouterC-LoopBack1]int lo2
[RouterC-LoopBack2]ip add 172.16.2.1 24
[RouterC-LoopBack2]isis enable 1
[RouterC-LoopBack2]q[RouterC-LoopBack2]int lo3
[RouterC-LoopBack3]ip add 172.16.3.1 24
[RouterC-LoopBack3]isis enable 1
[RouterC-LoopBack3]q
配置OSPF引入IS-IS
RouterB
[RouterB]ospf
[RouterB-ospf-1]import-route isis 1
[RouterB-ospf-1]q
查看RouterA的OSPF路由表
<RouterA>display ospf routing OSPF Process 1 with Router ID 192.168.1.1Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area192.168.1.0/24 1 Transit 192.168.1.1 192.168.1.1 0.0.0.1Routing for ASEsDestination Cost Type Tag NextHop AdvRouter172.16.1.0/24 1 Type2 1 192.168.1.2 192.168.1.2172.16.2.0/24 1 Type2 1 192.168.1.2 192.168.1.2172.16.3.0/24 1 Type2 1 192.168.1.2 192.168.1.2192.168.2.0/24 1 Type2 1 192.168.1.2 192.168.1.2Total Nets: 5 Intra Area: 1 Inter Area: 0 ASE: 4 NSSA: 0
配置过滤列表
配置编号为2002的ACL,允许172.16.2.0/24通过
[RouterB]acl number 2002
[RouterB-acl-basic-2002]rule permit source 172.16.2.0 0.0.0.255
[RouterB-acl-basic-2002]q
配置名为prefix1的地址前缀列表,允许172.16.1.0/24通过
[RouterB]ip ip-prefix prefix1 index 10 permit 172.16.1.0 24
配置Route-Policy(路由策略)
#创建路由策略 ISIS2OSPF 模式为允许 节点编号10
[RouterB]route-policy ospf2isis permit node 10
#定义路由策略的匹配条件 应用 地址前缀列表 prefix1
[RouterB-route-policy]if-match ip-prefix prefix1
[RouterB-route-policy]apply cost 100
[RouterB-route-policy]q#创建路由策略 ISIS2OSPF节点20
[RouterB]route-policy ospf2isis permit node 20
Info: New Sequence of this List.
[RouterB-route-policy]if-match acl 2021
[RouterB-route-policy]apply tag 20
[RouterB-route-policy]q[RouterB]route-policy ospf2isis permit node 30
Info: New Sequence of this List.
[RouterB-route-policy]q
在路由引入时应用Route-Policy
[RouterB]ospf
[RouterB-ospf-1]import-route isis 1 route-policy ospf2isis
[RouterB-ospf-1]q
[RouterB]
验证
查看RouterA路由器的OSPF路由表的变化
可以看到目的地址为172.17.1.0/24的路由的开销为100,目的地址为172.17.2.0/24的路由的标记域(Tag)为20,而其他路由的属性未发生变化。
<RouterA>display ospf routing OSPF Process 1 with Router ID 192.168.1.1Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area192.168.1.0/24 1 Transit 192.168.1.1 192.168.1.1 0.0.0.1Routing for ASEsDestination Cost Type Tag NextHop AdvRouter172.16.1.0/24 100 Type2 1 192.168.1.2 192.168.1.2172.16.2.0/24 1 Type2 20 192.168.1.2 192.168.1.2172.16.3.0/24 1 Type2 1 192.168.1.2 192.168.1.2192.168.2.0/24 1 Type2 1 192.168.1.2 192.168.1.2Total Nets: 5 Intra Area: 1 Inter Area: 0 ASE: 4 NSSA: 0