_Sidebar.md
... ...
@@ -2,7 +2,7 @@
2 2
* [Getting Started](/howto/Getting-Started)
3 3
* [Registry Authentication](/howto/Registry-Authentication)
4 4
* [Address Space](/howto/Address-Space)
5
- * [BGP communities](/howto/Bird-communities)
5
+ * [BGP communities](/howto/BGP-communities)
6 6
* [FAQ](/FAQ)
7 7
8 8
* How-To
... ...
@@ -15,7 +15,7 @@
15 15
* [IPv6 Multicast (PIM-SM)](/howto/IPv6-Multicast)
16 16
* [SSM Multicast](/howto/multicast)
17 17
* [MPLS](/howto/mpls)
18
- * [Bird](/howto/Bird) / [Bird2](/howto/Bird2)
18
+ * [Bird2](/howto/Bird2)
19 19
* [Quagga](/howto/Quagga)
20 20
* [FRRouting](/howto/frr)
21 21
* [OpenBGPD](/howto/OpenBGPD)
... ...
@@ -46,6 +46,9 @@
46 46
* [Show and Tell](/internal/ShowAndTell)
47 47
* [Historical services](/internal/Historical-Services)
48 48
49
+* Historical
50
+ * [Bird 1](/historical/Bird) /
51
+
49 52
* External Tools
50 53
* [Paste Board](https://paste.dn42.us)
51 54
* [Git Repositories](https://git.dn42.dev)
historical/Bird.md
... ...
@@ -0,0 +1,467 @@
1
+Bird is a commonly used BGP daemon. This page provides configuration and help to run Bird for dn42.
2
+Compared to quagga, bird supports multiple routing tables, which is useful, if you also plan to peer with other federated networks such as freifunk. In the following a working configuration for dn42 is shown. If you
3
+want to learn the practical details behind routing protocols in bird, see the following [guide](https://github.com/knorrie/network-examples)
4
+
5
+**Bird 1.6.x will be EOL by the end of 2023, it's recommended to upgrade to 2.13.**
6
+
7
+# Debian
8
+In the Debian release cycle the bird packages may become outdated at times, if that is the case you should use the official bird package repository maintained by the developers of nic.cz.
9
+
10
+This is not necessary for Debian Stretch, which currently ships the most recent version (1.6.3) in this repositories.
11
+
12
+```sh
13
+echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/buster-backports.list
14
+apt update
15
+apt install bird
16
+```
17
+
18
+# Example configuration
19
+
20
+Note: This file covers the configuration of Bird 1.x. For an example configuration of Bird 2.x see [howto/Bird2](/howto/Bird2)
21
+
22
+* Replace `<AS>` with your Autonomous System Number (only the digits)
23
+* Replace `<GATEWAY_IP>` with your gateway ip (the internal dn42 ip address you use on the host, where dn42 is running)
24
+* Replace `<SUBNET>` with your registered dn42 subnet
25
+* Replace `<PEER_IP>` with the ip of your peer who is connected with you using your favorite vpn protocol (openvpn, ipsec, tinc, ...)
26
+* Replace `<PEER_AS>` the Autonomous System Number of your peer (only the digits)
27
+* Replace `<PEER_NAME>` a self chosen name for your peer
28
+
29
+## IPv6
30
+
31
+```conf
32
+#/etc/bird/bird6.conf
33
+protocol device {
34
+ scan time 10;
35
+}
36
+
37
+# local configuration
38
+######################
39
+
40
+include "/etc/bird/local6.conf";
41
+
42
+# filter helpers
43
+#################
44
+
45
+##include "/etc/bird/filter6.conf";
46
+
47
+# Kernel routing tables
48
+########################
49
+
50
+
51
+/*
52
+ krt_prefsrc defines the source address for outgoing connections.
53
+ On Linux, this causes the "src" attribute of a route to be set.
54
+
55
+ Without this option outgoing connections would use the peering IP which
56
+ would cause packet loss if some peering disconnects but the interface
57
+ is still available. (The route would still exist and thus route through
58
+ the TUN/TAP interface but the VPN daemon would simply drop the packet.)
59
+*/
60
+protocol kernel {
61
+ scan time 20;
62
+ import none;
63
+ export filter {
64
+ if source = RTS_STATIC then reject;
65
+ krt_prefsrc = OWNIP;
66
+ accept;
67
+ };
68
+}
69
+
70
+# static routes
71
+################
72
+
73
+protocol static {
74
+ route <SUBNET> reject;
75
+ import all;
76
+ export none;
77
+}
78
+
79
+template bgp dnpeers {
80
+ local as OWNAS;
81
+ path metric 1;
82
+ import keep filtered;
83
+ import filter {
84
+ if is_valid_network() && !is_self_net() then {
85
+ accept;
86
+ }
87
+ reject;
88
+ };
89
+ export filter {
90
+ if is_valid_network() && source ~ [RTS_STATIC, RTS_BGP] then {
91
+ accept;
92
+ }
93
+ reject;
94
+ };
95
+ import limit 1000 action block;
96
+}
97
+
98
+include "/etc/bird/peers6/*";
99
+```
100
+
101
+```conf
102
+# /etc/bird/local6.conf
103
+# should be a unique identifier, use same id as for ipv4
104
+router id <GATEWAY_IP>;
105
+
106
+define OWNAS = <AS>;
107
+define OWNIP = <GATEWAY_IP>;
108
+
109
+function is_self_net() {
110
+ return net ~ [<SUBNET>+];
111
+}
112
+
113
+function is_valid_network() {
114
+ return net ~ [
115
+ fd00::/8{44,64} # ULA address space as per RFC 4193
116
+ ];
117
+}
118
+```
119
+
120
+```conf
121
+# /etc/bird/peers6/<PEER_NAME>
122
+protocol bgp <PEER_NAME> from dnpeers {
123
+ neighbor <PEERING_IP> as <PEER_AS>;
124
+ # if you use link-local ipv6 addresses for peering using the following
125
+ # neighbor <PEERING_IP> % '<INTERFACE_NAME>' as <PEER_AS>;
126
+};
127
+```
128
+
129
+### IPv4
130
+
131
+```conf
132
+# /etc/bird/bird.conf
133
+# Device status
134
+protocol device {
135
+ scan time 10; # recheck every 10 seconds
136
+}
137
+
138
+protocol static {
139
+ # Static routes to announce your own range(s) in dn42
140
+ route <SUBNET> reject;
141
+ import all;
142
+ export none;
143
+};
144
+
145
+# local configuration
146
+######################
147
+
148
+# keeping router specific in a seperate file,
149
+# so this configuration can be reused on multiple routers in your network
150
+include "/etc/bird/local4.conf";
151
+
152
+# filter helpers
153
+#################
154
+
155
+##include "/etc/bird/filter4.conf";
156
+
157
+# Kernel routing tables
158
+########################
159
+
160
+/*
161
+ krt_prefsrc defines the source address for outgoing connections.
162
+ On Linux, this causes the "src" attribute of a route to be set.
163
+
164
+ Without this option outgoing connections would use the peering IP which
165
+ would cause packet loss if some peering disconnects but the interface
166
+ is still available. (The route would still exist and thus route through
167
+ the TUN/TAP interface but the VPN daemon would simply drop the packet.)
168
+*/
169
+protocol kernel {
170
+ scan time 20;
171
+ import none;
172
+ export filter {
173
+ if source = RTS_STATIC then reject;
174
+ krt_prefsrc = OWNIP;
175
+ accept;
176
+ };
177
+};
178
+# DN42
179
+#######
180
+
181
+template bgp dnpeers {
182
+ local as OWNAS;
183
+ # metric is the number of hops between us and the peer
184
+ path metric 1;
185
+ # this lines allows debugging filter rules
186
+ # filtered routes can be looked up in birdc using the "show route filtered" command
187
+ import keep filtered;
188
+ import filter {
189
+ # accept every subnet, except our own advertised subnet
190
+ # filtering is important, because some guys try to advertise routes like 0.0.0.0
191
+ if is_valid_network() && !is_self_net() then {
192
+ accept;
193
+ }
194
+ reject;
195
+ };
196
+ export filter {
197
+ # here we export the whole net
198
+ if is_valid_network() && source ~ [RTS_STATIC, RTS_BGP] then {
199
+ accept;
200
+ }
201
+ reject;
202
+ };
203
+ import limit 1000 action block;
204
+ #source address OWNIP;
205
+};
206
+
207
+include "/etc/bird/peers4/*";
208
+```
209
+
210
+```conf
211
+#/etc/bird/local4.conf
212
+# should be a unique identifier, <GATEWAY_IP> is what most people use.
213
+router id <GATEWAY_IP>;
214
+
215
+define OWNAS = <AS>;
216
+define OWNIP = <GATEWAY_IP>;
217
+
218
+function is_self_net() {
219
+ return net ~ [<SUBNET>+];
220
+}
221
+
222
+function is_valid_network() {
223
+ return net ~ [
224
+ 172.20.0.0/14{21,29}, # dn42
225
+ 172.20.0.0/24{28,32}, # dn42 Anycast
226
+ 172.21.0.0/24{28,32}, # dn42 Anycast
227
+ 172.22.0.0/24{28,32}, # dn42 Anycast
228
+ 172.23.0.0/24{28,32}, # dn42 Anycast
229
+ 172.31.0.0/16+, # ChaosVPN
230
+ 10.100.0.0/14+, # ChaosVPN
231
+ 10.127.0.0/16{16,32}, # neonetwork
232
+ 10.0.0.0/8{15,24} # Freifunk.net
233
+ ];
234
+}
235
+```
236
+
237
+```conf
238
+# /etc/bird/peers4/<PEER_NAME>
239
+protocol bgp <PEER_NAME> from dnpeers {
240
+ neighbor <PEERING_IP> as <PEER_AS>;
241
+};
242
+```
243
+
244
+# Bird communities
245
+
246
+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. It is really easy to get started with communities and we encourage all of you to get the basic configuration done and to mark your peerings with the correct flags for improved routing.
247
+More information can be found [here](/howto/BGP-communities).
248
+
249
+# Route Origin Authorization
250
+
251
+Route Origin Authorizations should be used in BIRD to authenticate prefix announcements. These check the originating AS and validate that they are allowed to advertise a prefix.
252
+
253
+## ROA Tables
254
+
255
+The ROA table can be generated from the registry directly or you can use the following pre-built ROA tables for BIRD:
256
+
257
+ROA files generated by [dn42regsrv](https://git.burble.com/burble.dn42/dn42regsrv) are available from burble.dn42:
258
+
259
+|URL|&nbsp;IPv4/IPv6&nbsp;|Description|
260
+|---|---|---|
261
+| <https://dn42.burble.com/roa/dn42_roa_46.json> &nbsp; | &nbsp;Both&nbsp; | JSON format for use with RPKI |
262
+| <https://dn42.burble.com/roa/dn42_roa_bird1_46.conf> &nbsp; | &nbsp;Both&nbsp; | Bird1 format |
263
+| <https://dn42.burble.com/roa/dn42_roa_bird1_4.conf> &nbsp; | &nbsp;IPv4 Only&nbsp; | Bird1 format |
264
+| <https://dn42.burble.com/roa/dn42_roa_bird1_6.conf> &nbsp; | &nbsp;IPv6 Only&nbsp; | Bird1 format |
265
+| <https://dn42.burble.com/roa/dn42_roa_bird2_46.conf> &nbsp; | &nbsp;Both&nbsp; | Bird2 format |
266
+| <https://dn42.burble.com/roa/dn42_roa_bird2_4.conf> &nbsp; | &nbsp;IPv4 Only&nbsp; | Bird2 format |
267
+| <https://dn42.burble.com/roa/dn42_roa_bird2_6.conf> &nbsp; | &nbsp;IPv6 Only&nbsp; | Bird2 format |
268
+
269
+ROA files generated by [roa_wizard](https://git.dn42.dev/Kioubit/roa_wizard) are available:
270
+
271
+|URL|&nbsp;IPv4/IPv6&nbsp;|Description|
272
+|---|---|---|
273
+| <https://kioubit-roa.dn42.dev/?type=v4> &nbsp; | &nbsp;IPv4 Only&nbsp; | Bird2 format |
274
+| <https://kioubit-roa.dn42.dev/?type=v6> &nbsp; | &nbsp;IPv6 Only&nbsp; | Bird2 format |
275
+| <https://kioubit-roa.dn42.dev/?type=json> &nbsp; | &nbsp;Both&nbsp; | JSON format for use with RPKI |
276
+
277
+### Updating ROA tables
278
+
279
+You can add cron entries to periodically update the tables:
280
+
281
+```conf
282
+*/15 * * * * curl -sfSLR {-o,-z}/var/lib/bird/bird6_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_6.conf && chronic birdc6 configure
283
+*/15 * * * * curl -sfSLR {-o,-z}/var/lib/bird/bird_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_4.conf && chronic birdc configure
284
+```
285
+
286
+Debian version:
287
+
288
+```conf
289
+*/15 * * * * curl -sfSLR -o/var/lib/bird/bird6_roa_dn42.conf -z/var/lib/bird/bird6_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_6.conf && /usr/sbin/birdc6 configure
290
+*/15 * * * * curl -sfSLR -o/var/lib/bird/bird_roa_dn42.conf -z/var/lib/bird/bird_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_4.conf && /usr/sbin/birdc configure
291
+```
292
+
293
+then create the directory to make sure curls can save the files:
294
+
295
+```sh
296
+mkdir -p /var/lib/bird/
297
+```
298
+
299
+Or use a systemd timer: (check the commands before copy-pasting)
300
+
301
+```conf
302
+# /etc/systemd/system/dn42-roa.service
303
+[Unit]
304
+Description=Update DN42 ROA
305
+
306
+[Service]
307
+Type=oneshot
308
+ExecStart=curl -sfSLR -o /etc/bird/roa_dn42.conf -z /etc/bird/roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird2_4.conf
309
+ExecStart=curl -sfSLR -o /etc/bird/roa_dn42_v6.conf -z /etc/bird/roa_dn42_v6.conf https://dn42.burble.com/roa/dn42_roa_bird2_6.conf
310
+ExecStart=birdc configure
311
+```
312
+
313
+```conf
314
+# /etc/systemd/system/dn42-roa.timer
315
+[Unit]
316
+Description=Update DN42 ROA periodically
317
+
318
+[Timer]
319
+OnBootSec=2m
320
+OnUnitActiveSec=15m
321
+AccuracySec=1m
322
+
323
+[Install]
324
+WantedBy=timers.target
325
+```
326
+
327
+then enable and start the timer with `systemctl enable --now dn42-roa.timer`.
328
+
329
+More advanced script with error checking:
330
+```sh
331
+#!/bin/bash
332
+roa4URL=""
333
+roa6URL=""
334
+
335
+roa4FILE="/etc/bird/roa/roa_dn42.conf"
336
+roa6FILE="/etc/bird/roa/roa_dn42_v6.conf"
337
+
338
+cp "${roa4FILE}" "${roa4FILE}.old"
339
+cp "${roa6FILE}" "${roa6FILE}.old"
340
+
341
+if curl -f -o "${roa4FILE}.new" "${roa4URL};" ;then
342
+ mv "${roa4FILE}.new" "${roa4FILE}"
343
+fi
344
+
345
+if curl -f -o "${roa6FILE}.new" "${roa6URL};" ;then
346
+ mv "${roa6FILE}.new" "${roa6FILE}"
347
+fi
348
+
349
+if birdc configure ; then
350
+ rm "${roa4FILE}.old"
351
+ rm "${roa6FILE}.old"
352
+else
353
+ mv "${roa4FILE}.old" "${roa4FILE}"
354
+ mv "${roa6FILE}.old" "${roa6FILE}"
355
+fi
356
+```
357
+
358
+
359
+### Use RPKI ROA in bird2
360
+
361
+* Download gortr
362
+
363
+<https://github.com/cloudflare/gortr/releases>
364
+
365
+* Run gortr.
366
+
367
+```sh
368
+./gortr -verify=false -checktime=false -cache=https://dn42.burble.com/roa/dn42_roa_46.json
369
+```
370
+
371
+
372
+* Run with docker
373
+
374
+```sh
375
+docker pull cloudflare/gortr
376
+```
377
+
378
+```sh
379
+docker run --name dn42rpki -p 8282:8282 --restart=always -d cloudflare/gortr -verify=false -checktime=false -cache=https://dn42.burble.com/roa/dn42_roa_46.json
380
+```
381
+
382
+* Add this to your bird configure file,other ROA protocol must removed.
383
+
384
+```conf
385
+protocol rpki rpki_dn42{
386
+ roa4 { table dn42_roa; };
387
+ roa6 { table dn42_roa_v6; };
388
+
389
+ remote "<your rpki server ip or domain>" port 8282;
390
+
391
+ retry keep 90;
392
+ refresh keep 900;
393
+ expire keep 172800;
394
+}
395
+```
396
+
397
+## Filter configuration
398
+
399
+In your import filter add the following to reject invalid routes:
400
+
401
+```conf
402
+if (roa_check(dn42_roa, net, bgp_path.last) != ROA_VALID) then {
403
+ print "[dn42] ROA check failed for ", net, " ASN ", bgp_path.last;
404
+ reject;
405
+}
406
+```
407
+
408
+Also, define your ROA table with:
409
+
410
+```conf
411
+roa table dn42_roa {
412
+ include "/var/lib/bird/bird_roa_dn42.conf";
413
+};
414
+```
415
+
416
+
417
+**NOTE**: Make sure you setup ROA checks for both bird and bird6 (for IPv6).
418
+
419
+# Useful bird commmands
420
+
421
+bird can be remote controlled via the `birdc` command. Here is a list of useful bird commands:
422
+
423
+```sh
424
+$ birdc
425
+BIRD 1.4.5 ready.
426
+bird> configure # reload configuration
427
+Reading configuration from /etc/bird.conf
428
+Reconfigured
429
+bird> show ? # Completions work either by pressing tab or pressing '?'
430
+show bfd ... Show information about BFD protocol
431
+show interfaces Show network interfaces
432
+show memory Show memory usage
433
+show ospf ... Show information about OSPF protocol
434
+show protocols [<protocol> | "<pattern>"] Show routing protocols
435
+show roa ... Show ROA table
436
+show route ... Show routing table
437
+show static [<name>] Show details of static protocol
438
+show status Show router status
439
+show symbols ... Show all known symbolic names
440
+bird> show protocols # this command shows your peering status
441
+name proto table state since info
442
+device1 Device master up 07:20:25
443
+kernel1 Kernel master up 07:20:25
444
+chelnok BGP master up 07:20:29 Established
445
+hax404 BGP master up 07:20:26 Established
446
+static1 Static master up 07:20:25
447
+bird> show protocols all chelnok # show verbose peering status for peering with chelnok
448
+bird> show route for 172.22.141.181 # show possible routes to internal.dn42
449
+172.22.141.0/24 via 172.23.67.1 on tobee [tobee 07:20:30] * (100) [AS64737i]
450
+ via 172.23.64.1 on chelnok [chelnok 07:20:29] (100) [AS64737i]
451
+ via 172.23.136.65 on hax404 [hax404 07:20:26] (100) [AS64737i]
452
+bird> show route filtered # shows routed filtered out by rules
453
+172.23.245.1/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS76175i]
454
+172.22.247.128/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS76175i]
455
+172.22.227.1/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS76115i]
456
+172.23.196.75/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS76115i]
457
+172.22.41.241/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS76115i]
458
+172.22.249.4/30 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS4242420002i]
459
+172.22.255.133/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS64654i]
460
+bird> show route protocol <somepeer> # shows the route they export to you
461
+bird> show route export <somepeer> # shows the route you export to someone
462
+...
463
+```
464
+
465
+# External Links
466
+* detailed bird configuration from Mic92: <https://github.com/Mic92/bird-dn42>
467
+* more bird commands: <https://bird.network.cz/?get_doc&v=20&f=bird-4.html>
howto/BGP-communities.md
... ...
@@ -0,0 +1,211 @@
1
+Bird is a commonly used BGP daemon. This page provides configuration and help for using BGP communities with Bird for dn42.
2
+
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
+
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 guide.
6
+
7
+The filter helpers can be stored in a separate file, for example /etc/bird/community_filters.conf.
8
+
9
+Below, you will see an example config for peers4 based on the original filter implementation by Jplitza.
10
+
11
+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.
12
+
13
+## BGP community criteria
14
+```conf
15
+(64511, 1) :: latency \in (0, 2.7ms]
16
+(64511, 2) :: latency \in (2.7ms, 7.3ms]
17
+(64511, 3) :: latency \in (7.3ms, 20ms]
18
+(64511, 4) :: latency \in (20ms, 55ms]
19
+(64511, 5) :: latency \in (55ms, 148ms]
20
+(64511, 6) :: latency \in (148ms, 403ms]
21
+(64511, 7) :: latency \in (403ms, 1097ms]
22
+(64511, 8) :: latency \in (1097ms, 2981ms]
23
+(64511, 9) :: latency > 2981ms
24
+(64511, x) :: latency \in [exp(x-1), exp(x)] ms (for x < 10)
25
+
26
+(64511, 21) :: bw >= 0.1mbit
27
+(64511, 22) :: bw >= 1mbit
28
+(64511, 23) :: bw >= 10mbit
29
+(64511, 24) :: bw >= 100mbit
30
+(64511, 25) :: bw >= 1000mbit
31
+(64511, 2x) :: bw >= 10^(x-2) mbit
32
+bw = min(up,down) for asymmetric connections
33
+
34
+(64511, 31) :: not encrypted
35
+(64511, 32) :: encrypted with unsafe vpn solution
36
+(64511, 33) :: encrypted with safe vpn solution (but no PFS - the usual OpenVPN p2p configuration falls in this category)
37
+(64511, 34) :: encrypted with safe vpn solution with PFS (Perfect Forward Secrecy)
38
+
39
+Propagation:
40
+- - for latency pick max(received_route.latency, link_latency)
41
+- - for encryption and bandwidth pick min between received BGP community and peer link
42
+```
43
+For example, if your peer is 12ms away and the link speed between you is 250Mbit/s and you are peering using OpenVPN P2P, then the community string would be (3, 24, 33).
44
+
45
+Two utilities which measure round trip time and calculate community values automatically are provided, written in [ruby](https://github.com/Mic92/bird-dn42/blob/master/bgp-community.rb) and [C](https://github.com/nixnodes/bird/blob/master/misc/dn42-comgen.c).
46
+
47
+**Note: In general, the link latency metric only reflects the latency of the *immediate* link, and not the overall latency from following a path**. A route may traverse multiple internal routers once it enters an AS, and because this is invisible to BGP, it's best to treat latency values as informational only and not use them to make routing decisions.
48
+
49
+```sh
50
+$ ruby bgp-community.rb --help
51
+USAGE: bgp-community.rb host mbit_speed unencrypted|unsafe|encrypted|pfs
52
+ -6, --ipv6 Assume ipv6 for ping
53
+$ ruby bgp-community.rb 212.129.13.123 300 encrypted
54
+ # 15 ms, 300 mbit/s, encrypted tunnel (updated: 2016-02-11)
55
+ import where dn42_import_filter(3,24,33);
56
+ export where dn42_export_filter(3,24,33);
57
+$ ruby bgp-community.rb -6 dn42-2.higgsboson.tk 1000 pfs
58
+ # 11 ms, 1000 mbit/s, pfs tunnel (updated: 2016-02-11)
59
+ import where dn42_import_filter(3,25,34);
60
+ export where dn42_export_filter(3,25,34);
61
+```
62
+
63
+### Route Origin
64
+There are two type of route origin: `region` and `country`
65
+
66
+#### Region
67
+The range `41-70` is assigned to the region property.
68
+The communities for route origin region were first defined in [December 2015](https://lists.nox.tf/pipermail/dn42/2015-December/001259.html) and further extended in [May 2022](https://groups.io/g/dn42/topic/91226190):
69
+
70
+```conf
71
+(64511, 41) :: Europe
72
+(64511, 42) :: North America-E
73
+(64511, 43) :: North America-C
74
+(64511, 44) :: North America-W
75
+(64511, 45) :: Central America
76
+(64511, 46) :: South America-E
77
+(64511, 47) :: South America-W
78
+(64511, 48) :: Africa-N (above Sahara)
79
+(64511, 49) :: Africa-S (below Sahara)
80
+(64511, 50) :: Asia-S (IN,PK,BD)
81
+(64511, 51) :: Asia-SE (TH,SG,PH,ID,MY)
82
+(64511, 52) :: Asia-E (JP,CN,KR,TW,HK)
83
+(64511, 53) :: Pacific&Oceania (AU,NZ,FJ)
84
+(64511, 54) :: Antarctica
85
+(64511, 55) :: Asia-N (RU)
86
+(64511, 56) :: Asia-W (IR,TR,UAE)
87
+(64511, 57) :: Central Asia (AF,UZ,KZ)
88
+```
89
+
90
+#### Country
91
+The range `1000-1999` is assigned to the country property. Here we use [ISO-3166-1 numeric](https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.csv) country codes, adding `1000` to each value to get the country origin community:
92
+
93
+```conf
94
+(64511, 1124) :: Canada
95
+(64511, 1156) :: China
96
+(64511, 1158) :: Taiwan
97
+(64511, 1250) :: France
98
+(64511, 1276) :: Germany
99
+(64511, 1344) :: Hong Kong
100
+(64511, 1392) :: Japan
101
+(64511, 1528) :: Netherlands
102
+(64511, 1578) :: Norway
103
+(64511, 1643) :: Russian Federation
104
+(64511, 1702) :: Singapore
105
+(64511, 1756) :: Switzerland
106
+(64511, 1826) :: United Kingdom
107
+(64511, 1840) :: United States of America
108
+```
109
+etc. Please follow the ISO-3166-1 Numeric standard
110
+<https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.csv>.
111
+
112
+You need to add following lines to your config(s):
113
+- `define DN42_REGION = $VALUE_FROM_ABOVE` to your node's config (where OWNAS and OWNIP are set)
114
+- `if source = RTS_STATIC then bgp_community.add((64511, DN42_REGION));`
115
+just above `update_flags` in `dn42_export_filter` function
116
+- Unlike the other community values, **the DN42_REGION community should only be set on routes originating from your network!** (This is what the `source = RTS_STATIC` check does).
117
+ - Otherwise, if you export routes across multiple regions within your network, you may be sending incorrect origin information to other peers.
118
+
119
+
120
+## Example configurations
121
+```conf
122
+# /etc/bird/peers4/tombii.conf
123
+protocol bgp tombii from dnpeers {
124
+ neighbor 172.23.102.x as 4242420321;
125
+ import where dn42_import_filter(3,24,33);
126
+ export where dn42_export_filter(3,24,33);
127
+};
128
+```
129
+```conf
130
+#/etc/bird/community_filters.conf
131
+function update_latency(int link_latency) {
132
+ bgp_community.add((64511, link_latency));
133
+ if (64511, 9) ~ bgp_community then { bgp_community.delete([(64511, 1..8)]); return 9; }
134
+ else if (64511, 8) ~ bgp_community then { bgp_community.delete([(64511, 1..7)]); return 8; }
135
+ else if (64511, 7) ~ bgp_community then { bgp_community.delete([(64511, 1..6)]); return 7; }
136
+ else if (64511, 6) ~ bgp_community then { bgp_community.delete([(64511, 1..5)]); return 6; }
137
+ else if (64511, 5) ~ bgp_community then { bgp_community.delete([(64511, 1..4)]); return 5; }
138
+ else if (64511, 4) ~ bgp_community then { bgp_community.delete([(64511, 1..3)]); return 4; }
139
+ else if (64511, 3) ~ bgp_community then { bgp_community.delete([(64511, 1..2)]); return 3; }
140
+ else if (64511, 2) ~ bgp_community then { bgp_community.delete([(64511, 1..1)]); return 2; }
141
+ else return 1;
142
+}
143
+
144
+function update_bandwidth(int link_bandwidth) {
145
+ bgp_community.add((64511, link_bandwidth));
146
+ if (64511, 21) ~ bgp_community then { bgp_community.delete([(64511, 22..29)]); return 21; }
147
+ else if (64511, 22) ~ bgp_community then { bgp_community.delete([(64511, 23..29)]); return 22; }
148
+ else if (64511, 23) ~ bgp_community then { bgp_community.delete([(64511, 24..29)]); return 23; }
149
+ else if (64511, 24) ~ bgp_community then { bgp_community.delete([(64511, 25..29)]); return 24; }
150
+ else if (64511, 25) ~ bgp_community then { bgp_community.delete([(64511, 26..29)]); return 25; }
151
+ else if (64511, 26) ~ bgp_community then { bgp_community.delete([(64511, 27..29)]); return 26; }
152
+ else if (64511, 27) ~ bgp_community then { bgp_community.delete([(64511, 28..29)]); return 27; }
153
+ else if (64511, 28) ~ bgp_community then { bgp_community.delete([(64511, 29..29)]); return 28; }
154
+ else return 29;
155
+}
156
+
157
+function update_crypto(int link_crypto) {
158
+ bgp_community.add((64511, link_crypto));
159
+ if (64511, 31) ~ bgp_community then { bgp_community.delete([(64511, 32..34)]); return 31; }
160
+ else if (64511, 32) ~ bgp_community then { bgp_community.delete([(64511, 33..34)]); return 32; }
161
+ else if (64511, 33) ~ bgp_community then { bgp_community.delete([(64511, 34..34)]); return 33; }
162
+ else return 34;
163
+}
164
+
165
+function update_flags(int link_latency; int link_bandwidth; int link_crypto)
166
+int dn42_latency;
167
+int dn42_bandwidth;
168
+int dn42_crypto;
169
+{
170
+ dn42_latency = update_latency(link_latency);
171
+ dn42_bandwidth = update_bandwidth(link_bandwidth) - 20;
172
+ dn42_crypto = update_crypto(link_crypto) - 30;
173
+ # replace 4 with your calculated bandwidth value
174
+ if dn42_bandwidth > 4 then dn42_bandwidth = 4;
175
+ return true;
176
+}
177
+
178
+# Combines filter from local4.conf/local6.conf and filter4.conf/filter6.conf,
179
+# which means, these must included before this file
180
+
181
+function dn42_import_filter(int link_latency; int link_bandwidth; int link_crypto) {
182
+ if is_valid_network() && !is_self_net() then {
183
+ update_flags(link_latency, link_bandwidth, link_crypto);
184
+ accept;
185
+ }
186
+ reject;
187
+}
188
+
189
+function dn42_export_filter(int link_latency; int link_bandwidth; int link_crypto) {
190
+ if is_valid_network() then {
191
+ update_flags(link_latency, link_bandwidth, link_crypto);
192
+ accept;
193
+ }
194
+ reject;
195
+}
196
+```
197
+Please remember to include /etc/bird/community_filters.conf in your bird.conf/birdc6.conf
198
+```conf
199
+# local configuration
200
+######################
201
+include "bird/local4.conf";
202
+
203
+# filter helpers
204
+#################
205
+
206
+include "/etc/bird/filter4.conf";
207
+include "/etc/bird/community_filters.conf";
208
+```
209
+
210
+
211
+***
howto/Bird-communities.md
... ...
@@ -1,211 +0,0 @@
1
-Bird is a commonly used BGP daemon. This page provides configuration and help for using BGP communities with Bird for dn42.
2
-
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
-
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 guide.
6
-
7
-The filter helpers can be stored in a separate file, for example /etc/bird/community_filters.conf.
8
-
9
-Below, you will see an example config for peers4 based on the original filter implementation by Jplitza.
10
-
11
-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.
12
-
13
-## BGP community criteria
14
-```conf
15
-(64511, 1) :: latency \in (0, 2.7ms]
16
-(64511, 2) :: latency \in (2.7ms, 7.3ms]
17
-(64511, 3) :: latency \in (7.3ms, 20ms]
18
-(64511, 4) :: latency \in (20ms, 55ms]
19
-(64511, 5) :: latency \in (55ms, 148ms]
20
-(64511, 6) :: latency \in (148ms, 403ms]
21
-(64511, 7) :: latency \in (403ms, 1097ms]
22
-(64511, 8) :: latency \in (1097ms, 2981ms]
23
-(64511, 9) :: latency > 2981ms
24
-(64511, x) :: latency \in [exp(x-1), exp(x)] ms (for x < 10)
25
-
26
-(64511, 21) :: bw >= 0.1mbit
27
-(64511, 22) :: bw >= 1mbit
28
-(64511, 23) :: bw >= 10mbit
29
-(64511, 24) :: bw >= 100mbit
30
-(64511, 25) :: bw >= 1000mbit
31
-(64511, 2x) :: bw >= 10^(x-2) mbit
32
-bw = min(up,down) for asymmetric connections
33
-
34
-(64511, 31) :: not encrypted
35
-(64511, 32) :: encrypted with unsafe vpn solution
36
-(64511, 33) :: encrypted with safe vpn solution (but no PFS - the usual OpenVPN p2p configuration falls in this category)
37
-(64511, 34) :: encrypted with safe vpn solution with PFS (Perfect Forward Secrecy)
38
-
39
-Propagation:
40
-- - for latency pick max(received_route.latency, link_latency)
41
-- - for encryption and bandwidth pick min between received BGP community and peer link
42
-```
43
-For example, if your peer is 12ms away and the link speed between you is 250Mbit/s and you are peering using OpenVPN P2P, then the community string would be (3, 24, 33).
44
-
45
-Two utilities which measure round trip time and calculate community values automatically are provided, written in [ruby](https://github.com/Mic92/bird-dn42/blob/master/bgp-community.rb) and [C](https://github.com/nixnodes/bird/blob/master/misc/dn42-comgen.c).
46
-
47
-**Note: In general, the link latency metric only reflects the latency of the *immediate* link, and not the overall latency from following a path**. A route may traverse multiple internal routers once it enters an AS, and because this is invisible to BGP, it's best to treat latency values as informational only and not use them to make routing decisions.
48
-
49
-```sh
50
-$ ruby bgp-community.rb --help
51
-USAGE: bgp-community.rb host mbit_speed unencrypted|unsafe|encrypted|pfs
52
- -6, --ipv6 Assume ipv6 for ping
53
-$ ruby bgp-community.rb 212.129.13.123 300 encrypted
54
- # 15 ms, 300 mbit/s, encrypted tunnel (updated: 2016-02-11)
55
- import where dn42_import_filter(3,24,33);
56
- export where dn42_export_filter(3,24,33);
57
-$ ruby bgp-community.rb -6 dn42-2.higgsboson.tk 1000 pfs
58
- # 11 ms, 1000 mbit/s, pfs tunnel (updated: 2016-02-11)
59
- import where dn42_import_filter(3,25,34);
60
- export where dn42_export_filter(3,25,34);
61
-```
62
-
63
-### Route Origin
64
-There are two type of route origin: `region` and `country`
65
-
66
-#### Region
67
-The range `41-70` is assigned to the region property.
68
-The communities for route origin region were first defined in [December 2015](https://lists.nox.tf/pipermail/dn42/2015-December/001259.html) and further extended in [May 2022](https://groups.io/g/dn42/topic/91226190):
69
-
70
-```conf
71
-(64511, 41) :: Europe
72
-(64511, 42) :: North America-E
73
-(64511, 43) :: North America-C
74
-(64511, 44) :: North America-W
75
-(64511, 45) :: Central America
76
-(64511, 46) :: South America-E
77
-(64511, 47) :: South America-W
78
-(64511, 48) :: Africa-N (above Sahara)
79
-(64511, 49) :: Africa-S (below Sahara)
80
-(64511, 50) :: Asia-S (IN,PK,BD)
81
-(64511, 51) :: Asia-SE (TH,SG,PH,ID,MY)
82
-(64511, 52) :: Asia-E (JP,CN,KR,TW,HK)
83
-(64511, 53) :: Pacific&Oceania (AU,NZ,FJ)
84
-(64511, 54) :: Antarctica
85
-(64511, 55) :: Asia-N (RU)
86
-(64511, 56) :: Asia-W (IR,TR,UAE)
87
-(64511, 57) :: Central Asia (AF,UZ,KZ)
88
-```
89
-
90
-#### Country
91
-The range `1000-1999` is assigned to the country property. Here we use [ISO-3166-1 numeric](https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.csv) country codes, adding `1000` to each value to get the country origin community:
92
-
93
-```conf
94
-(64511, 1124) :: Canada
95
-(64511, 1156) :: China
96
-(64511, 1158) :: Taiwan
97
-(64511, 1250) :: France
98
-(64511, 1276) :: Germany
99
-(64511, 1344) :: Hong Kong
100
-(64511, 1392) :: Japan
101
-(64511, 1528) :: Netherlands
102
-(64511, 1578) :: Norway
103
-(64511, 1643) :: Russian Federation
104
-(64511, 1702) :: Singapore
105
-(64511, 1756) :: Switzerland
106
-(64511, 1826) :: United Kingdom
107
-(64511, 1840) :: United States of America
108
-```
109
-etc. Please follow the ISO-3166-1 Numeric standard
110
-<https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.csv>.
111
-
112
-You need to add following lines to your config(s):
113
-- `define DN42_REGION = $VALUE_FROM_ABOVE` to your node's config (where OWNAS and OWNIP are set)
114
-- `if source = RTS_STATIC then bgp_community.add((64511, DN42_REGION));`
115
-just above `update_flags` in `dn42_export_filter` function
116
-- Unlike the other community values, **the DN42_REGION community should only be set on routes originating from your network!** (This is what the `source = RTS_STATIC` check does).
117
- - Otherwise, if you export routes across multiple regions within your network, you may be sending incorrect origin information to other peers.
118
-
119
-
120
-## Example configurations
121
-```conf
122
-# /etc/bird/peers4/tombii.conf
123
-protocol bgp tombii from dnpeers {
124
- neighbor 172.23.102.x as 4242420321;
125
- import where dn42_import_filter(3,24,33);
126
- export where dn42_export_filter(3,24,33);
127
-};
128
-```
129
-```conf
130
-#/etc/bird/community_filters.conf
131
-function update_latency(int link_latency) {
132
- bgp_community.add((64511, link_latency));
133
- if (64511, 9) ~ bgp_community then { bgp_community.delete([(64511, 1..8)]); return 9; }
134
- else if (64511, 8) ~ bgp_community then { bgp_community.delete([(64511, 1..7)]); return 8; }
135
- else if (64511, 7) ~ bgp_community then { bgp_community.delete([(64511, 1..6)]); return 7; }
136
- else if (64511, 6) ~ bgp_community then { bgp_community.delete([(64511, 1..5)]); return 6; }
137
- else if (64511, 5) ~ bgp_community then { bgp_community.delete([(64511, 1..4)]); return 5; }
138
- else if (64511, 4) ~ bgp_community then { bgp_community.delete([(64511, 1..3)]); return 4; }
139
- else if (64511, 3) ~ bgp_community then { bgp_community.delete([(64511, 1..2)]); return 3; }
140
- else if (64511, 2) ~ bgp_community then { bgp_community.delete([(64511, 1..1)]); return 2; }
141
- else return 1;
142
-}
143
-
144
-function update_bandwidth(int link_bandwidth) {
145
- bgp_community.add((64511, link_bandwidth));
146
- if (64511, 21) ~ bgp_community then { bgp_community.delete([(64511, 22..29)]); return 21; }
147
- else if (64511, 22) ~ bgp_community then { bgp_community.delete([(64511, 23..29)]); return 22; }
148
- else if (64511, 23) ~ bgp_community then { bgp_community.delete([(64511, 24..29)]); return 23; }
149
- else if (64511, 24) ~ bgp_community then { bgp_community.delete([(64511, 25..29)]); return 24; }
150
- else if (64511, 25) ~ bgp_community then { bgp_community.delete([(64511, 26..29)]); return 25; }
151
- else if (64511, 26) ~ bgp_community then { bgp_community.delete([(64511, 27..29)]); return 26; }
152
- else if (64511, 27) ~ bgp_community then { bgp_community.delete([(64511, 28..29)]); return 27; }
153
- else if (64511, 28) ~ bgp_community then { bgp_community.delete([(64511, 29..29)]); return 28; }
154
- else return 29;
155
-}
156
-
157
-function update_crypto(int link_crypto) {
158
- bgp_community.add((64511, link_crypto));
159
- if (64511, 31) ~ bgp_community then { bgp_community.delete([(64511, 32..34)]); return 31; }
160
- else if (64511, 32) ~ bgp_community then { bgp_community.delete([(64511, 33..34)]); return 32; }
161
- else if (64511, 33) ~ bgp_community then { bgp_community.delete([(64511, 34..34)]); return 33; }
162
- else return 34;
163
-}
164
-
165
-function update_flags(int link_latency; int link_bandwidth; int link_crypto)
166
-int dn42_latency;
167
-int dn42_bandwidth;
168
-int dn42_crypto;
169
-{
170
- dn42_latency = update_latency(link_latency);
171
- dn42_bandwidth = update_bandwidth(link_bandwidth) - 20;
172
- dn42_crypto = update_crypto(link_crypto) - 30;
173
- # replace 4 with your calculated bandwidth value
174
- if dn42_bandwidth > 4 then dn42_bandwidth = 4;
175
- return true;
176
-}
177
-
178
-# Combines filter from local4.conf/local6.conf and filter4.conf/filter6.conf,
179
-# which means, these must included before this file
180
-
181
-function dn42_import_filter(int link_latency; int link_bandwidth; int link_crypto) {
182
- if is_valid_network() && !is_self_net() then {
183
- update_flags(link_latency, link_bandwidth, link_crypto);
184
- accept;
185
- }
186
- reject;
187
-}
188
-
189
-function dn42_export_filter(int link_latency; int link_bandwidth; int link_crypto) {
190
- if is_valid_network() then {
191
- update_flags(link_latency, link_bandwidth, link_crypto);
192
- accept;
193
- }
194
- reject;
195
-}
196
-```
197
-Please remember to include /etc/bird/community_filters.conf in your bird.conf/birdc6.conf
198
-```conf
199
-# local configuration
200
-######################
201
-include "bird/local4.conf";
202
-
203
-# filter helpers
204
-#################
205
-
206
-include "/etc/bird/filter4.conf";
207
-include "/etc/bird/community_filters.conf";
208
-```
209
-
210
-
211
-***
howto/Bird.md
... ...
@@ -1,467 +0,0 @@
1
-Bird is a commonly used BGP daemon. This page provides configuration and help to run Bird for dn42.
2
-Compared to quagga, bird supports multiple routing tables, which is useful, if you also plan to peer with other federated networks such as freifunk. In the following a working configuration for dn42 is shown. If you
3
-want to learn the practical details behind routing protocols in bird, see the following [guide](https://github.com/knorrie/network-examples)
4
-
5
-**Bird 1.6.x will be EOL by the end of 2023, it's recommended to upgrade to 2.13.**
6
-
7
-# Debian
8
-In the Debian release cycle the bird packages may become outdated at times, if that is the case you should use the official bird package repository maintained by the developers of nic.cz.
9
-
10
-This is not necessary for Debian Stretch, which currently ships the most recent version (1.6.3) in this repositories.
11
-
12
-```sh
13
-echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/buster-backports.list
14
-apt update
15
-apt install bird
16
-```
17
-
18
-# Example configuration
19
-
20
-Note: This file covers the configuration of Bird 1.x. For an example configuration of Bird 2.x see [howto/Bird2](/howto/Bird2)
21
-
22
-* Replace `<AS>` with your Autonomous System Number (only the digits)
23
-* Replace `<GATEWAY_IP>` with your gateway ip (the internal dn42 ip address you use on the host, where dn42 is running)
24
-* Replace `<SUBNET>` with your registered dn42 subnet
25
-* Replace `<PEER_IP>` with the ip of your peer who is connected with you using your favorite vpn protocol (openvpn, ipsec, tinc, ...)
26
-* Replace `<PEER_AS>` the Autonomous System Number of your peer (only the digits)
27
-* Replace `<PEER_NAME>` a self chosen name for your peer
28
-
29
-## IPv6
30
-
31
-```conf
32
-#/etc/bird/bird6.conf
33
-protocol device {
34
- scan time 10;
35
-}
36
-
37
-# local configuration
38
-######################
39
-
40
-include "/etc/bird/local6.conf";
41
-
42
-# filter helpers
43
-#################
44
-
45
-##include "/etc/bird/filter6.conf";
46
-
47
-# Kernel routing tables
48
-########################
49
-
50
-
51
-/*
52
- krt_prefsrc defines the source address for outgoing connections.
53
- On Linux, this causes the "src" attribute of a route to be set.
54
-
55
- Without this option outgoing connections would use the peering IP which
56
- would cause packet loss if some peering disconnects but the interface
57
- is still available. (The route would still exist and thus route through
58
- the TUN/TAP interface but the VPN daemon would simply drop the packet.)
59
-*/
60
-protocol kernel {
61
- scan time 20;
62
- import none;
63
- export filter {
64
- if source = RTS_STATIC then reject;
65
- krt_prefsrc = OWNIP;
66
- accept;
67
- };
68
-}
69
-
70
-# static routes
71
-################
72
-
73
-protocol static {
74
- route <SUBNET> reject;
75
- import all;
76
- export none;
77
-}
78
-
79
-template bgp dnpeers {
80
- local as OWNAS;
81
- path metric 1;
82
- import keep filtered;
83
- import filter {
84
- if is_valid_network() && !is_self_net() then {
85
- accept;
86
- }
87
- reject;
88
- };
89
- export filter {
90
- if is_valid_network() && source ~ [RTS_STATIC, RTS_BGP] then {
91
- accept;
92
- }
93
- reject;
94
- };
95
- import limit 1000 action block;
96
-}
97
-
98
-include "/etc/bird/peers6/*";
99
-```
100
-
101
-```conf
102
-# /etc/bird/local6.conf
103
-# should be a unique identifier, use same id as for ipv4
104
-router id <GATEWAY_IP>;
105
-
106
-define OWNAS = <AS>;
107
-define OWNIP = <GATEWAY_IP>;
108
-
109
-function is_self_net() {
110
- return net ~ [<SUBNET>+];
111
-}
112
-
113
-function is_valid_network() {
114
- return net ~ [
115
- fd00::/8{44,64} # ULA address space as per RFC 4193
116
- ];
117
-}
118
-```
119
-
120
-```conf
121
-# /etc/bird/peers6/<PEER_NAME>
122
-protocol bgp <PEER_NAME> from dnpeers {
123
- neighbor <PEERING_IP> as <PEER_AS>;
124
- # if you use link-local ipv6 addresses for peering using the following
125
- # neighbor <PEERING_IP> % '<INTERFACE_NAME>' as <PEER_AS>;
126
-};
127
-```
128
-
129
-### IPv4
130
-
131
-```conf
132
-# /etc/bird/bird.conf
133
-# Device status
134
-protocol device {
135
- scan time 10; # recheck every 10 seconds
136
-}
137
-
138
-protocol static {
139
- # Static routes to announce your own range(s) in dn42
140
- route <SUBNET> reject;
141
- import all;
142
- export none;
143
-};
144
-
145
-# local configuration
146
-######################
147
-
148
-# keeping router specific in a seperate file,
149
-# so this configuration can be reused on multiple routers in your network
150
-include "/etc/bird/local4.conf";
151
-
152
-# filter helpers
153
-#################
154
-
155
-##include "/etc/bird/filter4.conf";
156
-
157
-# Kernel routing tables
158
-########################
159
-
160
-/*
161
- krt_prefsrc defines the source address for outgoing connections.
162
- On Linux, this causes the "src" attribute of a route to be set.
163
-
164
- Without this option outgoing connections would use the peering IP which
165
- would cause packet loss if some peering disconnects but the interface
166
- is still available. (The route would still exist and thus route through
167
- the TUN/TAP interface but the VPN daemon would simply drop the packet.)
168
-*/
169
-protocol kernel {
170
- scan time 20;
171
- import none;
172
- export filter {
173
- if source = RTS_STATIC then reject;
174
- krt_prefsrc = OWNIP;
175
- accept;
176
- };
177
-};
178
-# DN42
179
-#######
180
-
181
-template bgp dnpeers {
182
- local as OWNAS;
183
- # metric is the number of hops between us and the peer
184
- path metric 1;
185
- # this lines allows debugging filter rules
186
- # filtered routes can be looked up in birdc using the "show route filtered" command
187
- import keep filtered;
188
- import filter {
189
- # accept every subnet, except our own advertised subnet
190
- # filtering is important, because some guys try to advertise routes like 0.0.0.0
191
- if is_valid_network() && !is_self_net() then {
192
- accept;
193
- }
194
- reject;
195
- };
196
- export filter {
197
- # here we export the whole net
198
- if is_valid_network() && source ~ [RTS_STATIC, RTS_BGP] then {
199
- accept;
200
- }
201
- reject;
202
- };
203
- import limit 1000 action block;
204
- #source address OWNIP;
205
-};
206
-
207
-include "/etc/bird/peers4/*";
208
-```
209
-
210
-```conf
211
-#/etc/bird/local4.conf
212
-# should be a unique identifier, <GATEWAY_IP> is what most people use.
213
-router id <GATEWAY_IP>;
214
-
215
-define OWNAS = <AS>;
216
-define OWNIP = <GATEWAY_IP>;
217
-
218
-function is_self_net() {
219
- return net ~ [<SUBNET>+];
220
-}
221
-
222
-function is_valid_network() {
223
- return net ~ [
224
- 172.20.0.0/14{21,29}, # dn42
225
- 172.20.0.0/24{28,32}, # dn42 Anycast
226
- 172.21.0.0/24{28,32}, # dn42 Anycast
227
- 172.22.0.0/24{28,32}, # dn42 Anycast
228
- 172.23.0.0/24{28,32}, # dn42 Anycast
229
- 172.31.0.0/16+, # ChaosVPN
230
- 10.100.0.0/14+, # ChaosVPN
231
- 10.127.0.0/16{16,32}, # neonetwork
232
- 10.0.0.0/8{15,24} # Freifunk.net
233
- ];
234
-}
235
-```
236
-
237
-```conf
238
-# /etc/bird/peers4/<PEER_NAME>
239
-protocol bgp <PEER_NAME> from dnpeers {
240
- neighbor <PEERING_IP> as <PEER_AS>;
241
-};
242
-```
243
-
244
-# Bird communities
245
-
246
-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. It is really easy to get started with communities and we encourage all of you to get the basic configuration done and to mark your peerings with the correct flags for improved routing.
247
-More information can be found [here](/howto/Bird-communities).
248
-
249
-# Route Origin Authorization
250
-
251
-Route Origin Authorizations should be used in BIRD to authenticate prefix announcements. These check the originating AS and validate that they are allowed to advertise a prefix.
252
-
253
-## ROA Tables
254
-
255
-The ROA table can be generated from the registry directly or you can use the following pre-built ROA tables for BIRD:
256
-
257
-ROA files generated by [dn42regsrv](https://git.burble.com/burble.dn42/dn42regsrv) are available from burble.dn42:
258
-
259
-|URL|&nbsp;IPv4/IPv6&nbsp;|Description|
260
-|---|---|---|
261
-| <https://dn42.burble.com/roa/dn42_roa_46.json> &nbsp; | &nbsp;Both&nbsp; | JSON format for use with RPKI |
262
-| <https://dn42.burble.com/roa/dn42_roa_bird1_46.conf> &nbsp; | &nbsp;Both&nbsp; | Bird1 format |
263
-| <https://dn42.burble.com/roa/dn42_roa_bird1_4.conf> &nbsp; | &nbsp;IPv4 Only&nbsp; | Bird1 format |
264
-| <https://dn42.burble.com/roa/dn42_roa_bird1_6.conf> &nbsp; | &nbsp;IPv6 Only&nbsp; | Bird1 format |
265
-| <https://dn42.burble.com/roa/dn42_roa_bird2_46.conf> &nbsp; | &nbsp;Both&nbsp; | Bird2 format |
266
-| <https://dn42.burble.com/roa/dn42_roa_bird2_4.conf> &nbsp; | &nbsp;IPv4 Only&nbsp; | Bird2 format |
267
-| <https://dn42.burble.com/roa/dn42_roa_bird2_6.conf> &nbsp; | &nbsp;IPv6 Only&nbsp; | Bird2 format |
268
-
269
-ROA files generated by [roa_wizard](https://git.dn42.dev/Kioubit/roa_wizard) are available:
270
-
271
-|URL|&nbsp;IPv4/IPv6&nbsp;|Description|
272
-|---|---|---|
273
-| <https://kioubit-roa.dn42.dev/?type=v4> &nbsp; | &nbsp;IPv4 Only&nbsp; | Bird2 format |
274
-| <https://kioubit-roa.dn42.dev/?type=v6> &nbsp; | &nbsp;IPv6 Only&nbsp; | Bird2 format |
275
-| <https://kioubit-roa.dn42.dev/?type=json> &nbsp; | &nbsp;Both&nbsp; | JSON format for use with RPKI |
276
-
277
-### Updating ROA tables
278
-
279
-You can add cron entries to periodically update the tables:
280
-
281
-```conf
282
-*/15 * * * * curl -sfSLR {-o,-z}/var/lib/bird/bird6_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_6.conf && chronic birdc6 configure
283
-*/15 * * * * curl -sfSLR {-o,-z}/var/lib/bird/bird_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_4.conf && chronic birdc configure
284
-```
285
-
286
-Debian version:
287
-
288
-```conf
289
-*/15 * * * * curl -sfSLR -o/var/lib/bird/bird6_roa_dn42.conf -z/var/lib/bird/bird6_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_6.conf && /usr/sbin/birdc6 configure
290
-*/15 * * * * curl -sfSLR -o/var/lib/bird/bird_roa_dn42.conf -z/var/lib/bird/bird_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_4.conf && /usr/sbin/birdc configure
291
-```
292
-
293
-then create the directory to make sure curls can save the files:
294
-
295
-```sh
296
-mkdir -p /var/lib/bird/
297
-```
298
-
299
-Or use a systemd timer: (check the commands before copy-pasting)
300
-
301
-```conf
302
-# /etc/systemd/system/dn42-roa.service
303
-[Unit]
304
-Description=Update DN42 ROA
305
-
306
-[Service]
307
-Type=oneshot
308
-ExecStart=curl -sfSLR -o /etc/bird/roa_dn42.conf -z /etc/bird/roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird2_4.conf
309
-ExecStart=curl -sfSLR -o /etc/bird/roa_dn42_v6.conf -z /etc/bird/roa_dn42_v6.conf https://dn42.burble.com/roa/dn42_roa_bird2_6.conf
310
-ExecStart=birdc configure
311
-```
312
-
313
-```conf
314
-# /etc/systemd/system/dn42-roa.timer
315
-[Unit]
316
-Description=Update DN42 ROA periodically
317
-
318
-[Timer]
319
-OnBootSec=2m
320
-OnUnitActiveSec=15m
321
-AccuracySec=1m
322
-
323
-[Install]
324
-WantedBy=timers.target
325
-```
326
-
327
-then enable and start the timer with `systemctl enable --now dn42-roa.timer`.
328
-
329
-More advanced script with error checking:
330
-```sh
331
-#!/bin/bash
332
-roa4URL=""
333
-roa6URL=""
334
-
335
-roa4FILE="/etc/bird/roa/roa_dn42.conf"
336
-roa6FILE="/etc/bird/roa/roa_dn42_v6.conf"
337
-
338
-cp "${roa4FILE}" "${roa4FILE}.old"
339
-cp "${roa6FILE}" "${roa6FILE}.old"
340
-
341
-if curl -f -o "${roa4FILE}.new" "${roa4URL};" ;then
342
- mv "${roa4FILE}.new" "${roa4FILE}"
343
-fi
344
-
345
-if curl -f -o "${roa6FILE}.new" "${roa6URL};" ;then
346
- mv "${roa6FILE}.new" "${roa6FILE}"
347
-fi
348
-
349
-if birdc configure ; then
350
- rm "${roa4FILE}.old"
351
- rm "${roa6FILE}.old"
352
-else
353
- mv "${roa4FILE}.old" "${roa4FILE}"
354
- mv "${roa6FILE}.old" "${roa6FILE}"
355
-fi
356
-```
357
-
358
-
359
-### Use RPKI ROA in bird2
360
-
361
-* Download gortr
362
-
363
-<https://github.com/cloudflare/gortr/releases>
364
-
365
-* Run gortr.
366
-
367
-```sh
368
-./gortr -verify=false -checktime=false -cache=https://dn42.burble.com/roa/dn42_roa_46.json
369
-```
370
-
371
-
372
-* Run with docker
373
-
374
-```sh
375
-docker pull cloudflare/gortr
376
-```
377
-
378
-```sh
379
-docker run --name dn42rpki -p 8282:8282 --restart=always -d cloudflare/gortr -verify=false -checktime=false -cache=https://dn42.burble.com/roa/dn42_roa_46.json
380
-```
381
-
382
-* Add this to your bird configure file,other ROA protocol must removed.
383
-
384
-```conf
385
-protocol rpki rpki_dn42{
386
- roa4 { table dn42_roa; };
387
- roa6 { table dn42_roa_v6; };
388
-
389
- remote "<your rpki server ip or domain>" port 8282;
390
-
391
- retry keep 90;
392
- refresh keep 900;
393
- expire keep 172800;
394
-}
395
-```
396
-
397
-## Filter configuration
398
-
399
-In your import filter add the following to reject invalid routes:
400
-
401
-```conf
402
-if (roa_check(dn42_roa, net, bgp_path.last) != ROA_VALID) then {
403
- print "[dn42] ROA check failed for ", net, " ASN ", bgp_path.last;
404
- reject;
405
-}
406
-```
407
-
408
-Also, define your ROA table with:
409
-
410
-```conf
411
-roa table dn42_roa {
412
- include "/var/lib/bird/bird_roa_dn42.conf";
413
-};
414
-```
415
-
416
-
417
-**NOTE**: Make sure you setup ROA checks for both bird and bird6 (for IPv6).
418
-
419
-# Useful bird commmands
420
-
421
-bird can be remote controlled via the `birdc` command. Here is a list of useful bird commands:
422
-
423
-```sh
424
-$ birdc
425
-BIRD 1.4.5 ready.
426
-bird> configure # reload configuration
427
-Reading configuration from /etc/bird.conf
428
-Reconfigured
429
-bird> show ? # Completions work either by pressing tab or pressing '?'
430
-show bfd ... Show information about BFD protocol
431
-show interfaces Show network interfaces
432
-show memory Show memory usage
433
-show ospf ... Show information about OSPF protocol
434
-show protocols [<protocol> | "<pattern>"] Show routing protocols
435
-show roa ... Show ROA table
436
-show route ... Show routing table
437
-show static [<name>] Show details of static protocol
438
-show status Show router status
439
-show symbols ... Show all known symbolic names
440
-bird> show protocols # this command shows your peering status
441
-name proto table state since info
442
-device1 Device master up 07:20:25
443
-kernel1 Kernel master up 07:20:25
444
-chelnok BGP master up 07:20:29 Established
445
-hax404 BGP master up 07:20:26 Established
446
-static1 Static master up 07:20:25
447
-bird> show protocols all chelnok # show verbose peering status for peering with chelnok
448
-bird> show route for 172.22.141.181 # show possible routes to internal.dn42
449
-172.22.141.0/24 via 172.23.67.1 on tobee [tobee 07:20:30] * (100) [AS64737i]
450
- via 172.23.64.1 on chelnok [chelnok 07:20:29] (100) [AS64737i]
451
- via 172.23.136.65 on hax404 [hax404 07:20:26] (100) [AS64737i]
452
-bird> show route filtered # shows routed filtered out by rules
453
-172.23.245.1/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS76175i]
454
-172.22.247.128/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS76175i]
455
-172.22.227.1/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS76115i]
456
-172.23.196.75/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS76115i]
457
-172.22.41.241/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS76115i]
458
-172.22.249.4/30 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS4242420002i]
459
-172.22.255.133/32 via 172.23.64.1 on chelnok [chelnok 21:26:18] * (100) [AS64654i]
460
-bird> show route protocol <somepeer> # shows the route they export to you
461
-bird> show route export <somepeer> # shows the route you export to someone
462
-...
463
-```
464
-
465
-# External Links
466
-* detailed bird configuration from Mic92: <https://github.com/Mic92/bird-dn42>
467
-* more bird commands: <https://bird.network.cz/?get_doc&v=20&f=bird-4.html>
howto/Bird2.md
... ...
@@ -247,3 +247,177 @@ protocol bgp <NEIGHBOR_NAME>_v6 from dnpeers {
247 247
```
248 248
249 249
Due to the special link local addresses of IPv6, an interface has to be specified using the `%<if>` syntax if a link local address is used (Which is recommended)
250
+
251
+# BGP communities
252
+
253
+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. It is really easy to get started with communities and we encourage all of you to get the basic configuration done and to mark your peerings with the correct flags for improved routing.
254
+More information can be found [here](/howto/BGP-communities).
255
+
256
+# Route Origin Authorization
257
+
258
+Route Origin Authorizations should be used in BIRD to authenticate prefix announcements. These check the originating AS and validate that they are allowed to advertise a prefix.
259
+
260
+## ROA Tables
261
+
262
+The ROA table can be generated from the registry directly or you can use the following pre-built ROA tables for BIRD:
263
+
264
+ROA files generated by [dn42regsrv](https://git.burble.com/burble.dn42/dn42regsrv) are available from burble.dn42:
265
+
266
+|URL|&nbsp;IPv4/IPv6&nbsp;|Description|
267
+|---|---|---|
268
+| <https://dn42.burble.com/roa/dn42_roa_46.json> &nbsp; | &nbsp;Both&nbsp; | JSON format for use with RPKI |
269
+| <https://dn42.burble.com/roa/dn42_roa_bird1_46.conf> &nbsp; | &nbsp;Both&nbsp; | Bird1 format |
270
+| <https://dn42.burble.com/roa/dn42_roa_bird1_4.conf> &nbsp; | &nbsp;IPv4 Only&nbsp; | Bird1 format |
271
+| <https://dn42.burble.com/roa/dn42_roa_bird1_6.conf> &nbsp; | &nbsp;IPv6 Only&nbsp; | Bird1 format |
272
+| <https://dn42.burble.com/roa/dn42_roa_bird2_46.conf> &nbsp; | &nbsp;Both&nbsp; | Bird2 format |
273
+| <https://dn42.burble.com/roa/dn42_roa_bird2_4.conf> &nbsp; | &nbsp;IPv4 Only&nbsp; | Bird2 format |
274
+| <https://dn42.burble.com/roa/dn42_roa_bird2_6.conf> &nbsp; | &nbsp;IPv6 Only&nbsp; | Bird2 format |
275
+
276
+ROA files generated by [roa_wizard](https://git.dn42.dev/Kioubit/roa_wizard) are available:
277
+
278
+|URL|&nbsp;IPv4/IPv6&nbsp;|Description|
279
+|---|---|---|
280
+| <https://kioubit-roa.dn42.dev/?type=v4> &nbsp; | &nbsp;IPv4 Only&nbsp; | Bird2 format |
281
+| <https://kioubit-roa.dn42.dev/?type=v6> &nbsp; | &nbsp;IPv6 Only&nbsp; | Bird2 format |
282
+| <https://kioubit-roa.dn42.dev/?type=json> &nbsp; | &nbsp;Both&nbsp; | JSON format for use with RPKI |
283
+
284
+### Updating ROA tables
285
+
286
+You can add cron entries to periodically update the tables:
287
+
288
+```conf
289
+*/15 * * * * curl -sfSLR {-o,-z}/var/lib/bird/bird6_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_6.conf && chronic birdc6 configure
290
+*/15 * * * * curl -sfSLR {-o,-z}/var/lib/bird/bird_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_4.conf && chronic birdc configure
291
+```
292
+
293
+Debian version:
294
+
295
+```conf
296
+*/15 * * * * curl -sfSLR -o/var/lib/bird/bird6_roa_dn42.conf -z/var/lib/bird/bird6_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_6.conf && /usr/sbin/birdc6 configure
297
+*/15 * * * * curl -sfSLR -o/var/lib/bird/bird_roa_dn42.conf -z/var/lib/bird/bird_roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird1_4.conf && /usr/sbin/birdc configure
298
+```
299
+
300
+then create the directory to make sure curls can save the files:
301
+
302
+```sh
303
+mkdir -p /var/lib/bird/
304
+```
305
+
306
+Or use a systemd timer: (check the commands before copy-pasting)
307
+
308
+```conf
309
+# /etc/systemd/system/dn42-roa.service
310
+[Unit]
311
+Description=Update DN42 ROA
312
+
313
+[Service]
314
+Type=oneshot
315
+ExecStart=curl -sfSLR -o /etc/bird/roa_dn42.conf -z /etc/bird/roa_dn42.conf https://dn42.burble.com/roa/dn42_roa_bird2_4.conf
316
+ExecStart=curl -sfSLR -o /etc/bird/roa_dn42_v6.conf -z /etc/bird/roa_dn42_v6.conf https://dn42.burble.com/roa/dn42_roa_bird2_6.conf
317
+ExecStart=birdc configure
318
+```
319
+
320
+```conf
321
+# /etc/systemd/system/dn42-roa.timer
322
+[Unit]
323
+Description=Update DN42 ROA periodically
324
+
325
+[Timer]
326
+OnBootSec=2m
327
+OnUnitActiveSec=15m
328
+AccuracySec=1m
329
+
330
+[Install]
331
+WantedBy=timers.target
332
+```
333
+
334
+then enable and start the timer with `systemctl enable --now dn42-roa.timer`.
335
+
336
+More advanced script with error checking:
337
+```sh
338
+#!/bin/bash
339
+roa4URL=""
340
+roa6URL=""
341
+
342
+roa4FILE="/etc/bird/roa/roa_dn42.conf"
343
+roa6FILE="/etc/bird/roa/roa_dn42_v6.conf"
344
+
345
+cp "${roa4FILE}" "${roa4FILE}.old"
346
+cp "${roa6FILE}" "${roa6FILE}.old"
347
+
348
+if curl -f -o "${roa4FILE}.new" "${roa4URL};" ;then
349
+ mv "${roa4FILE}.new" "${roa4FILE}"
350
+fi
351
+
352
+if curl -f -o "${roa6FILE}.new" "${roa6URL};" ;then
353
+ mv "${roa6FILE}.new" "${roa6FILE}"
354
+fi
355
+
356
+if birdc configure ; then
357
+ rm "${roa4FILE}.old"
358
+ rm "${roa6FILE}.old"
359
+else
360
+ mv "${roa4FILE}.old" "${roa4FILE}"
361
+ mv "${roa6FILE}.old" "${roa6FILE}"
362
+fi
363
+```
364
+
365
+
366
+### Use RPKI ROA in bird2
367
+
368
+* Download gortr
369
+
370
+<https://github.com/cloudflare/gortr/releases>
371
+
372
+* Run gortr.
373
+
374
+```sh
375
+./gortr -verify=false -checktime=false -cache=https://dn42.burble.com/roa/dn42_roa_46.json
376
+```
377
+
378
+
379
+* Run with docker
380
+
381
+```sh
382
+docker pull cloudflare/gortr
383
+```
384
+
385
+```sh
386
+docker run --name dn42rpki -p 8282:8282 --restart=always -d cloudflare/gortr -verify=false -checktime=false -cache=https://dn42.burble.com/roa/dn42_roa_46.json
387
+```
388
+
389
+* Add this to your bird configure file,other ROA protocol must removed.
390
+
391
+```conf
392
+protocol rpki rpki_dn42{
393
+ roa4 { table dn42_roa; };
394
+ roa6 { table dn42_roa_v6; };
395
+
396
+ remote "<your rpki server ip or domain>" port 8282;
397
+
398
+ retry keep 90;
399
+ refresh keep 900;
400
+ expire keep 172800;
401
+}
402
+```
403
+
404
+## Filter configuration
405
+
406
+In your import filter add the following to reject invalid routes:
407
+
408
+```conf
409
+if (roa_check(dn42_roa, net, bgp_path.last) != ROA_VALID) then {
410
+ print "[dn42] ROA check failed for ", net, " ASN ", bgp_path.last;
411
+ reject;
412
+}
413
+```
414
+
415
+Also, define your ROA table with:
416
+
417
+```conf
418
+roa table dn42_roa {
419
+ include "/var/lib/bird/bird_roa_dn42.conf";
420
+};
421
+```
422
+
423
+**NOTE**: Make sure you setup ROA checks for both IPv4 and IPv6.