f8b3aa3b2f658fa019103c2c9a29673cc4a788d3
howto/BGP-communities.md
| ... | ... | @@ -1,21 +1,28 @@ |
| 1 | -Bird2 is a commonly used BGP daemon. This page provides configuration and help for using BGP communities with Bird2 for dn42. |
|
| 1 | +Communities are tags that are applied to BGP prefixes. Communities can be used to make routing decisions and prioritize traffic based on various features. In DN42 we are using communities to prioritize based on latency, bandwidth and encryption. |
|
| 2 | + |
|
| 3 | +A BGP Community is a 32-bit field that consists of two 16-bit halves. The first half is generally the 16-bit AS Number of the entity applying the tag, and the second half is an opaque 16-bit numeric value that has a specific meaning to the applying entity. |
|
| 4 | + |
|
| 5 | +Please note that everyone in DN42 should be using communities with AS number 64511. |
|
| 6 | + |
|
| 7 | +## Bird2 |
|
| 2 | 8 | |
| 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. |
|
| 9 | +Bird2 is a commonly used BGP daemon. This page provides configuration and help for using BGP communities with Bird2 for dn42. |
|
| 4 | 10 | |
| 5 | 11 | The community is applied to the route when it is imported and exported, therefore you need to change your bird configuration |
| 6 | 12 | in /etc/bird/peers/* |
| 7 | 13 | |
| 8 | 14 | The filter helpers can be stored in a separate file, for example /etc/bird/community_filters.conf. |
| 9 | 15 | |
| 10 | -Below, you will see an example config for peers based on the original filter implementation by Jplitza. |
|
| 11 | -Additionally the below configuration applied BGP MED on exports using the communities |
|
| 12 | -as an example for what they can be used for. |
|
| 16 | +Below you will see an example config for peers based on the original filter implementation by Jplitza. The example configuration also applies BGP MED on exported routes, to demonstrate how communities can implement an administrative routing policy. |
|
| 17 | + |
|
| 13 | 18 | This is based on mk16's lab implemenation at [https://mk16.de/blog/lab-en/](https://mk16.de/blog/lab-en/) |
| 14 | 19 | |
| 15 | 20 | |
| 16 | -To properly assign the right community to your peer, please reference the table below. If you are running your own network and peering internally, please also apply the communities inside your network. |
|
| 21 | +## BGP communities in use in dn42 |
|
| 17 | 22 | |
| 18 | -## BGP community criteria |
|
| 23 | +To properly assign the right community to your peer, please refer to the table below. If you are running your own network and peering internally, please also apply the communities inside your network. |
|
| 24 | + |
|
| 25 | +### Peering link characteristics |
|
| 19 | 26 | ```conf |
| 20 | 27 | (64511, 1) :: latency \in (0, 2.7ms] |
| 21 | 28 | (64511, 2) :: latency \in (2.7ms, 7.3ms] |
| ... | ... | @@ -114,6 +121,9 @@ The range `1000-1999` is assigned to the country property. Here we use [ISO-3166 |
| 114 | 121 | etc. Please follow the ISO-3166-1 Numeric standard |
| 115 | 122 | <https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.csv>. |
| 116 | 123 | |
| 124 | + |
|
| 125 | +## Example configuration for BIRD2 |
|
| 126 | + |
|
| 117 | 127 | You need to add following lines to your config(s): |
| 118 | 128 | - `define DN42_REGION = $VALUE_FROM_ABOVE` to your node's config (where OWNAS and OWNIP are set) |
| 119 | 129 | - `if source = RTS_STATIC then bgp_community.add((64511, DN42_REGION));` |
| ... | ... | @@ -123,7 +133,7 @@ just above `update_flags` in `dn42_export_filter` function |
| 123 | 133 | This is not applicable for the below example configurations |
| 124 | 134 | that have it included, since networks usually use the region to do |
| 125 | 135 | routing policies like cold_potato. |
| 126 | -## Example configuration for BIRD2 |
|
| 136 | + |
|
| 127 | 137 | ```conf |
| 128 | 138 | function update_latency(int link_latency) -> int { |
| 129 | 139 | bgp_community.add((64511, link_latency)); |
| ... | ... | @@ -230,10 +240,9 @@ function dn42_export_filter(int link_latency; int link_bandwidth; int link_crypt |
| 230 | 240 | } |
| 231 | 241 | reject; |
| 232 | 242 | } |
| 233 | - |
|
| 234 | 243 | ``` |
| 235 | -And in your /etc/bird/peers/example.conf peer where your parameters as as such |
|
| 236 | -11 ms, 1000 mbit/s, pfs tunnel example with MP-BGP with ENH |
|
| 244 | + |
|
| 245 | +And in your /etc/bird/peers/example.conf peer config, where your peering connection are for example: 11 ms latency, 1000 Mbps bandwidth, pfs tunnel, using MP-BGP with ENH: |
|
| 237 | 246 | ```conf |
| 238 | 247 | protocol bgp example from dnpeers { |
| 239 | 248 | neighbor neighbor <neighborip><%interface if Link Local is used> as <AUT_NUM>; |
| ... | ... | @@ -248,19 +257,19 @@ protocol bgp example from dnpeers { |
| 248 | 257 | export where dn42_export_filter(3,25,34); |
| 249 | 258 | }; |
| 250 | 259 | ``` |
| 251 | -Please remember to include /etc/bird/community_filters.conf and to define your GEO regions in your bird.conf |
|
| 260 | + |
|
| 261 | +Remember to include /etc/bird/community_filters.conf and to define your GEO regions in your bird.conf |
|
| 252 | 262 | ```conf |
| 253 | 263 | # local configuration |
| 254 | 264 | ###################### |
| 255 | -# In the variable header or anywhere before the include for the community filters add |
|
| 265 | +# If you wish to add the BGP Geographical Communities make sure you define these values appropriately. |
|
| 266 | +# This should go in the variable header, or anywhere before you include the community filters. |
|
| 256 | 267 | define DN_REGION_GEO = xx; |
| 257 | 268 | define DN_REGION_COUNTRY = xxxx; |
| 258 | -#If you wish to add the BGP Geographical Communities. |
|
| 259 | 269 | |
| 260 | -#before you import your peers add the community filters eg |
|
| 261 | -#include "/etc/bird/community_filters.conf"; |
|
| 262 | -#include "/etc/bird/peers/*"; |
|
| 270 | +# Make sure to include community filters before your peers, eg: |
|
| 263 | 271 | include "/etc/bird/community_filters.conf"; |
| 272 | +include "/etc/bird/peers/*"; |
|
| 264 | 273 | ``` |
| 265 | 274 | |
| 266 | 275 |