OSPF <wbr>- <wbr>阻止从OSPF学到的路由被放置在路由表

R1#sh ip route

   1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Serial0/0
     2.0.0.0/24 is subnetted, 1 subnets
O IA    2.2.2.0 [110/192] via 1.1.1.2, 00:01:15, Serial0/0
     3.0.0.0/32 is subnetted, 1 subnets
O IA    3.3.3.3 [110/129] via 1.1.1.2, 00:09:15, Serial0/0
     4.0.0.0/24 is subnetted, 1 subnets
O IA    4.4.4.0 [110/192] via 1.1.1.2, 00:04:43, Serial0/0
     172.16.0.0/24 is subnetted, 1 subnets
O IA    172.16.1.0 [110/128] via 1.1.1.2, 00:09:15, Serial0/0

======================================

R1:

router ospf 1
 distribute-list 1 in
!
access-list 1 deny   2.2.2.0 0.0.0.255
access-list 1 deny   3.3.3.0 0.0.0.255
access-list 1 permit any

======================================

R1#sh ip route

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Serial0/0
     4.0.0.0/24 is subnetted, 1 subnets
O IA    4.4.4.0 [110/192] via 1.1.1.2, 00:00:28, Serial0/0
     172.16.0.0/24 is subnetted, 1 subnets
O IA    172.16.1.0 [110/128] via 1.1.1.2, 00:00:28, Serial0/0

R1#sh ip ospf database   (已阻止2.2.2.2与3.3.3.3进入路由,但仍在数据库中找到)

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Router Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum Link count
1.1.1.1         1.1.1.1         678         0x80000003 0x00A8E2 2
2.2.2.2         2.2.2.2         1392        0x80000002 0x004D39 2

                Summary Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum
2.2.2.0       2.2.2.2       204       0x80000001 0x000AA4
3.3.3.3       2.2.2.2       1333      0x80000001 0x004F98
4.4.4.0         2.2.2.2         412         0x80000001 0x00C1E6
172.16.1.0      2.2.2.2         1388        0x80000001 0x003FF7

 

另一种配置

===================================

R1:

router ospf 1
 distribute-list filter-ospf in
!
ip access-list standard filter-ospf
 deny   2.2.2.0 0.0.0.255
 deny   3.3.3.0 0.0.0.255
 permit any