OSPF六種路由過濾方法


OSPF六種路由過濾方法

 

實驗拓撲

如圖,把路由器的接口宣告進對應的區域,每個路由器把環回口宣告進OSPF進程,如R1的環回口為1.1.1.1/32,以此類推。L1以外部路由引入OSPF。

1、filter import (在ospf進程中配置)

讓R2本身不能學習到路由1.1.1.1,其他路由器可以學習到。也就是說僅在R2上過濾掉1.1.1.1這條路由,不能影響對下游路由器的學習。

所以在R2上配置:

acl basic 2000 rule 0 deny source 1.1.1.1 0 rule 5 permit ospf 1 router-id 2.2.2.2 filter-policy 2000 import 

查看路由表R2的路由表,已經沒有1.1.1.1的路由條目了。

[R2]dis ip routing-table protocol ospf Summary count : 8 OSPF Routing table status : <Active> Summary count : 5 Destination/Mask Proto Pre Cost NextHop Interface 3.3.3.3/32 O_INTRA 10 2 12.1.1.1 GE0/0 24.1.1.4 GE0/1 4.4.4.4/32 O_INTRA 10 1 24.1.1.4 GE0/1 13.1.1.0/24 O_INTRA 10 2 12.1.1.1 GE0/0 34.1.1.0/24 O_INTRA 10 2 24.1.1.4 GE0/1 OSPF Routing table status : <Inactive> Summary count : 3 Destination/Mask Proto Pre Cost NextHop Interface 2.2.2.2/32 O_INTRA 10 0 0.0.0.0 Loop0 12.1.1.0/24 O_INTRA 10 1 0.0.0.0 GE0/0 24.1.1.0/24 O_INTRA 10 1 0.0.0.0 GE0/1 

但是在LSDB中還是存在1.1.1.1的路由信息,因為R2還需要把路由信息泛洪給其他的路由器

[R2]dis ospf lsdb

        OSPF Process 1 with Router ID 2.2.2.2 Link State Database Area: 0.0.0.0 Type LinkState ID AdvRouter Age Len Sequence Metric Router 3.3.3.3 3.3.3.3 1432 60 80000008 0 Router 1.1.1.1 1.1.1.1 1509 60 8000000A 0 Router 4.4.4.4 4.4.4.4 1415 60 80000007 0 Router 2.2.2.2 2.2.2.2 1439 60 80000009 0 Network 34.1.1.3 3.3.3.3 1421 32 80000002 0 Network 12.1.1.1 1.1.1.1 1596 32 80000002 0 Network 24.1.1.2 2.2.2.2 1429 32 80000002 0 Network 13.1.1.1 1.1.1.1 1505 32 80000002 0 

2、filter-policy export (在ospf進程中配置)

讓除了R1以外的路由器都不能學習到192.168.1.1,也就是抑制5類LSA的生成(所以必須在ASBR上配置)

在R1上配置:

acl basic 2000 rule 0 deny source 192.168.1.1 0 rule 5 permit ospf 1 router-id 1.1.1.1 import-route direct filter-policy 2000 export 

此時R2,R3,R4肯定不能學習到192.168.1.0的路由信息了

3、asbr-summary not-advertise (在ospf進程中配置)

這條命令也是抑制5類LSA的生成,在R1上配置。會影響其他路由器

[R1]ospf 1 [R1-ospf-1]asbr-summary 192.168.1.1 24 not-advertise 

4、filter import/export (區域中配置)

這條命令是過濾3類LSA,只能在ABR上使用,不論是自己產生的還是從別的路由器收到的都能過濾。

讓R1不能學習到4.4.4.4

在R2上配置:

acl basic 2000 rule 0 deny source 4.4.4.4 0 rule 5 permit ospf 1 router-id 2.2.2.2 area 0.0.0.0 filter 2000 import 

也可以在R3上在區域1中使用export的方式過濾

acl basic 2000 rule 0 deny source 4.4.4.4 0 rule 5 permit ospf 1 router-id 3.3.3.3 area 0.0.0.1 filter 2000 export 

5、abr-summary not-advertise (區域中配置)

讓R4不能學習到2.2.2.2路由信息。這條命令是過濾3類LSA。需要在ABR上配置。不能對從其它設備收到的三類做過濾。會影響其他路由器

R2配置:

ospf 1 router-id 2.2.2.2 area 0.0.0.0 abr-summary 2.2.2.2 255.255.255.255 not-advertise 

因為2.2.2.2是宣告在區域0里的,所以要在區域0里配置

在R4上查看路由表,已經沒有2.2.2.2的路由信息。

[R4]dis ip routing-table Destinations : 21 Routes : 21 Destination/Mask Proto Pre Cost NextHop Interface 0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0 1.1.1.1/32 O_INTER 10 2 24.1.1.2 GE0/1 3.3.3.3/32 O_INTER 10 3 24.1.1.2 GE0/1 4.4.4.4/32 Direct 0 0 127.0.0.1 InLoop0 12.1.1.0/24 O_INTER 10 2 24.1.1.2 GE0/1 13.1.1.0/24 O_INTER 10 3 24.1.1.2 GE0/1 24.1.1.0/24 Direct 0 0 24.1.1.4 GE0/1 24.1.1.0/32 Direct 0 0 24.1.1.4 GE0/1 24.1.1.4/32 Direct 0 0 127.0.0.1 InLoop0 24.1.1.255/32 Direct 0 0 24.1.1.4 GE0/1 34.1.1.0/24 Direct 0 0 34.1.1.4 GE0/0 34.1.1.0/32 Direct 0 0 34.1.1.4 GE0/0 34.1.1.4/32 Direct 0 0 127.0.0.1 InLoop0 34.1.1.255/32 Direct 0 0 34.1.1.4 GE0/0 127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0 127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0 127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0 127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0 224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0 224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0 255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0 

R1上仍然會有2.2.2.2的路由條目,因為2.2.2.2是通過2類LSA學習到的。

6、ospf database-filter(接口上配置)

可以指定接口不能學習到相應的LSA

[R3-GigabitEthernet0/1]ospf database-filter ? all Filter all types of LSAs except for Grace LSAs 對所有的LSA過濾,除了Grace sLSA ase Filter AS External LSAs 對5類LSA過濾 nssa Filter NSSA External LSAs 對7類LSA過濾 summary Filter Network Summary LSAs 對3類LSA過濾


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM