01dedf0f0618393722565f4c9ce474575c993e14
howto/Bird-communities.md
| ... | ... | @@ -30,10 +30,30 @@ bw = min(up,down) for asymmetric connections |
| 30 | 30 | (64511, 33) :: encrypted with safe vpn solution (but no PFS - the usual OpenVPN p2p configuration falls in this category) |
| 31 | 31 | (64511, 34) :: encrypted with safe vpn solution with PFS |
| 32 | 32 | ``` |
| 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 | - |
|
| 35 | -### community_filters.conf |
|
| 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, 24, 33). |
|
| 34 | +``` |
|
| 35 | +### /etc/bird/peers4/tombii.conf |
|
| 36 | +# /etc/bird/peers4/tombii.conf |
|
| 37 | +protocol bgp tombii from dnpeers { |
|
| 38 | + neighbor 172.23.102.x as 4242420321; |
|
| 39 | + import filter { |
|
| 40 | + if is_valid_network() && !is_self_net() then { |
|
| 41 | + update_flags(3,24,33); |
|
| 42 | + accept; |
|
| 43 | + } |
|
| 44 | + reject; |
|
| 45 | + }; |
|
| 46 | + export filter { |
|
| 47 | + if is_valid_network() then { |
|
| 48 | + update_flags(3,24,33); |
|
| 49 | + accept; |
|
| 50 | + } |
|
| 51 | + reject; |
|
| 52 | + }; |
|
| 53 | +}; |
|
| 36 | 54 | ``` |
| 55 | +``` |
|
| 56 | +### community_filters.conf |
|
| 37 | 57 | #/etc/bird/community_filters.conf |
| 38 | 58 | function update_latency(int link_latency) { |
| 39 | 59 | bgp_community.add((64511, link_latency)); |
| ... | ... | @@ -68,4 +88,17 @@ function update_crypto(int link_crypto) { |
| 68 | 88 | else if (64511, 33) ~ bgp_community then { bgp_community.delete([(64511, 34..34)]); return 33; } |
| 69 | 89 | else return 34; |
| 70 | 90 | } |
| 91 | + |
|
| 92 | +function update_flags(int link_latency; int link_bandwidth; int link_crypto) |
|
| 93 | +int latency; |
|
| 94 | +int bandwidth; |
|
| 95 | +int crypto; |
|
| 96 | +{ |
|
| 97 | +latency = update_latency(link_latency); |
|
| 98 | +bandwidth = update_bandwidth(link_bandwidth) - 20; |
|
| 99 | +crypto = update_crypto(link_crypto) - 30; |
|
| 100 | +if bandwidth > 4 then bandwidth = 4; |
|
| 101 | +bgp_local_pref = 100*bandwidth + 100*(10-latency)-100*bgp_path.len+50*crypto; |
|
| 102 | +return true; |
|
| 103 | +} |
|
| 71 | 104 | ``` |
| ... | ... | \ No newline at end of file |