OSPF - route filtering
OSPF can have route filtering applied, however, it is impossible to filter routes advertised between routers in the same area. This means we have to configure filtering on an ABR or ASBR. ABRs can filter Type 3 and Type 4 LSAs, while ASBRs can filter Type 5 and Type 7 LSAs.
When talking about filtering in OSPF, it is more appropriate to speak about LSA filtering rather than route filtering. This is because it is the the advertising of the LSAs that match particular network destinations that are being filtered.
Filtering can be achieved using:
filter-listcommand under the OSPF configuration mode
distribute-listcommand under the OSPF configuration mode
The reason for filtering taking place only at ABRs or ASBRs is that as a link-state protocol, every router within the same area must by definition have an identical link-state database (LSDB) for shortest path first (SPF) calculations. If you filter LSAs within an area, it would break this uniformity.
Similarly route summarization can only take place between areas.
If you need to apply some sort of route filtering within an area, this can be achieved not by filtering LSAs between OSPF routers, but by filtering the installation of routes within the routing table. This can be done using distribute-list filtering.