Filter based on condition or watchdog
Hi all! Does BIRD allow to write a filter, where I can define a condition when it should import/export some route(s) and when it should not? To clarify my question, example: I want to check whether some process (lets say apache) is running and the server is listening TCP port 80, so if these conditions are true, BIRD should export some route to OSPF, if false - should not.
On 06/02/2017 12:59 PM, Войнович Андрей Александрович wrote:
Hi all!
Does BIRD allow to write a filter, where I can define a condition when it should import/export some route(s) and when it should not? To clarify my question, example: I want to check whether some process (lets say apache) is running and the server is listening TCP port 80, so if these conditions are true, BIRD should export some route to OSPF, if false – should not.
No, this is not possible in a simple way. Anyway, you may use a set of config files like this: bird.conf: ... include "apache-check.conf"; ... apache-check-yes.conf: static apachecheck { route XYZ }; apache-check-no.conf: empty apache-check.conf: symlink to apache-check-no.conf write a script like this: * if the condition is true: ln -sf apache-check-yes.conf apache-check.conf * else: ln -sf apache-check-no.conf apache-check.conf * if the script changed the symlink, reload bird config and run the script by cron every other while. Hope this is clear enough to help you. MQ
Or modify variant with krt_source: For enable announcing: ip route change to AAAA dev lo proto NNN For disable: ip route change to AAAA dev lo proto kernel protocol kernel MAIN{ persist; scan time 20; learn; import where krt_source = NNN; export all; } where NNN some unused number in /etc/iproute2/rt_protos If you don't want to use birdc configure every time. 02.06.2017, 16:54, "Jan Matejka" <jan.matejka@nic.cz>:
On 06/02/2017 12:59 PM, Войнович Андрей Александрович wrote:
Hi all!
Does BIRD allow to write a filter, where I can define a condition when it should import/export some route(s) and when it should not? To clarify my question, example: I want to check whether some process (lets say apache) is running and the server is listening TCP port 80, so if these conditions are true, BIRD should export some route to OSPF, if false – should not.
No, this is not possible in a simple way.
Anyway, you may use a set of config files like this:
bird.conf: ... include "apache-check.conf"; ...
apache-check-yes.conf: static apachecheck { route XYZ };
apache-check-no.conf: empty
apache-check.conf: symlink to apache-check-no.conf
write a script like this:
* if the condition is true: ln -sf apache-check-yes.conf apache-check.conf * else: ln -sf apache-check-no.conf apache-check.conf * if the script changed the symlink, reload bird config
and run the script by cron every other while.
Hope this is clear enough to help you. MQ
On 2 June 2017 at 11:59, Войнович Андрей Александрович <andreyv@skbkontur.ru> wrote:
Hi all!
Does BIRD allow to write a filter, where I can define a condition when it should import/export some route(s) and when it should not? To clarify my question, example: I want to check whether some process (lets say apache) is running and the server is listening TCP port 80, so if these conditions are true, BIRD should export some route to OSPF, if false – should not.
Hi, You will need some external monitoring script to handle this. To withdraw a route when a service fails there is a simpler option to have bird import from the kernel routing table and use an external script to add/remove routes. if `wget -O/dev/null https://u4477715.ct.sendgrid.net/wf/click?upn=IRP6gkWjxp-2BUYovgLeGtGDf-2FKz... then ip route add 1.2.3.4/32 dev lo else ip route del 1.2.3.4/32 dev lo fi Something like that in a while loop or cron job should be simpler than changing config files. Of course, this only works for the "turn off my advertisements when I’m broken" use case and isn't suitable for more complex requirements. You can also use an alternative kernel routing table purely for injecting in to bird if you don't want the routes in your main routing table. - Mike Jones
participants (4)
-
Jan Matejka -
Mike Jones -
Войнович Андрей Александрович -
Гаврилов Игорь