8c9e3e5af5d2888aff8cf8659a2d8208b302e9cc
howto/Bird-communities.md
... | ... | @@ -1,6 +1,6 @@ |
1 | -Bird is a commonly used BGP daemon. This page provides configuration and help to run Bird for dn42. |
|
1 | +Bird is a commonly used BGP daemon. This page provides configuration and help for using BGP communities with Bird for dn42. |
|
2 | 2 | |
3 | -Communities can be used to prioritize traffic based on different flags, in DN42 we are using communities to display latency, bandwidth and encryption. Please note that everyone should be using community 64511. |
|
3 | +Communities can be used to prioritize traffic based on different flags, in DN42 we are using communities to prioritize based on latency, bandwidth and encryption. Please note that everyone should be using community 64511. |
|
4 | 4 | |
5 | 5 | The community is applied to the route when it is imported and exported, therefore you need to change your bird configuration, in /etc/bird/peers4 if you followed the [Bird](/howto/Bird) guide. |
6 | 6 | |
... | ... | @@ -32,3 +32,40 @@ bw = min(up,down) for asymmetric connections |
32 | 32 | ``` |
33 | 33 | For example, if your peer is 12ms away and your link speed is 250Mbit/s and you are peering using OpenVPN P2P, then the community string would be (3, 4, 33). |
34 | 34 | |
35 | +### community_filters.conf |
|
36 | +``` |
|
37 | +#/etc/bird/community_filters.conf |
|
38 | +function update_latency(int link_latency) { |
|
39 | + bgp_community.add((64511, link_latency)); |
|
40 | + if (64511, 9) ~ bgp_community then { bgp_community.delete([(64511, 1..8)]); return 9; } |
|
41 | + else if (64511, 8) ~ bgp_community then { bgp_community.delete([(64511, 1..7)]); return 8; } |
|
42 | + else if (64511, 7) ~ bgp_community then { bgp_community.delete([(64511, 1..6)]); return 7; } |
|
43 | + else if (64511, 6) ~ bgp_community then { bgp_community.delete([(64511, 1..5)]); return 6; } |
|
44 | + else if (64511, 5) ~ bgp_community then { bgp_community.delete([(64511, 1..4)]); return 5; } |
|
45 | + else if (64511, 4) ~ bgp_community then { bgp_community.delete([(64511, 1..3)]); return 4; } |
|
46 | + else if (64511, 3) ~ bgp_community then { bgp_community.delete([(64511, 1..2)]); return 3; } |
|
47 | + else if (64511, 2) ~ bgp_community then { bgp_community.delete([(64511, 1..1)]); return 2; } |
|
48 | + else return 1; |
|
49 | +} |
|
50 | + |
|
51 | +function update_bandwidth(int link_bandwidth) { |
|
52 | + bgp_community.add((64511, link_bandwidth)); |
|
53 | + if (64511, 21) ~ bgp_community then { bgp_community.delete([(64511, 22..29)]); return 21; } |
|
54 | + else if (64511, 22) ~ bgp_community then { bgp_community.delete([(64511, 23..29)]); return 22; } |
|
55 | + else if (64511, 23) ~ bgp_community then { bgp_community.delete([(64511, 24..29)]); return 23; } |
|
56 | + else if (64511, 24) ~ bgp_community then { bgp_community.delete([(64511, 25..29)]); return 24; } |
|
57 | + else if (64511, 25) ~ bgp_community then { bgp_community.delete([(64511, 26..29)]); return 25; } |
|
58 | + else if (64511, 26) ~ bgp_community then { bgp_community.delete([(64511, 27..29)]); return 26; } |
|
59 | + else if (64511, 27) ~ bgp_community then { bgp_community.delete([(64511, 28..29)]); return 27; } |
|
60 | + else if (64511, 28) ~ bgp_community then { bgp_community.delete([(64511, 29..29)]); return 28; } |
|
61 | + else return 29; |
|
62 | +} |
|
63 | + |
|
64 | +function update_crypto(int link_crypto) { |
|
65 | + bgp_community.add((64511, link_crypto)); |
|
66 | + if (64511, 31) ~ bgp_community then { bgp_community.delete([(64511, 32..34)]); return 31; } |
|
67 | + else if (64511, 32) ~ bgp_community then { bgp_community.delete([(64511, 33..34)]); return 32; } |
|
68 | + else if (64511, 33) ~ bgp_community then { bgp_community.delete([(64511, 34..34)]); return 33; } |
|
69 | + else return 34; |
|
70 | +} |
|
71 | +``` |
|
... | ... | \ No newline at end of file |