Filter OSPF to kernel routes
Hello, I'm distributing my default route via OSPFv3 from my edge router. For testing purposes I would like to ignore that default route on one of my routers. Said router gets a default route via IPv6 router advertisements but the OSPF route is preferred. So I tried: filter default-reject { if ::/0 ~ net then reject; } [...] protocol ospf v3 ospfv3 { ipv6 { import filter default-reject; [...] and protocol kernel kernel6 { ipv6 { export filter default-reject; }; [...] The filter seems to be correct, "show route filter ..." works in birdc. But I still have the OSPF default route. So it seems I misunderstand filters in BIRD completely. Can anybody point me in the right direction? Thanks in advance, Marcus Büttemeyer
OK, the problem seems to have been the name of the filter. BIRD says "syntax error, unexpected DEFAULT" so I renamed the filter to "reject_default" and that works. What did BIRD not like about "default-reject"? Also, I have said filter configured as import and export filters in both ospfv3 and kernel6 but the router in question still announces the default route via OSPFv3. Can anybody tell me what filter I have to use in which direction on which protocol so that a) the router ignores the incoming OSPF default route and b) does not redistribute his default route via OSPF? Mit freundlichen Grüßen, Marcus Büttemeyer ---------- Forwarded message --------- From: Marcus Büttemeyer <marcus.buettemeyer@gmail.com> Date: Sun, 7 Aug 2022 at 15:12 Subject: Filter OSPF to kernel routes To: <bird-users@network.cz> Hello, I'm distributing my default route via OSPFv3 from my edge router. For testing purposes I would like to ignore that default route on one of my routers. Said router gets a default route via IPv6 router advertisements but the OSPF route is preferred. So I tried: filter default-reject { if ::/0 ~ net then reject; } [...] protocol ospf v3 ospfv3 { ipv6 { import filter default-reject; [...] and protocol kernel kernel6 { ipv6 { export filter default-reject; }; [...] The filter seems to be correct, "show route filter ..." works in birdc. But I still have the OSPF default route. So it seems I misunderstand filters in BIRD completely. Can anybody point me in the right direction? Thanks in advance, Marcus Büttemeyer
On Sun, Aug 07, 2022 at 04:24:22PM +0200, Marcus Büttemeyer wrote:
OK, the problem seems to have been the name of the filter. BIRD says "syntax error, unexpected DEFAULT" so I renamed the filter to "reject_default" and that works. What did BIRD not like about "default-reject"?
Hi BIRD syntax allows only alphanumeric characters and underscore in names, so default-reject is parsed as three tokens: "default", "-", "reject". You can use apostrophes for defining names with other symbols: 'default-reject'
Also, I have said filter configured as import and export filters in both ospfv3 and kernel6 but the router in question still announces the default route via OSPFv3. Can anybody tell me what filter I have to use in which direction on which protocol so that a) the router ignores the incoming OSPF default route and b) does not redistribute his default route via OSPF?
You should use both import (for (a)) and export (for (b)) filter for OSPF protocol. Also note the filter should be more like: filter default-reject { if net = ::/0 then reject; else accept; } There should be explicit accept (it should fail with error when ends without reject or accept), and although "::/0 ~ net" should work, it is kind of strange expression (it means if ::/0 is subnet or equal to 'net'). -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
Hi! I am using a similar function for both IPv4/IPv6. function isdefault() { if net.type = NET_IP4 && net = 0.0.0.0/0 then return true; if net.type = NET_IP6 && net = ::/0 then return true; return false; } Maybe I can reduce the number of comparisons? If I compare ::/0 with an IPv4 address, what will be the result? On 07.08.2022 19:21, Ondrej Zajicek wrote:
On Sun, Aug 07, 2022 at 04:24:22PM +0200, Marcus Büttemeyer wrote:
OK, the problem seems to have been the name of the filter. BIRD says "syntax error, unexpected DEFAULT" so I renamed the filter to "reject_default" and that works. What did BIRD not like about "default-reject"? Hi
BIRD syntax allows only alphanumeric characters and underscore in names, so default-reject is parsed as three tokens: "default", "-", "reject".
You can use apostrophes for defining names with other symbols: 'default-reject'
Also, I have said filter configured as import and export filters in both ospfv3 and kernel6 but the router in question still announces the default route via OSPFv3. Can anybody tell me what filter I have to use in which direction on which protocol so that a) the router ignores the incoming OSPF default route and b) does not redistribute his default route via OSPF? You should use both import (for (a)) and export (for (b)) filter for OSPF protocol.
Also note the filter should be more like:
filter default-reject { if net = ::/0 then reject; else accept; }
There should be explicit accept (it should fail with error when ends without reject or accept), and although "::/0 ~ net" should work, it is kind of strange expression (it means if ::/0 is subnet or equal to 'net').
-- Regards, Mikhail V. Majorov Megalink, CEO B.Bulvarnaya 11, Taganrog, Russia, 347913 tel work: +7 8634 431431 (ext 101) tel mobile: +7 905 4309006 pg19.ru
Hi, Probably "net.len = 0" should be enough. On Mon, Aug 8, 2022 at 9:14 AM Mikhail Mayorov <mm@tagan.ru> wrote:
Hi!
I am using a similar function for both IPv4/IPv6.
function isdefault()
{
if net.type = NET_IP4 && net = 0.0.0.0/0 then return true;
if net.type = NET_IP6 && net = ::/0 then return true;
return false;
}
Maybe I can reduce the number of comparisons? If I compare ::/0 with an IPv4 address, what will be the result? On 07.08.2022 19:21, Ondrej Zajicek wrote:
On Sun, Aug 07, 2022 at 04:24:22PM +0200, Marcus Büttemeyer wrote:
OK, the problem seems to have been the name of the filter. BIRD says "syntax error, unexpected DEFAULT" so I renamed the filter to "reject_default" and that works. What did BIRD not like about "default-reject"?
Hi
BIRD syntax allows only alphanumeric characters and underscore in names, so default-reject is parsed as three tokens: "default", "-", "reject".
You can use apostrophes for defining names with other symbols: 'default-reject'
Also, I have said filter configured as import and export filters in both ospfv3 and kernel6 but the router in question still announces the default route via OSPFv3. Can anybody tell me what filter I have to use in which direction on which protocol so that a) the router ignores the incoming OSPF default route and b) does not redistribute his default route via OSPF?
You should use both import (for (a)) and export (for (b)) filter for OSPF protocol.
Also note the filter should be more like:
filter default-reject { if net = ::/0 then reject; else accept; }
There should be explicit accept (it should fail with error when ends without reject or accept), and although "::/0 ~ net" should work, it is kind of strange expression (it means if ::/0 is subnet or equal to 'net').
--
Regards, Mikhail V. Majorov Megalink, CEO B.Bulvarnaya 11, Taganrog, Russia, 347913 tel work: +7 8634 431431 (ext 101) tel mobile: +7 905 4309006
[image: pg19.ru]
participants (4)
-
Alexander Zubkov -
Marcus Büttemeyer -
Mikhail Mayorov -
Ondrej Zajicek