9ca8eb116e76a96999a33e413e45ced3f7538ae2
howto/BGP-communities.md
| ... | ... | @@ -47,6 +47,21 @@ bw = min(up,down) for asymmetric connections |
| 47 | 47 | (64511, 32) :: encrypted with unsafe vpn solution |
| 48 | 48 | (64511, 33) :: encrypted with safe vpn solution (but no PFS - the usual OpenVPN p2p configuration falls in this category) |
| 49 | 49 | (64511, 34) :: encrypted with safe vpn solution with PFS (Perfect Forward Secrecy) |
| 50 | +(64511, 35): encrypted with safe vpn solution with PFS (Perfect Forward Secrecy) and post-quantum resistance but without post-quantum forward secrecy (e.g. WireGuard with PSK) |
|
| 51 | +(64511, 36): encrypted with safe vpn solution with PFS (Perfect Forward |
|
| 52 | +Secrecy) and post-quantum forward secrecy (e.g. WireGuard with Rosenpass) |
|
| 53 | + |
|
| 54 | +(64511, 81) :: Physical connection (e.g. Ethernet cable, direct wireless link) |
|
| 55 | +(64511, 82) :: Connection over Internet Exchange Points (Manually or via router server) (e.g. Ethernet cable on a big switch) |
|
| 56 | +(64511, 83) :: Connection over Tunnel (e. g. WireGuard, fastd, GRE) |
|
| 57 | +(64511, 84) :: Connection over meshed Virtual Internet Exchange Points (Manually or via router server) (e.g. Tailscale, Tinc, n2n) |
|
| 58 | +(64511, 85) :: Connection over centralized Virtual Internet Exchange Points (Manually or via router server) (e.g. WireGuard to a single Server with a virtual switch) |
|
| 59 | +(64511, 89) :: Unknown type / Other type |
|
| 60 | + |
|
| 61 | +(6511, 91) :: almost 0% packet lost |
|
| 62 | +(6511, 92) :: up to 1% packet lost |
|
| 63 | +(6511, 93) :: up to 5% packet lost |
|
| 64 | +(6511, 94) :: over 5% packet lost (impossible link?) |
|
| 50 | 65 | |
| 51 | 66 | Propagation: |
| 52 | 67 | - - for latency pick max(received_route.latency, link_latency) |
| ... | ... | @@ -72,6 +87,11 @@ $ ruby bgp-community.rb -6 dn42-2.higgsboson.tk 1000 pfs |
| 72 | 87 | export where dn42_export_filter(3,25,34); |
| 73 | 88 | ``` |
| 74 | 89 | |
| 90 | +Peerings with packet loss exceeding 5% have proven to be unstable. |
|
| 91 | +Such peering connections should be avoided whenever possible. |
|
| 92 | + |
|
| 93 | +If an automated method is used to update the latency communities, care must be taken to ensure that the communities are not updated too frequently, in order to avoid flapping (a large number of attribute changes). For example, a script could always calculate the average latency over the last 12 hours and then set the new value accordingly. |
|
| 94 | + |
|
| 75 | 95 | ### Route Origin |
| 76 | 96 | There are two type of route origin: `region` and `country` |
| 77 | 97 | |
| ... | ... | @@ -164,28 +184,56 @@ function update_bandwidth(int link_bandwidth) -> int { |
| 164 | 184 | |
| 165 | 185 | function update_crypto(int link_crypto) -> int { |
| 166 | 186 | bgp_community.add((64511, link_crypto)); |
| 167 | - if (64511, 31) ~ bgp_community then { bgp_community.delete([(64511, 32..34)]); return 31; } |
|
| 168 | - else if (64511, 32) ~ bgp_community then { bgp_community.delete([(64511, 33..34)]); return 32; } |
|
| 169 | - else if (64511, 33) ~ bgp_community then { bgp_community.delete([(64511, 34..34)]); return 33; } |
|
| 170 | - else return 34; |
|
| 187 | + if (64511, 31) ~ bgp_community then { bgp_community.delete([(64511, 32..36)]); return 31; } |
|
| 188 | + else if (64511, 32) ~ bgp_community then { bgp_community.delete([(64511, 33..36)]); return 32; } |
|
| 189 | + else if (64511, 33) ~ bgp_community then { bgp_community.delete([(64511, 34..36)]); return 33; } |
|
| 190 | + else if (64511, 34) ~ bgp_community then { bgp_community.delete([(64511, 35..36)]); return 34; } |
|
| 191 | + else if (64511, 35) ~ bgp_community then { bgp_community.delete([(64511, 36..36)]); return 35; } |
|
| 192 | + else return 36; |
|
| 193 | +} |
|
| 194 | + |
|
| 195 | +function update_topology(int link_topology) -> int { |
|
| 196 | + bgp_community.add((64511, update_topology)); |
|
| 197 | + if (64511, 89) ~ bgp_community then { bgp_community.delete([(64511, 81..88)]); return 89; } |
|
| 198 | + else if (64511, 85) ~ bgp_community then { bgp_community.delete([(64511, 81..84)]); return 85; } |
|
| 199 | + else if (64511, 84) ~ bgp_community then { bgp_community.delete([(64511, 81..83)]); return 84; } |
|
| 200 | + else if (64511, 83) ~ bgp_community then { bgp_community.delete([(64511, 81..82)]); return 83; } |
|
| 201 | + else if (64511, 82) ~ bgp_community then { bgp_community.delete([(64511, 81..81)]); return 82; } |
|
| 202 | + else return 81; |
|
| 203 | +} |
|
| 204 | + |
|
| 205 | +function update_packetloss(int link_packetloss) -> int { |
|
| 206 | + bgp_community.add((64511, link_packetloss)); |
|
| 207 | + if (64511, 94) ~ bgp_community then { bgp_community.delete([(64511, 91..93)]); return 94; } |
|
| 208 | + else if (64511, 93) ~ bgp_community then { bgp_community.delete([(64511, 91..92)]); return 93; } |
|
| 209 | + else if (64511, 92) ~ bgp_community then { bgp_community.delete([(64511, 91..91)]); return 92; } |
|
| 210 | + else return 91; |
|
| 171 | 211 | } |
| 172 | -#Remove the following function if you do not want to advertize your region in the BGP community. |
|
| 212 | + |
|
| 213 | +# Remove the following function if you do not want to advertize your region in the BGP community. |
|
| 173 | 214 | function update_geo_flags() -> bool { |
| 174 | 215 | if (is_self_net() || is_self_net_v6()) && source = RTS_STATIC then { |
| 175 | 216 | bgp_community.add((64511, DN_REGION_GEO)); |
| 176 | 217 | bgp_community.add((64511, DN_REGION_COUNTRY)); |
| 177 | 218 | } |
| 178 | 219 | } |
| 179 | -function update_flags(int link_latency; int link_bandwidth; int link_crypto) -> bool |
|
| 220 | + |
|
| 221 | +function update_flags(int link_latency; int link_bandwidth; int link_crypto; int link_topology; int link_packetloss) -> bool |
|
| 180 | 222 | int dn42_latency; |
| 181 | 223 | int dn42_bandwidth; |
| 182 | 224 | int dn42_crypto; |
| 225 | +int dn42_topology; |
|
| 226 | +int dn42_packetloss; |
|
| 183 | 227 | { |
| 184 | 228 | dn42_latency = update_latency(link_latency); |
| 185 | 229 | dn42_bandwidth = update_bandwidth(link_bandwidth) - 20; |
| 186 | 230 | dn42_crypto = update_crypto(link_crypto) - 30; |
| 231 | + dn42_topology = update_topology(link_topology) - 80; |
|
| 232 | + dn42_packetloss = update_packetloss(link_packetloss) - 90; |
|
| 233 | + |
|
| 187 | 234 | # replace 4 with your calculated bandwidth value |
| 188 | 235 | if dn42_bandwidth > 4 then dn42_bandwidth = 4; |
| 236 | + |
|
| 189 | 237 | return true; |
| 190 | 238 | } |
| 191 | 239 |