BGP dynamic filtering

Stefan Plug spl at ecix.net
Wed Feb 15 09:01:44 CET 2017


Hi,

We also use an external script to generate our BIRD configs. I can recommend using Python with Jinja2 templates.
Something like this:

Python calling jinja template:
    templateVars = {
			"peer_asn" : 1234
			"peer_id"  : 12
                        "ips" : ["1.1.1.1", "1.1.1.2"],
    }
    templateEnv = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath=os.path.join("/")))
    template = templateEnv.get_template(template.tmp)
    rendr = template.render( templateVars )
    filename = config["outputs"]["rt_tables"] + "rt_tables"
    f = open(filename, 'w')
    f.write(rendr.encode('utf8'))
    f.close()

Jinja template:
define ips_AS{{ peer.asn }}_PeerID{{ peer.id }} = [
{% for ip in ips %}
    {% if loop.last %}
    {{ ip }}
    {% else %}
    {{ ip }},
    {% endif %}
{% endfor %}
];

and the like Liran said just do a birdc configure


On 14.02.2017 13:20, Stanislaw wrote:
> Hi,
> 
> Yes, you can do that. The best practice (at least for myself) is using the separate auto-generated config with prefix-lists which is included to the
> bird.conf. After regenerating it via some of your scripts, just run birdc configure. The reconfiguration of import/export filters is completely
> seamless. As for the performance impact: it uses some extra CPU power for recalculating bestpathes but it lasts for ~1 second on modern CPUs.
> 
> Whant kind of example do you want? Just make another file, write your prefix-lists as a variables (or constants) there and use the 'include' statement
> in the bird.conf. Ofc, use those variables in your filters.
> 
> 
> Liran Schour писал 2017-02-14 13:46:
> 
>> Hi all,
>>
>> I want to implement a dynamic filter where I will export a route based on matching against a dynamic set of prefixes. The set is maintained
>> according to a database.
>>
>> 1. Can I maintain a dynamic set of prefixes and change the set on the fly? What are the performance impacts of this?
>> 2.. Where can I find such an example?
>>
>> - Liran



More information about the Bird-users mailing list