策略路由:在路由引入时应用路由策略示例

学习精彩网络技术老师:华为、华三、锐捷、WLAN、IPv6等全套视频课程

应用路由策略可以严格控制路由的引入,同时可设置引入路由的属性。

组网需求

图1所示,DeviceB与DeviceA之间通过OSPF协议交换路由信息,与DeviceC之间通过IS-IS协议交换路由信息。

要求在DeviceB上配置路由引入,将IS-IS路由引入到OSPF中去,并同时使用路由策略设置路由的属性。其中,设置172.16.1.0/24的路由的开销为100,设置172.16.2.0/24的路由的Tag属性为20。

图1 配置在路由引入时应用路由策略组网图

本例中interface1,interface2,interface3,interface4分别代表GE0/1/0,GE0/2/0,GE0/3/0,GE0/1/1。

配置注意事项

在配置过程中,需注意以下事项:

配置地址前缀列表时,需根据实际需求准确地指定地址前缀范围。

引用路由策略时,需注意区分策略名称的大小写。

配置思路

采用如下的思路配置在路由引入时应用路由策略:

在DeviceB和DeviceC上配置IS-IS基本功能。

在DeviceA和DeviceB上配置OSPF,引入IS-IS路由。

在DeviceB上配置路由策略,并在OSPF引入IS-IS路由时应用路由策略,查看路由信息。

数据准备

为完成此配置例,需准备如下数据:

DeviceB和DeviceC所在的区域号、IS-IS级别及system ID。

DeviceA和DeviceB位于OSPF骨干区域(Area0)。

配置ACL编号,地址前缀列表名称,172.16.1.0/24路由的开销值,172.16.2.0/24路由的Tag属性值。

操作步骤
  1. 配置各接口的IP地址(略)
  2. 配置IS-IS路由协议

# 配置DeviceC。

[~DeviceC] isis

[*DeviceC-isis-1] is-level level-2

[*DeviceC-isis-1] network-entity 10.0000.0000.0001.00

[*DeviceC-isis-1] quit

[*DeviceC] interface gigabitethernet 0/1/1

[*DeviceC-GigabitEthernet0/1/1] isis enable

[*DeviceC-GigabitEthernet0/1/1] quit

[*DeviceC] interface GigabitEthernet 0/1/0

[*DeviceC-GigabitEthernet0/1/0] isis enable

[*DeviceC-GigabitEthernet0/1/0] quit

[*DeviceC] interface GigabitEthernet 0/2/0

[*DeviceC-GigabitEthernet0/2/0] isis enable

[*DeviceC-GigabitEthernet0/2/0] quit

[*DeviceC] interface GigabitEthernet 0/3/0

[*DeviceC-GigabitEthernet0/3/0] isis enable

[*DeviceC-GigabitEthernet0/3/0] commit

[~DeviceC-GigabitEthernet0/3/0] quit

# 配置DeviceB。

[~DeviceB] isis

[*DeviceB-isis-1] is-level level-2

[*DeviceB-isis-1] network-entity 10.0000.0000.0002.00

[*DeviceB-isis-1] quit

[*DeviceB] interface gigabitethernet 0/2/0

[*DeviceB-GigabitEthernet0/2/0] isis enable

[*DeviceB-GigabitEthernet0/2/0] commit

[~DeviceB-GigabitEthernet0/2/0] quit

  1. 配置OSPF路由协议及路由引入

# 配置DeviceA,启动OSPF。

[~DeviceA] ospf

[*DeviceA-ospf-1] area 0

[*DeviceA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255

[*DeviceA-ospf-1-area-0.0.0.0] commit

[~DeviceA-ospf-1-area-0.0.0.0] quit

[~DeviceA-ospf-1] quit

# 配置DeviceB,启动OSPF,并引入IS-IS路由。

[~DeviceB] ospf

[*DeviceB-ospf-1] area 0

[*DeviceB-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255

[*DeviceB-ospf-1-area-0.0.0.0] quit

[*DeviceB-ospf-1] import-route isis 1

[*DeviceB-ospf-1] commit

[~DeviceB-ospf-1] quit

# 查看DeviceA的OSPF路由表,可以看到引入的路由。

[~DeviceA] display ospf routing

          OSPF Process 1 with Router ID 192.168.1.1

                   Routing Tables

 Routing for Network

 Destination        Cost  Type       NextHop         AdvRouter       Area

 192.168.1.0/24     1  Stub       192.168.1.1     192.168.1.1     0.0.0.0

 Routing for ASEs

 Destination        Cost      Type       Tag         NextHop         AdvRouter

 172.16.1.0/24      1        Type2      1           192.168.1.2     192.168.1.2

 172.16.2.0/24      1        Type2      1           192.168.1.2     192.168.1.2

 172.16.3.0/24      1        Type2      1           192.168.1.2     192.168.1.2

 192.168.2.0/24     1        Type2      1           192.168.1.2     192.168.1.2

 Routing for NSSAs

 Destination        Cost      Type       Tag         NextHop         AdvRouter

 Total Nets: 5

 Intra Area: 1  Inter Area: 0  ASE: 4  NSSA: 0

  1. 配置过滤列表

# 配置编号为2002的ACL,允许172.16.2.0/24通过。

[~DeviceB] acl number 2002

[*DeviceB-acl4-basic-2002] rule permit source 172.16.2.0 0.0.0.255

[*DeviceB-acl4-basic-2002] commit

[*DeviceB-acl4-basic-2002] quit

# 配置名为prefix-a的地址前缀列表,允许172.16.1.0/24通过。

[*DeviceB] ip ip-prefix prefix-a index 10 permit 172.16.1.0 24

[*DeviceB] commit

  1. 配置Route-Policy

[~DeviceB] route-policy isis2ospf permit node 10

[*DeviceB-route-policy] if-match ip-prefix prefix-a

[*DeviceB-route-policy] apply cost 100

[*DeviceB-route-policy] quit

[*DeviceB] route-policy isis2ospf permit node 20

[*DeviceB-route-policy] if-match acl 2002

[*DeviceB-route-policy] apply tag 20

[*DeviceB-route-policy] quit

[*DeviceB] route-policy isis2ospf permit node 30

[*DeviceB] commit

[~DeviceB-route-policy] quit

  1. 在路由引入时应用Route-Policy

# 配置DeviceB,设置在路由引入时应用Route-Policy。

[~DeviceB] ospf

[*DeviceB-ospf-1] import-route isis 1 route-policy isis2ospf

[*DeviceB-ospf-1] commit

[~DeviceB-ospf-1] quit

# 查看DeviceA的OSPF路由表,可以看到目的地址为172.16.1.0/24的路由的开销为100,目的地址为172.16.2.0/24的路由的标记域(Tag)为20,而其他路由的属性未发生变化。

[~DeviceA] display ospf routing

          OSPF Process 1 with Router ID 192.168.1.1

                   Routing Tables

 Routing for Network

 Destination        Cost  Type       NextHop         AdvRouter       Area

 192.168.1.0/24     1  Stub       192.168.1.1     192.168.1.1     0.0.0.0

 Routing for ASEs

 Destination        Cost      Type       Tag         NextHop         AdvRouter

 172.16.1.0/24      100       Type2      1           192.168.1.2     192.168.1.2

 172.16.2.0/24      1          Type2      20          192.168.1.2     192.168.1.2

 172.16.3.0/24      1          Type2      1           192.168.1.2     192.168.1.2

 192.168.2.0/24     1          Type2      1           192.168.1.2     192.168.1.2

 Routing for NSSAs

 Destination        Cost      Type       Tag         NextHop         AdvRouter

 Total Nets: 5

 Intra Area: 1  Inter Area: 0  ASE: 4  NSSA: 0

配置文件

DeviceA的配置文件

#

 sysname DeviceA

#

interface GigabitEthernet0/1/0

 undo shutdown

 ip address 192.168.1.1 255.255.255.0

#

ospf 1

 area 0.0.0.0

  network 192.168.1.0 0.0.0.255

#

return

DeviceB的配置文件

#

sysname DeviceB

#

acl number 2002

 rule 5 permit source 172.16.2.0 0.0.0.255

#

isis 1

 is-level level-2

 network-entity 10.0000.0000.0002.00

#

interface GigabitEthernet0/1/0

 undo shutdown

 ip address 192.168.1.2 255.255.255.0

#

interface GigabitEthernet0/2/0

 undo shutdown

 ip address 192.168.2.2 255.255.255.0

 isis enable 1

#

ospf 1

 import-route isis 1 route-policy isis2ospf

 area 0.0.0.0

  network 192.168.1.0 0.0.0.255

#

route-policy isis2ospf permit node 10

 if-match ip-prefix prefix-a

 apply cost 100

#

route-policy isis2ospf permit node 20

 if-match acl 2002

 apply tag 20

#

route-policy isis2ospf permit node 30

#

ip ip-prefix prefix-a index 10 permit 172.16.1.0 24

#

return

DeviceC的配置文件

#

sysname DeviceC

#

isis 1

 is-level level-2

 network-entity 10.0000.0000.0001.00

#

interface GigabitEthernet0/1/0

 undo shutdown

 ip address 172.16.1.1 255.255.255.0

 isis enable 1

#

interface GigabitEthernet0/2/0

 undo shutdown

 ip address 172.16.2.1 255.255.255.0

 isis enable 1

#

interface GigabitEthernet0/3/0

 undo shutdown

 ip address 172.16.3.1 255.255.255.0

 isis enable 1

#

interface GigabitEthernet0/1/1

 undo shutdown

 ip address 192.168.2.1 255.255.255.0

 isis enable 1

#

return

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

精彩网络技术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值