How to filter routes that are advertised via OSPF?

There are several networks, that are connected via L2TP/SSTP/IPIP/etc. OSPF configured. ROS 7.3.1 Everything is fine. Some routers redistribute their static routes.

Question: how can I set up filtering of these advertised routes on some routers?

For example: there is a router R1 that redistributes routes to addresses 1.1.1.1, 2.2.2.2, 3.3.3.3. And there is a router R2 that does not need such routes through R1 to 1.1.1.1 and 2.2.2.2.

On R2 tried to filter:

/routing filter rule add chain=ospf-in comment="Test block" disabled=no rule="if ( protocol ospf && dst in 1.1.1.1 ) { reject }"

But such a filter generally breaks the entire OSPF on this router.

I’m curious.. How does it “break” ospf? Does adjacency drop? Or just all OSPF routes disappear?

Special for you. :smiley:
After.png
Before.png

Filter default action is ‘reject’.
rule=“if ( protocol ospf && dst in 1.1.1.1 ) { reject } else { accept }

It’s really simple… Thank you.