ospf routing information filtering

ospf routing information filtering

insert image description here
Note:
After ospf is configured, all advertised addresses are reachable to each other if route filtering is not performed.
However, in practical applications, some regional network segments need to restrict access.
For example:
R2 can access 11.11.11.11/32 of R1, but R3 is not allowed to access
R3. When importing direct routes, only loop10, loop11 and loop12
matching tools
are imported 1) acl access Control List (Huawei)

   除了在接口下调用,acl的默认规则是permit any外;
   其它场合下调用,acl的默认规则都是deny any

2) ip-prefix prefix list

   匹配或者筛选更灵活。先匹配前缀,后匹配掩码

Call tool or filter tool
1) filter (filter 3 types of lsa)

   可以在ospf的 area下调用,可以在接口下调用
   可以过滤3类lsa,不能过滤其它类型lsa
   可以在通告区域的出方向过滤
   可以在要接受的区域入方向过滤
   需要配置在abr上
[R2]acl 2000
      rule 10 deny source 11.11.11.11 0
      rule 100 permit source any
      //最底层默认规则是拒绝所有
ip ip-prefix 100 deny 11.11.11.11 32    
ip ip-prefix 100 permit 0.0.0.0 0 less-equal 32 

[R2]ospf 1
	  area 0      //在area 0 的出方向过滤3类lsa
       filter 2000 export  //可以调用acl
       filter ip-prefix 100 export  //也可调用ip-prefix实现
      area 1      //也可以在其它区域(1 or 2)的入方向过滤
       filter 2000 import
      

2) filter-policy (filter 3 types of lsa, 5 types)

在ospf进程下调用
可以调用acl,也可以调用ip-prefix
在abr的入方向上过滤3类,不5类lsa,但是可以阻止其生成去往外部的路由,特点不够灵活,过滤范围大
在asbr的出方向过滤5类lsa
入方向:filter-policy import    
[R2]ospf 1
	  filter 2000 import   //两种方式都可以,但需要在入方向
	  filter-policy ip-prefix 10 import
出方向:filter-policy export//仅配置在asbr
[R3]acl 2000  
	 rule 5 deny source 100.0.1.0 0 
 	 rule 10 permit 

[R3]ospf 1
	  filter-policy 2000 export //asbr上过了5类lsa

3)router-policy

 既可以调用acl 和 ip-prefix 
 也可以被filter 或 filter-policy调用
 可以在调用acl时,修改一些路由参数
用于引入外部路由时的过滤
[R3]acl 2000  
	 rule 5 deny source 100.0.1.0 0 
 	 rule 10 permit 
[R3]route-policy test permit node 10
	 if-match acl 2000 
	 apply cost 200 
[R3]ospf 1
     import-route direct route-policy test 
//abr上过了3类lsa
 [R2]filter route-policy test import //跟上述filter调用acl,ip-prefix差不多,但是此命令是立即生效

//5类lsa此命令无法过滤

Interface filtering method

#模拟器在测试时,R2的0口上配置完后,R1上不会立马出效果
#需要登lsa老化完,3600秒
#R1上 reset ospf process 后立马出效果
#可以调用acl筛选要过滤的lsa,不支持调用ip-prefix
#可以过滤 3 5 7 all 种类的lsa
[R2]inte Gig0/0/0
 	  ip address 10.0.12.2 255.255.255.0 
      ospf filter-lsa-out all //过滤所有类型lsa,包括1,2类型
      ospf filter-lsa-out summary //过滤3类
      ospf filter-lsa-out ase     //过滤5类
      ospf filter-lsa-out nssa    //过滤7类
      ospf filter-lsa-out summary ase nssa //过滤3 5 7类lsa
      ospf filter-lsa-out summary ase acl 2010//调用筛选工具过滤
  注意:接口下只能配置一条 filter-lsa-out ...      

Guess you like

Origin blog.csdn.net/qq_42906357/article/details/124769402