Converting a route between tables via pipe proto?
Ondrej Zajicek
santiago at crfreenet.org
Sat Jan 23 00:48:19 CET 2021
On Fri, Jan 22, 2021 at 03:26:59PM -0500, David Johnson wrote:
> Hi,
>
> I'm trying to see if bird can accomplish the following and so far I can't
> seem to find a way to do it.
>
> Quick summary:
> I want to be able to modify a route (the actual IP/mask) between 2
> interfaces.
>
>
> Setup is as follows:
>
> table A: routes learned as normal
>
> table B: I want to advertise a specific route into table B if there is
> another specific route learned on table A. Note that the route in table B
> is different than A but I want to link/convert them somehow.
>
> Why would I want to do this? This Linux setup is performing NETMAP to
> convert IPs when forwarded between 2 interfaces. I know the exact prefixes
> so I can enter them in the config but I want to dynamically advertise those
> into B but only if they are reachable via A.
>
>
> My first attempt was to use a proto pipe between the two tables and simply
> change the net variable:
>
> protocol pipe a_b_pipe {
> table b;
> peer table a;
> import filter { # a -> b
> if net ~ A.B.C.D/E then { net = F.G.H.I/J; accept; };
> reject;
> };
> export none; # b -> a
> }
>
> but that doesn't work:
> bird: /etc/bird/bird.conf:24:56 This static attribute is read-only.
>
>
> My second attempt was to setup filters/functions on the protos in table A
> to set some variable if the specific route is seen, then reference that
> variable via a static proto route in table B. This seems to be a no go as
> there are global constants (define xxx;) but attributes are local and
> function variables are also local scope.
>
> Other suggestions appreciated, or is this just not possible?
Hi
It is not possible to do this directly, but there is one ugly trick how
to do that:
You can use pipe to import route A.B.C.D/E from table a to auxiliary
table c. Then have static route F.G.H.I/J with recursive nexthop from
A.B.C.D/E put to auxiliary table c. If route A.B.C.D/E is exported to
table c, then route F.G.H.I/J would inherit its nexthop, otherwise it
would be unreachable. Last, you can have pipe from table c to table b
that accepts only network F.G.H.I/J and only when it is reachable
(dest = RTD_UNICAST). And you should also reset its gateway (using
'gw = gw;' filter command), so it is no longer recursive when propagated
to table b.
--
Elen sila lumenn' omentielvo
Ondrej 'Santiago' Zajicek (email: santiago at 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."
More information about the Bird-users
mailing list