How to use a variable for OSPF interfaces?

Ondrej Zajicek santiago at crfreenet.org
Fri May 2 21:40:45 CEST 2025


On Fri, May 02, 2025 at 01:37:17PM +0200, Arnaud Gomes-do-Vale wrote:
> Hi,
> 
> I have a common block of configuration for a bunch of routers that I
> would like to share in an include file. It looks basically like this:
> 

...

> I tried the obvious:
> 
> ```
> define OSPF_INTF = "enp1s0f1.1004";
> protocol ospf v3 o_backbone_ipv6 {
> .../...
>        interface OSPF_INTF;
> .../...
> }
> ```
> 
> Which BIRD definitely didn't like:
> 
> ```
> bird> conf check
> Reading configuration from /etc/bird/bird.conf
> /etc/bird/bird.conf:110:12 IP address or network constant expected
> ```
> 
> What did I miss?

Hi

You missed nothing, that is just a legacy limitation in BIRD. Defines
were originally just for integers and using them for other purposes
outside of filters still does not work in many cases. We should fix that.

You could try a creative use of include:

```
ipv6 table ospf_backbone6;
protocol ospf v3 o_backbone_ipv6 {
  area 0 {
    interface
include "iface_filename.conf";
    ;
    interface "loop0" { stub yes; };
  };
  ipv6 {
    import all;
    export all;
    table ospf_backbone6;
  };
}
```

with iface_filename.conf containing just "enp1s0f1.1004"

We process includes on lexer level, so they can be used even inside
expressions, but have to start at an empty line. Note two semicolons,
the first closing the include, the second closing the interface.

-- 
Elen sila lumenn' omentielvo

Ondrej 'Santiago' Zajicek (email: santiago at crfreenet.org)
"To err is human -- to blame it on a computer is even more so."


More information about the Bird-users mailing list