Page 1 of 1

Problem with understanding ospf-out filter

Posted: Thu Dec 05, 2013 4:53 pm
by Balu75
Hello All !

I need some help with understanding filtering rules in ospf-out chain.
For example, I have OSPF enabled board, with many /32 and /30 connected and static routes, that are in the same prefix, for example in 192.168.0.0/16, and some routes in other prefixes. I want to redistribute only those prefixes that are in prefix 192.168.0.0/16, so I build ospf-out filter:
0 chain=ospf-out prefix=192.168.0.0/16 prefix-length=16 invert-match=no
action=accept set-bgp-prepend-path=""

Nothing happens, board redistributes all connected/static routes in all prefixes.
Ok, I slightly change it, trying to deny everything else except of 0 rule:
0 chain=ospf-out prefix=192.168.0.0/16 prefix-length=16 invert-match=no
action=accept set-bgp-prepend-path=""

1 chain=ospf-out invert-match=no action=reject set-bgp-prepend-path=""

And now board totally stops to redistribute all external prefixes.
I tried to change first rule making prefix= without masklen, or with empty prefix-length=, but nothing happens, when I insert 1 rule with rejecting everything else I totally lost redistributing of external prefixes.
Reading WiKi about Routing filters doesn't help, I'm stuck.
Please give me a glue, how can I match all more specific routes within the same subnet, and deny everything else in ospf-out filter ?

Re: Problem with understanding ospf-out filter

Posted: Thu Dec 05, 2013 5:11 pm
by mrz
You need to specify correct prefix length or range of prefix lengths

prefix=192.168.0.0/16 prefix-length=16 means that you will match only 192.168.0.0/16


To match prefixes inside this /16 use

prefix=192.168.0.0/16 prefix-length=17-32

Re: Problem with understanding ospf-out filter

Posted: Thu Dec 05, 2013 5:22 pm
by Balu75
Yes, this prefix-length range helps ! Big thanks to you, mrz!
I think that WiKi must be extended with example like this.

Re: Problem with understanding ospf-out filter

Posted: Wed Mar 25, 2020 4:34 pm
by lucim100
You need to specify correct prefix length or range of prefix lengths

prefix=192.168.0.0/16 prefix-length=16 means that you will match only 192.168.0.0/16


To match prefixes inside this /16 use

prefix=192.168.0.0/16 prefix-length=17-32

Thank you , this solved my issue filtering out PPTP /32 ips over OSPF