路由控制

路由控制

Falcon

2025-06-29 发布93 浏览 · 0 点赞 · 0 收藏

1.重分布

从A协议得到的网络信息,注入到B协议中

IGP 属于该协议的网络(直连和从A学来的路由)发布给B协议

image

第一步:部署两侧网络

R1:

int g0/0/0

ip add 12.1.1.1 24

int lo0

ip ad 192.168.10.10 24

quit

rip

version 2

net 192.168.10.0

net 12.0.0.0

R2:

int g0/0/0

ip ad 12.1.1.2 24

quit

rip

version 2

net 12.0.0.0

isis

net 49.0001.0000.0000.0001.00

is-level level-2

int g0/0/1

ip ad 23.1.1.2 24

isis en

R3:

isis

net 49.0001.0000.0000.0003.00

is-level level-2

int g0/0/0

ip ad 23.1.1.3 24

isis en

int lo0

ip ad 192.168.30.30 24

isis en

第二步:R2双向重分布

R2:

rip

import-route isis 1

isis

import-route rip 1

查看路由信息,测试两边通讯

第三步:接入OSPF网络

R2:

ospf router-id 2.2.2.2

area 0

int g0/0/2

ip ad 24.1.1.2 24

ospf en 1 a 0

R4:

ospf router-id 4.4.4.4

area 0

int g0/0/0

ip ad 24.1.1.4 24

ospf en 1 a 0

int lo0

ip add 192.168.40.40 24

ospf en 1 a 0

ospf net bro

第四步:R2如图增加重分发

image

R2:

rip

import-route ospf 1

ospf

import-route isis 1

R2:将从OSPF得到的路径给RIP

14、40

R2:将从RIP得到的路径给ISIS

12、10

R3得到12、10,没有40的回包路由

此时不能全网全通

如果想要实现全网全通??????

2.双点双向重分布

image

R1:

int g0/0/0

ip ad 12.1.1.1 24

quit

rip

version 2

net 12.0.0.0

isis

net 49.0001.0000.0000.0001.00

is-level level-2

int g0/0/1

ip ad 14.1.1.1 24

isis en

R2:

int g0/0/0

ip ad 12.1.1.2 24

int g0/0/1

ip ad 23.1.1.2 24

int lo0

ip ad 192.168.20.20 24

quit

rip

version 2

net 12.0.0.0

net 23.0.0.0

net 192.168.20.0

R3:

int g0/0/0

ip ad 23.1.1.3 24

quit

rip

version 2

net 23.0.0.0

isis

net 49.0001.0000.0000.0003.00

is-level level-2

int g0/0/1

ip ad 34.1.1.3 24

isis en

R4:

isis

net 49.0001.0000.0000.0004.00

is-level level-2

int g0/0/0

ip ad 34.1.1.4 24

isis en

int g0/0/1

ip ad 14.1.1.4 24

isis en

int lo0

ip ad 192.168.40.40 24

isis en

测试 rip内、isis内 ,是否可实现全区内通讯

image

image

第一步:R1先ISIS引入RIP

R1:

rip

import-route isis 1

image

第二步:R1然后将RIP引入ISIS

R1:

isis

import-route rip 1

image

总结:

image

image

第三步:R3上ISIS引入进RIP

R3:

rip

import-route isis 1

image

image

第四步:R3上RIP引入进ISIS

R3:

isis

import-route rip 1

image

image

思考: 判断--- 从RIP引入进isis,将优先级为100的路由变为了15

答案:错

解析:发布路由信息,不携带优先级

协议优先级,本地的概念


解决方案:

造成问题的原因: 优先级

第一步:修改优先级 ,避免次优问题

R1、R3:

RIP中的网络就从RIP转发,ISIS的网络就从ISIS转发

image

*route-policy 路由策略

影响的是路由表中的信息,

路由条目是否可以存在--过滤

路由的参数,cost、precedence、nh等


前提 ISIS cost-style wide 支持TAG

①ISIS 路由器cost-style修改成wide

R1、R4、R3:

isis

cost-style wide

②R3:RIP引入进ISIS ,调用工具,工具作用TAG 100

route-policy R2I permit node 10--设置策略 R2I

apply tag 100-------------------------执行:标记TAG 100

isis

import-route rip 1 route-policy R2I

③R1:将有TAG100的路由,优先级改为110

设置工具,实现上述需求

在isis协议中调用

route-policy Pre permit node 10-策略名称 Pre ,执行序列号10

if-match tag 100--------------------筛选条件:命中tag 100的路由

apply preference 110---------------设置参数:将优先级改为110

isis

preference route-policy Pre--修改isis的优先级,根据策略Pre 修改


反之。R1引入RIP进isis 也要TAG 100,在R3将有TAG100的路由优先级改为110

R1:

route-policy R2I permit node 10 --设置策略 R2I

apply tag 100 --执行:标记TAG 100

isis

import-route rip 1 route-policy R2I

R3:

route-policy Pre permit node 10 -策略名称 Pre ,执行序列号10

if-match tag 100 --------------------筛选条件:命中tag 100的路由

apply preference 110 ---------------设置参数:将优先级改为110

isis

preference route-policy Pre --修改isis的优先级,根据策略Pre 修改


备注:RIP收敛太慢了,网工手工加快RIP收敛,先断开isis的网络,等RIP收敛好之后,在接入ISIS

R1、R3:

int g0/0/1

sh

R1\R3 查看 display ip rou pro rip ---保障rip的网络信息都学全了

然后接入ISIS

int g0/0/1

undo sh

现象查看:R1、R3: display ip rou pro isis ------ inactive / active

Tracert测试,看是否是最优路径

R2、R4 相互访问,是否负载分担? 路由表两个下一跳,tracert -q 10

第二步:解决未来可能出现的环路问题

次优->环

原因:rip网络失效,但是ISIS收敛不及时,造成R1误认为仍可以通过ISIS得到路由,引入RIP,RIP传递给R3,R3稳定引入ISIS,R1误认为稳定从ISIS得到路径,造成环路问题。

image

解决方案:防止路由的回灌

image

R1、R3:

route-policy R2I deny node 5

if-match tag 200

route-policy R2I permit node 10

apply tag 100

isis

import-route rip 1 route-policy R2I

route-policy I2R deny node 5

if-match tag 100

route-policy I2R permit node 10

apply tag 200

rip

import-route isis 1 route-policy I2R

3.ACL & ip-prefix

3.1 ACL

访问控制列表

匹配的方式:

IP + 统配符

特点:

① 灵活,通配符匹配ip位 ,匹配可以不连续

② 不够精确 ,匹配路由仅能匹配网络号

功能:

①筛选流量

调用接口下

标准、扩展ACL

②筛选路由

调用协议中

标准ACL

3.2 IP-Prefix

前缀列表

匹配的方式:

ip+ 前缀长度 + 掩码范围(greater-equal ≥ ,less-equal ≤)

特点:

①精确匹配

②不够灵活,匹配连续的网络

功能:

①筛选路由

调用协议中

3.3 实验

image

R1:

int lo0

ip ad 10.1.1.1 8

ip ad 11.1.1.1 24 sub

ip ad 172.10.1.1 16 sub

ip ad 172.11.1.1 24 sub

ip ad 192.168.10.1 24 sub

ip ad 192.168.11.1 28 sub

quit

rip

net 10.0.0.0

net 11.0.0.0

net 172.10.0.0

net 172.11.0.0

net 192.168.10.0

net 192.168.11.0

查看rip的网络是否都学习到


ABC类的筛选:

A类:标8bit

0 xxx xxxx. X.X.X 范围1-126

B类:标16bit

10 xx xxxx. X.X.X 范围128-191

C类:标24bit

110 x xxxx. X.X.X 范围192-223


使用ACL筛选路由,R2上依次过滤看现象

第一步:R2过滤

rip 1

filter-policy 2000 import --学习路由根据ACL 2000 过滤

现象:调用空列表,无效

第二步:R2依次ACL 2000

①筛选A类

acl 2000 rule permit source 0.0.0.0 127.255.255.255

②筛选B类

acl 2000 rule permit source 128.0.0.0 63.255.255.255

②筛选C类

acl 2000 rule permit source 192.0.0.0 31.255.255.255

依次查看R2、R3的路由表现象


IP-Prefix 在R2的出向过滤:

第一步:R2

rip 1

filter-policy ip-prefix ABC export

现象:

调用空列表,不生效

第二步:依次过滤

掩码的筛选:

第一种 ,如果不规定下限,下限= 前缀长度

           特殊,如果前缀匹配的是0,后续掩码必须精确,否则不生效

①筛选A类

ip ip-prefix ABC permit 0.0.0.0 1 less-equal 32 ---掩码范围 1-32

②筛选标准A类

ip ip-prefix ABC permit 0.0.0.0 1 greater-equal 8 less-equal 8 ---掩码范围 =8

[R2]undo
ip ip-prefix ABC index 10

③筛选B类

ip ip-prefix ABC permit 128.0.0.0 2 less-equal 32 ---掩码范围 1-32

标准B类

ip ip-prefix ABC permit 128.0.0.0 2 greater-equal 16 less-equal 16 ---掩码范围 16

③筛选标准C类

ip ip-prefix ABC permit 192.0.0.0 3 greater-equal 24 less-equal 24 ---掩码范围 24

筛选非标C类

ip ip-prefix ABC permit 192.0.0.0 3 less-equal 32 ---掩码范围 1-32

第三步:R3上入向过滤

第二种,如果不规定掩码长度,掩码= 前缀长度

         即,匹配的一条路由

[R3]ip ip-prefix ABC permit 192.168.10.0 24

[R3]rip

[R3-rip-1]filter-policy ip-prefix ABC import

[R3-rip-1]q

第四步:R3上入向过滤

第三种,匹配的是所有

R1下发默认

rip 1

default-route originate

R2、R3:

ip ip-prefix ABC permit 0.0.0.0 0 ----- 筛选 0.0.0.0/0 默认路由

现象:R3上看路由

R3:放行所有

ip ip-prefix ABC permit 0.0.0.0 0 le 32

现象:R3上看路由

  1. PBR policy-based routing 策略路由

策略路由 PBR :路由--用于指导数据转发路径,根据流量策略指导数据转发

路由策略 route-policy:修改路由的参数


image

单播路由:只关心去哪

image

根据PBR、分类:数据从哪来,去哪,干什么-----高级ACL/标准ACL 匹配数据

4.1 经过本设备的流量

可以使用PBR(ensp不支持)、可以使用MQC(模块化QOS命令行)模型

分类模块、行为模块 ==> 流量策略

实验需求:1-》5 走R3 ,11-》5 走R4

配置:

R2:

分类模块

acl 3000

rule permit ip source 1.1.1.0 0.0.0.255 destination 5.5.5.5 0

traffic classifier bangong --定义一类流量,命名为办公

if-match acl 3000 --筛选条件:命中ACL 3000

acl 3001

rule permit ip source 11.1.1.0 0.0.0.255 destination 5.5.5.5 0

traffic classifier shengchan

if-match acl 3001

行为模块

traffic behavior toR3 ---定义一种行为,命名为toR3

redirect ip-nexthop 23.1.1.3 --重定向数据转发给23.1.1.3

traffic behavior toR4

redirect ip-nexthop 24.1.1.4

组装流量策略

traffic policy PBR ---组装策略,命名为PBR :什么流量如何操作

classifier bangong behavior toR3

classifier shengchan behavior toR4

调用在流量的入接口

int g0/0/0

traffic-policy PBR inbound

image

结论:

数据策略优先于路由,挡在查看路由表之前,流量在上行LPU上执行(入向接口调用)

4.2 PBR 影响本地触发的流量

①acl 筛选流量

②policy-based-route

if-match ACL

apply ip-address next-hop
XX

③调用在全局(本地)

需求:R2增加两个网络,同上

R2:

int lo0

ip add 2.2.2.2 32

ip add 22.2.2.2 32 sub

ospf en 1 a 0

acl 2000

rule permit source 2.2.2.2 0

acl 2001

rule permit source 22.2.2.2 0

policy-based-route R2PBR permit node 10

if-match acl 2000

apply ip-address next-hop 23.1.1.3

policy-based-route R2PBR permit node 20

if-match acl 2001

apply ip-address next-hop 24.1.1.4

ip local policy-based-route R2PBR

image

额外要求:22.2.2.2-》5.5.5.5 , 优先路由,没有路由 走policy

policy-based-route R2PBR permit node 20

if-match acl 2001

apply ip-address default next-hop 24.1.1.4

image

测试:光有策略,可以指导数据转发

R2上针对本地过滤路由5.5.5.5/32

filter-policy、import

Ip ip-prefix R2 deny 5.5.5.5 32

Ip ip-prefix R2 permit 0.0.0.0 0 le 32

Ospf

filter-policy ip-prefix R2 import

验证①查看路由表中是否过滤成功 ② 找测试站点,tracert测试

请前往 登录/注册 即可发表您的看法…