华为网路设备学习-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-1\]filter-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-1\]filter-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-1\]filter-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#aaabf71a9bbf453b9174c01f4f8e2c90![](https://csdnimg.cn/release/blog_editor_html/release2.3.8/ckeditor/plugins/CsdnLink/icons/icon-default.png)https://735a87f47ad54f3baa6a1afdeb693dd3.shixizhi.huawei.com/course/1820992203597668354/application-learn?courseId=1825413776469086209\&id=701887797485309952\&appId=701887797485309953\&classId=696820005249683456\&courseType=4\&sxz-lang=zh_CN#aaabf71a9bbf453b9174c01f4f8e2c90](https://735a87f47ad54f3baa6a1afdeb693dd3.shixizhi.huawei.com/course/1820992203597668354/application-learn?courseId=1825413776469086209&id=701887797485309952&appId=701887797485309953&classId=696820005249683456&courseType=4&sxz-lang=zh_CN#aaabf71a9bbf453b9174c01f4f8e2c90 "https://735a87f47ad54f3baa6a1afdeb693dd3.shixizhi.huawei.com/course/1820992203597668354/application-learn?courseId=1825413776469086209&id=701887797485309952&appId=701887797485309953&classId=696820005249683456&courseType=4&sxz-lang=zh_CN#aaabf71a9bbf453b9174c01f4f8e2c90")

相关推荐
hello kitty w12 小时前
Python学习(10) ----- Python的继承
开发语言·python·学习
华仔啊12 小时前
别再纠结Pinia和Vuex了!一篇文章彻底搞懂区别与选择
前端·vue.js
徐同保13 小时前
Redux和@reduxjs/toolkit同时在Next.js项目中使用
开发语言·前端·javascript
CandyU213 小时前
C++ 学习 —— 02 - 排序算法
c++·学习·排序算法
扁豆的主人13 小时前
http 状态码
网络·网络协议·http
~无忧花开~13 小时前
CSS学习笔记(二):CSS动画核心属性全解析
开发语言·前端·css·笔记·学习·css3·动画
颜酱13 小时前
了解 pnpm 的优势,然后将已有项目的 yarn 换成 pnpm
前端·javascript·前端工程化
网安INF13 小时前
网络攻防技术:拒绝服务攻击
网络·安全·web安全·网络安全
海在掘金6112713 小时前
从"鬼知道这对象有啥"到"一目了然" - TS接口的实战魔力
前端
spionbo13 小时前
Vue 模拟键盘组件封装方法与使用技巧详解
前端