一、路由過濾(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#aaabf71a9bbf453b9174c01f4f8e2c90https://735a87f47ad54f3baa6a1afdeb693dd3.shixizhi.huawei.com/course/1820992203597668354/application-learn?courseId=1825413776469086209&id=701887797485309952&appId=701887797485309953&classId=696820005249683456&courseType=4&sxz-lang=zh_CN#aaabf71a9bbf453b9174c01f4f8e2c90