实验拓扑
如图,把路由器的接口宣告进对应的区域,每个路由器把环回口宣告进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过滤