determining ipv4 or ipv6 net in filter
Migrating from BIRD 1.6 to 2.0 and I would like to consolidate some BGP filters and use them for IPv4 or IPv6 sessions.... What is the best way to enumerate if a net is IPv4 or IPv6 if you wanted to make a if/then/else on.. ie: filter MY_FILTER { if ((MYAS, 888) ~ bgp_community) then { if (< Is IPv4 ?>) then { do this...; accept; } else if (< Is IPv6 ?> then { do that...; accept; } else { reject; } } reject; } TIA -- inoc.net!rblayzor XMPP: rblayzor.AT.inoc.net PGP: https://pgp.inoc.net/rblayzor/
On Mon, 27 Jan 2020 at 20:27, Robert Blayzor <rblayzor.bulk@inoc.net> wrote:
Migrating from BIRD 1.6 to 2.0 and I would like to consolidate some BGP filters and use them for IPv4 or IPv6 sessions....
What is the best way to enumerate if a net is IPv4 or IPv6 if you wanted to make a if/then/else on.. ie:
filter MY_FILTER { if ((MYAS, 888) ~ bgp_community) then { if (< Is IPv4 ?>) then { do this...; accept; } else if (< Is IPv6 ?> then { do that...; accept; } else { reject; } } reject; }
TIA
Depending on your existing approach. One possible option is to go the "we use communities" approach. Were you tag ALL routes on ingress/import into the control plane. And henceforth from then on on egress. You act on communities - when used in your OUT filters - instead of using anything AF_INET specific. Were you need to differentiate between v4 and v6. It may require some planning/schematic on how you want to use what communities/ranges for what purpose (look to large communities). But can be worthwhile in the long run. Chriztoffer
After some digging through the BIRD 2.0 manual, I may have found my own answer, but first time working with BIRD 2.0 so not sure if this is valid.... Maybe something like: if (net.type = NET_IP4) && (net.len = 32) then { ... } else if (net.type = NET_IP6) && (net.len > 63) then { ... } -- inoc.net!rblayzor XMPP: rblayzor.AT.inoc.net PGP: https://pgp.inoc.net/rblayzor/
Yes. This version should work. BTW, I suggest using custom attributes instead of communities for all the route tagging. They work the same way as other attributes and all protocols (except for Pipe) ignore them. Maria On January 27, 2020 8:52:38 PM GMT+01:00, Robert Blayzor <rblayzor.bulk@inoc.net> wrote:
After some digging through the BIRD 2.0 manual, I may have found my own answer, but first time working with BIRD 2.0 so not sure if this is valid....
Maybe something like:
if (net.type = NET_IP4) && (net.len = 32) then { ... } else if (net.type = NET_IP6) && (net.len > 63) then { ... }
-- inoc.net!rblayzor XMPP: rblayzor.AT.inoc.net PGP: https://pgp.inoc.net/rblayzor/
-- Sent from my Android device with K-9 Mail. Please excuse my brevity.
Excellent. I like the custom attributes for route tagging. However in the docs I cannot find what "types" are supported for custom attributes. For example: attribute string foo; Results in an unsupported type, yet: attribute int foo; works... On 1/27/20 5:37 PM, Maria Matějka wrote:
Yes. This version should work.
BTW, I suggest using custom attributes instead of communities for all the route tagging. They work the same way as other attributes and all protocols (except for Pipe) ignore them.
Maria
Maria, On Tue, 28 Jan 2020 at 02:03, Robert Blayzor <rblayzor.bulk@inoc.net> wrote:
Excellent. I like the custom attributes for route tagging. However in the docs I cannot find what "types" are supported for custom attributes. For example:
attribute string foo;
Results in an unsupported type, yet: attribute int foo; works...
https://bird.network.cz/?get_doc&v=20&f=bird-5.html#ss5.6 https://fossies.org/linux/bird-doc/doc/bird.pdf https://ripe78.ripe.net/presentations/91-bird_new_features_migrate_ripe78.pd... Looks very promising, indeed. (writes a user, still stuck on 1.6.x) Is it possible the Wiki could come to include quick "cheat-sheet"-ish example(s) of how custom route attributes in bird >= 2.0.4 can be utilised? https://gitlab.labs.nic.cz/labs/bird/wikis/Examples Chriztoffer
participants (3)
-
Chriztoffer Hansen -
Maria Matějka -
Robert Blayzor