华为网路设备学习-21 IGP路由专题-路由过滤(filter-policy)

一、路由过滤(filter-policy)

1、用于控制路由更新、接收的一个工具

2、只能过滤路由信息,无法过滤LSA

二、路由过滤(filter-policy)与动态路由协议

1、距离矢量路由协议

RIP动态路由协议 交换的是路由表,即该路由器中存储的路由表信息

2、链路状态协议

OSPF动态路由协议 交换的是LSA(链路状态通告),即该路由器获知的链路状态信息。在各个路由器互相传递LSA(链路状态通告)后,会各自形成LSDB(链路状态数据库)。最后根据LSDB(链路状态数据库)运行SPF(最短路径优先)的算法,来规划路由表。

3、二者区别

链路状态协议比距离矢量路由协议复杂得多,但基本功能和配置却很简单,算法易理解。

注:‌filter-policy‌:在链路状态协议中仅局部生效(如OSPF的import方向),不影响LSA泛洪。即仅能影响路由器的LSDB加表过程,但不会过滤LSA信息。

三、实验1

复制代码
[Huawei]sysname R1	
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.12.1 24
[R1-GigabitEthernet0/0/0]q
 
[R1]rip	
[R1-rip-1]ver 2
[R1-rip-1]undo summary 
[R1-rip-1]network 192.168.12.0	
[R1-rip-1]network 192.168.1.0
[R1-rip-1]network 192.168.2.0
[R1-rip-1]network 192.168.3.0
[R1-rip-1]q

[R1]int LoopBack 1
[R1-LoopBack1]ip address 192.168.1.1 24
[R1-LoopBack1]q
[R1]int LoopBack 2
[R1-LoopBack2]ip address 192.168.2.1 24
[R1-LoopBack2]q
[R1]int LoopBack 3
[R1-LoopBack3]ip address 192.168.3.1 24

[Huawei]sysname R2
[R2]interface g0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.12.2 24
[R2-GigabitEthernet0/0/0]q
[R2]interface g0/0/1	
[R2-GigabitEthernet0/0/1]ip address 192.168.23.2 24
[R2-GigabitEthernet0/0/1]q
	
[R2]rip
[R2-rip-1]ver 2
[R2-rip-1]undo summary 
[R2-rip-1]network 192.168.12.0
[R2-rip-1]network 192.168.23.0
 
[Huawei]sysname R3	
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip address 192.168.23.3 24
[R3-GigabitEthernet0/0/1]q
 

[R3]rip
[R3-rip-1]ver 2
[R3-rip-1]undo summary 
[R3-rip-1]network 192.168.23.0

检查发现R2有三条rip路由,R3有四条rip路由。

此时要求在R3上过滤掉192.168.3.0/24

复制代码
[R2]ip ip-prefix T1 deny 192.168.3.0 24	
[R2]ip ip-prefix T1 permit 0.0.0.0 0 less-equal 32
[R2]rip
[R2-rip-1]filter-policy ip-prefix T1 export GigabitEthernet 0/0/1

###############在R2的 G0/0/1口 的 出方向上 添加路由过滤

###############路由过滤使用 IP前缀列表 T1 进行匹配

检查如下

四、注意:以下是其他可选项的参考

###############filter-policy 可以选择 acl或者IP前缀列表 进行匹配###############

R2-rip-1filter-policy ?

INTEGER<2000-2999> Apply basic ACL

acl-name Specify IP Access Control List (ACL) name for filtering routes

gateway Filter routes based on the distributing gateway

ip-prefix Specify IP prefix for filtering routes

###############filter-policy 可以选择 作用于 出方向 或者 入方向###############

R2-rip-1filter-policy ip-prefix T1 ?

export Specify an export policy

gateway Filter routes based on the distributing gateway

import Specify an import policy

############### filter-policy 可以选择作用与指定的接口 或者 指定的路由类型 #############

R2-rip-1filter-policy ip-prefix T1 export ?

Cellular Cellular interface

GigabitEthernet GigabitEthernet interface

bgp Border Gateway Protocol (BGP) routes

direct Direct routes

isis Intermediate System to Intermediate System (ISIS) routes

ospf Open Shortest Path First (OSPF) routes

rip Routing Information Protocol (RIP) routes

static Static routes

unr User Network Route

实验2

五、问:filter-policy和route-policy的区别?

答:filter-policy仅能过滤路由,而route-policy既能过滤路由又能修改路由属性。

总的来说: 两者核心区别在于功能灵活性------‌filter-policy是单一过滤工具,而route-policy是综合策略工具‌。前者配置简单方便,后者能实现更复杂的路由操控。

参考:https://735a87f47ad54f3baa6a1afdeb693dd3.shixizhi.huawei.com/course/1820992203597668354/application-learn?courseId=1825413776469086209&id=701887797485309952&appId=701887797485309953&classId=696820005249683456&courseType=4&sxz-lang=zh_CN#aaabf71a9bbf453b9174c01f4f8e2c90https://735a87f47ad54f3baa6a1afdeb693dd3.shixizhi.huawei.com/course/1820992203597668354/application-learn?courseId=1825413776469086209&id=701887797485309952&appId=701887797485309953&classId=696820005249683456&courseType=4&sxz-lang=zh_CN#aaabf71a9bbf453b9174c01f4f8e2c90

相关推荐
勇往直前plus11 分钟前
Python 属性访问与操作全解析:内置函数、魔法方法与描述符深度指南
java·网络·python
古月开发17 分钟前
旧手机变身 AI 作业监督器:低成本家庭学习解决方案
人工智能·学习·智能手机
Arenaschi17 分钟前
关于GPT的版特点
java·网络·人工智能·windows·python·gpt
柚子科技22 分钟前
Vue3 响应式原理:我被 ref 和 reactive 坑了3次后终于搞懂了
前端·javascript·vue.js
MAXrxc25 分钟前
ospf笔记
网络·笔记
薛定猫AI26 分钟前
【深度解析】Hermes Agent Velocity Release:长期记忆、自进化技能与多智能体任务编排实践
网络·人工智能
大鱼前端29 分钟前
Veaury:让Vue和React组件在同一应用中共存的神器
前端·vue.js·react.js
Leweslyh30 分钟前
基于 Confucius 架构的无人集群网络控制原语解析
开发语言·网络·php
scan72435 分钟前
大模型只是知道要调用工具,本身不
前端·javascript·html
古月方枘Fry35 分钟前
OSPF 企业级多区域网络
运维·服务器·网络