howto/Run your MPLS network with BIRD.md
... ...
@@ -1,704 +0,0 @@
1
-Original Article: [https://blog.sherpherd.top/2024/02/11/RunYourMPLSNetworkWithBIRD_en.html](https://blog.sherpherd.top/2024/02/11/RunYourMPLSNetworkWithBIRD_en.html)
2
-
3
-# Intro
4
-Now, most tutorials about running MPLS on Linux are based on FRR. Because in a long time, FRR and its predecessor Quagga are the only choices who provide industry standard MPLS related protocol (LDP, BGP-LU, BGP IPv4/IPv6 MPLS L3VPN, etc.) implementation, by the time, most of other routing software don't even have availiable MPLS support.
5
-
6
-The most popular routing software among DN42 users, BIRD, has added availiable MPLS support in its newest version (2.14), now BIRD has MPLS-aware, labeled route producing routing protocol, too. (No LDP still though) [<sup>[1]</sup>](#c1)
7
-
8
-The newest BIRD 2.0 User Guide has added MPLS function related chapter[<sup>[2]</sup>](#c2), this is an excerpt:
9
-
10
-> In BIRD, the whole process generally works this way: A MPLS-aware routing protocol (say BGP) receives
11
-routing information including remote label. It produces a route with attribute mpls policy (p. 30) specifying
12
-desired MPLS label policy (p. 18). Such route then passes the import filter (which could modify the MPLS
13
-label policy or perhaps assign a static label) and when it is accepted, a local MPLS label is selected (according
14
-to the label policy) and attached to the route, producing labeled route. When a new MPLS label is allocated,
15
-the MPLS-aware protocol automatically produces corresponding MPLS route. When all labeled routes that
16
-use specific local MPLS label are retracted, the corresponding MPLS route is retracted too. <br>
17
-There are three important concepts for MPLS in BIRD: MPLS domains, MPLS tables and MPLS channels.
18
-MPLS domain represents an independent label space, all MPLS-aware protocols are associated with some MPLS domain. It is responsible for label management, handling label allocation requests from MPLS-aware protocols. MPLS table is just a routing table for MPLS routes. Routers usually have one MPLS domain and one MPLS table, with Kernel protocol to export MPLS routes into kernel FIB. <br>
19
-MPLS channels make protocols MPLS-aware, they are responsible for keeping track of active FECs (and corresponding allocated labels), selecting FECs / local labels for labeled routes, and maintaining correspondence between labeled routes and MPLS routes.
20
-
21
-As mentioned above, the current BGP implementation of BIRD is MPLS-awared, can be used to assign and distribute MPLS labeled route.
22
-
23
-In this article, I will make use of official BIRD document to show readers how to construct a simple MPLS VPN network running with BIRD.
24
-
25
-# Prerequisites
26
-* Unless specific configuration, your node must running completely independent kernel (dedicated server, KVM virtualization, etc.), so that you can enable MPLS kernel module.
27
-* If you using Vultr VPS, due to unknown reason, Vultr integrated system image has some trouble with MPLS, please reinstall your system with official ISO after deployment.
28
-
29
-# Table of Contents
30
-- [Intro](#intro)
31
-- [Prerequisites](#prerequisites)
32
-- [Table of Contents](#table-of-contents)
33
-- [1 Lab Topo](#1-lab-topo)
34
- - [1.1 Node Specs](#11-node-specs)
35
-- [2 Preliminary Work](#2-preliminary-work)
36
- - [2.1 Enable MPLS Kernel Module](#21-enable-mpls-kernel-module)
37
- - [2.2 Kernel Parameter Adjustment](#22-kernel-parameter-adjustment)
38
- - [2.2.1 Enable MPLS Input on MPLS Port](#221-enable-mpls-input-on-mpls-port)
39
- - [2.3 Create VRF and assign VRF for port](#23-create-vrf-and-assign-vrf-for-port)
40
- - [2.3.1 Adjust Client-faced Port MTU to Avoid Fragmentation](#231-adjust-client-faced-port-mtu-to-avoid-fragmentation)
41
- - [2.4 IP Address and Static Route Configuration](#24-ip-address-and-static-route-configuration)
42
- - [2.5 Installing BIRD](#25-installing-bird)
43
- - [2.5.1 Install Compiling and Building Dependencies](#251-install-compiling-and-building-dependencies)
44
- - [2.5.2 Clone BIRD 2.14 Repo](#252-clone-bird-214-repo)
45
- - [2.5.3 Build Software Package of BIRD 2.14](#253-build-software-package-of-bird-214)
46
-- [3 BIRD Configuration](#3-bird-configuration)
47
- - [3.1 Basic Setup](#31-basic-setup)
48
- - [3.1.1 Router ID](#311-router-id)
49
- - [3.1.2 Adding MPLS Domain and Tables](#312-adding-mpls-domain-and-tables)
50
- - [3.1.3 Adding MPLS and VRF Related Protocol and Configuration](#313-adding-mpls-and-vrf-related-protocol-and-configuration)
51
- - [3.2 BGP Configuration](#32-bgp-configuration)
52
- - [3.3 Setup Binding between MPLS L3VPN and VRF Instance](#33-setup-binding-between-mpls-l3vpn-and-vrf-instance)
53
- - [3.4 Complete BIRD Configuration File](#34-complete-bird-configuration-file)
54
- - [3.4.1 R1](#341-r1)
55
- - [3.4.2 R2](#342-r2)
56
- - [3.4.3 R3](#343-r3)
57
-- [4 Verification](#4-verification)
58
- - [4.1 Check VPNv4 Table](#41-check-vpnv4-table)
59
- - [4.2 Check Default IPv4 Table](#42-check-default-ipv4-table)
60
- - [4.3 Check VRF IPv4 Table](#43-check-vrf-ipv4-table)
61
- - [4.4 Check connectivity between PC1 and PC2](#44-check-connectivity-between-pc1-and-pc2)
62
-- [5 Reference](#5-reference)
63
-
64
-# 1 Lab Topo
65
-```
66
-
67
- ----------------------------------------------------------
68
--------- | -------- -------- -------- | --------
69
-| | eth0 ens20 | | ens19 ens19| | ens20 ens19| | ens20 eth0 | |
70
-| PC1 | O==========O | R1 |O==========O| R3 |O==========O| R2 | O==========O | PC2 |
71
-| | | | | | | | | | | |
72
--------- | -------- -------- -------- | --------
73
- | |
74
- | Confederation ASN: 100 |
75
- | R1 ASN: 64512 |
76
- | R2 ASN: 64513 |
77
- | R3 ASN: 64514 |
78
- | RT: 100:500 |
79
- | R1 RT: 203.0.113.1:500 |
80
- | R2 RT: 203.0.113.2:500 |
81
- | |
82
- ----------------------------------------------------------
83
- | Address Assignment |
84
- ----------------------------------------------------------
85
- | |
86
- | eth0@PC1: 192.168.1.2/24 |
87
- | ens20@R1: 192.168.1.1/24 |
88
- | (vrf blue) |
89
- | lo@R1: 203.0.113.1/32 |
90
- | ens19@R1: 203.0.113.1/32 |
91
- | lo@R3: 203.0.113.3/32 |
92
- | ens19@R3: 203.0.113.3/32 |
93
- | ens20@R3: 203.0.113.3/32 |
94
- | lo@R2: 203.0.113.2/32 |
95
- | ens19@R2: 203.0.113.2/32 |
96
- | ens20@R2: 192.168.2.1/24 |
97
- | (vrf blue) |
98
- | eth0@PC2: 192.168.2.2/24 |
99
- | |
100
- ----------------------------------------------------------
101
-
102
-```
103
-
104
-## 1.1 Node Specs
105
-PC1, R1, R2 and PC2 all running Debian 12. R1 and R2 both installed newest version BIRD by the time I finished this, the BIRD 2.14.
106
-
107
-**Notice: Remember to add third port for R1, R2 and R3 to make them able to access Internet for downloading BIRD software package or compiling dependencies**
108
-
109
-# 2 Preliminary Work
110
-## 2.1 Enable MPLS Kernel Module
111
-Run these command on R1 and R2 with root permission:
112
-```
113
-modprobe mpls_router
114
-modprobe mpls_iptunnel
115
-modprobe mpls_gso
116
-```
117
-## 2.2 Kernel Parameter Adjustment
118
-Run these command on R1, R2 and R3 with root permission to adjust parameters related to IP routing and MPLS, make them able to work[<sup>[3]</sup>](#c3):
119
-```
120
-cat >/etc/sysctl.d/90-mpls-router.conf <<EOF
121
-net.ipv4.ip_forward=1
122
-net.ipv6.conf.all.forwarding=1
123
-net.ipv4.conf.all.rp_filter=0
124
-net.mpls.platform_labels=1048575
125
-net.ipv4.tcp_l3mdev_accept=1
126
-net.ipv4.udp_l3mdev_accept=1
127
-net.mpls.conf.lo.input=1
128
-EOF
129
-sysctl -p /etc/sysctl.d/90-mpls-router.conf
130
-```
131
-### 2.2.1 Enable MPLS Input on MPLS Port
132
-Every port transits MPLS traffic need to enable MPLS input, run these command on R1 and R2 with root permission to enable MPLS input for their port ens19:
133
-```
134
-sysctl -w net.mpls.conf.ens19.input=1
135
-```
136
-So do on R3:
137
-```
138
-sysctl -w net.mpls.conf.ens19.input=1
139
-sysctl -w net.mpls.conf.ens20.input=1
140
-```
141
-**Notice: Every MPLS traffic transiting port need this configuration**
142
-## 2.3 Create VRF and assign VRF for port
143
-Run these command on R1 and R2 with root permission to create a VRF interface named "blue":
144
-```
145
-ip link add blue type vrf table 500
146
-ip link set blue up
147
-```
148
-Run these command on R1 and R2 with root permission to assign ens20 to VRF blue then enable it:
149
-```
150
-ip link set ens20 master blue up
151
-```
152
-### 2.3.1 Adjust Client-faced Port MTU to Avoid Fragmentation
153
-In practice, increasing MTU of core network link is always harder than decreasing client-faced port MTU, and using MPLS incur additional packet header overhead (4 bytes per label), this made large packet may get fragmented when entering MPLS network. To avoid this, we need to approviately decrease the MTU of client-faced port.
154
-
155
-Run these command on PC1 and PC2 with root permission to adjust MTU of eth0 then enable it:
156
-```
157
-ip link set eth0 mtu 1492 up
158
-```
159
-Run these command on R1 and R2 with root permission to adjust MTU of ens20:
160
-```
161
-ip link set ens20 mtu 1492
162
-```
163
-## 2.4 IP Address and Static Route Configuration
164
-Run command with root permission on nodes below to done this.
165
-R1:
166
-```
167
-ip addr add 203.0.113.1/32 dev lo
168
-ip addr add 203.0.113.1/32 dev ens19 peer 203.0.113.3/32
169
-ip addr add 192.168.1.1/24 dev ens20
170
-```
171
-R2:
172
-```
173
-ip addr add 203.0.113.2/32 dev lo
174
-ip addr add 203.0.113.2/32 dev ens19 peer 203.0.113.3/32
175
-ip addr add 192.168.2.1/24 dev ens20
176
-```
177
-R3:
178
-```
179
-ip addr add 203.0.113.3/32 dev lo
180
-ip addr add 203.0.113.3/32 dev ens19 peer 203.0.113.1/32
181
-ip addr add 203.0.113.3/32 dev ens20 peer 203.0.113.2/32
182
-```
183
-PC1:
184
-```
185
-ip addr add 192.168.1.2/24 dev eth0
186
-ip route add 192.168.2.0/24 via 192.168.1.1
187
-```
188
-PC1:
189
-```
190
-ip addr add 192.168.2.2/24 dev eth0
191
-ip route add 192.168.1.0/24 via 192.168.2.1
192
-```
193
-## 2.5 Installing BIRD
194
-The compile installed BIRD is incomplete, it lacks system service file, docs, etc.
195
-
196
-If you want complete BIRD, you have to build software package then install from it.
197
-
198
-If you don't want build yourself, you can download them here (deb package):
199
-
200
-[https://drive.google.com/drive/folders/1DUaFJgZGsEXI-RlreNxCG9mnERiAkIVB?usp=drive_link](https://drive.google.com/drive/folders/1DUaFJgZGsEXI-RlreNxCG9mnERiAkIVB?usp=drive_link)
201
-
202
-If hints dependency miss, follow the hint to install missed dependency.
203
-
204
-If you want to build it yourself, please read the rest of this chapter.
205
-
206
-Prepare a compile node running Debian 12, no need of high spec, mine got 4 cores and 4 gigs of RAM, then do as follow.
207
-
208
-### 2.5.1 Install Compiling and Building Dependencies
209
-```
210
-apt install -y git linuxdoc-tools autoconf build-essential libssh-dev libreadline-dev libncurses-dev flex bison checkinstall debhelper docbook-xsl libssh-gcrypt-dev quilt xsltproc linuxdoc-tools-latex texlive-latex-extra
211
-```
212
-```
213
-pipx install apkg
214
-```
215
-### 2.5.2 Clone BIRD 2.14 Repo
216
-```
217
-git clone --branch v2.14 https://gitlab.nic.cz/labs/bird.git
218
-```
219
-### 2.5.3 Build Software Package of BIRD 2.14
220
-Enter "bird" then run command below:
221
-```
222
-apkg build
223
-```
224
-Once finished, apkg gives hint like this:
225
-```
226
-built 3 packages in: pkg/pkgs/debian-12/bird2_2.14.1707409394.0e1fbaa5-cznic.1
227
-```
228
-The built software package is located in the location the hint mentioned, make use of it.
229
-
230
-# 3 BIRD Configuration
231
-Currently BIRD don't have implementation of distributing MPLS labeled route through IGP topo, so we use BGP-LU to do that.
232
-## 3.1 Basic Setup
233
-### 3.1.1 Router ID
234
-Having a static Router ID is always not a bad thing.
235
-
236
-R1:
237
-```
238
-router id 203.0.113.1;
239
-```
240
-So do on R2 and R3.
241
-
242
-### 3.1.2 Adding MPLS Domain and Tables
243
-Use R1 as example, so do on other nodes:
244
-```
245
-mpls domain mpls_dom;
246
-
247
-mpls table bgp_mpls_table;
248
-
249
-vpn4 table bgp_vpn4;
250
-
251
-ipv4 table vrf_blue4; # This one is no need on R3
252
-```
253
-
254
-### 3.1.3 Adding MPLS and VRF Related Protocol and Configuration
255
-Use R1 as example:
256
-```
257
-protocol kernel krt_mpls {
258
- mpls {
259
- table bgp_mpls_table;
260
- export all;
261
- };
262
-}
263
-
264
-protocol kernel vrf_blue_4 { # No need for R3, since it doesn't run any VRF instance
265
- vrf "blue";
266
- ipv4 {
267
- table vrf_blue4;
268
- export all;
269
- import all;
270
- };
271
- kernel table 500;
272
-}
273
-
274
-protocol static {
275
- ipv4;
276
- route 203.0.113.1/32 reject; # Inject direct route through static, for advertising it in BGP
277
-}
278
-
279
-protocol static { # Same, no need for R3
280
- ipv4 { table vrf_blue4; };
281
- route 192.168.1.0/24 reject;
282
-}
283
-```
284
-
285
-## 3.2 BGP Configuration
286
-Use R1 as example:
287
-```
288
-protocol bgp r3 {
289
- local 203.0.113.1 as 64512;
290
- neighbor 203.0.113.3 as 64514;
291
- confederation 100;
292
- confederation member;
293
- ipv4 mpls { # Enable IPv4 Labeled Unicast channel, to enable MPLS reachability between MPLS nodes
294
- import all;
295
- export all;
296
- };
297
- vpn4 mpls { # Enable VPNv4 channel, carring IPv4 VPN route
298
- table bgp_vpn4;
299
- import all;
300
- export all;
301
- };
302
- mpls {
303
- label policy aggregate;
304
- };
305
-}
306
-```
307
-
308
-## 3.3 Setup Binding between MPLS L3VPN and VRF Instance
309
-No need for R3, it doesn't run any VRF instance.
310
-
311
-Use R1 as example:
312
-```
313
-protocol l3vpn vpn_blue4 {
314
- vrf "blue";
315
- ipv4 { table vrf_blue4; }; # # Binding VRF Table
316
- vpn4 { table bgp_vpn4; }; # Binding VPNv4 Table
317
- mpls { label policy vrf; };
318
-
319
- rd 203.0.113.1:500;
320
- import target [(rt,100,500)]; # Define RT the desired route import from binded VPNv4 to VRF have
321
- export target [(rt,100,500)]; # Define RT the route export from VRF to binded VPNv4 will be attached
322
-}
323
-```
324
-
325
-## 3.4 Complete BIRD Configuration File
326
-### 3.4.1 R1
327
-```
328
-log syslog all;
329
-
330
-router id 203.0.113.1;
331
-
332
-mpls domain mpls_dom;
333
-
334
-mpls table bgp_mpls_table;
335
-
336
-vpn4 table bgp_vpn4;
337
-
338
-ipv4 table vrf_blue4;
339
-
340
-protocol device {
341
-
342
-}
343
-
344
-protocol direct {
345
- disabled; # Disable by default
346
- ipv4; # Connect to default IPv4 table
347
- ipv6; # ... and to default IPv6 table
348
-}
349
-
350
-protocol kernel {
351
- ipv4 { # Connect protocol to IPv4 table by channel
352
- export all; # Export to protocol. default is export none
353
- import all;
354
- };
355
-}
356
-
357
-protocol kernel {
358
- ipv6 { export all; };
359
-}
360
-
361
-protocol kernel krt_mpls {
362
- mpls {
363
- table bgp_mpls_table;
364
- export all;
365
- };
366
-}
367
-
368
-protocol kernel vrf_blue_4 {
369
- vrf "blue";
370
- ipv4 {
371
- table vrf_blue4;
372
- export all;
373
- import all;
374
- };
375
- kernel table 500;
376
-}
377
-
378
-protocol static {
379
- ipv4; # Again, IPv4 channel with default options
380
- route 203.0.113.1/32 reject;
381
-}
382
-
383
-protocol static {
384
- ipv4 { table vrf_blue4; };
385
- route 192.168.1.0/24 reject;
386
-}
387
-
388
-protocol bgp r3 {
389
- local 203.0.113.1 as 64512;
390
- neighbor 203.0.113.3 as 64514;
391
- confederation 100;
392
- confederation member;
393
- ipv4 mpls {
394
- import all;
395
- export all;
396
- };
397
- vpn4 mpls {
398
- table bgp_vpn4;
399
- import all;
400
- export all;
401
- };
402
- mpls {
403
- label policy aggregate;
404
- };
405
-}
406
-
407
-protocol l3vpn vpn_blue4 {
408
- vrf "blue";
409
- ipv4 { table vrf_blue4; };
410
- vpn4 { table bgp_vpn4; };
411
- mpls { label policy vrf; };
412
-
413
- rd 203.0.113.1:500;
414
- import target [(rt,100,500)];
415
- export target [(rt,100,500)];
416
-}
417
-
418
-```
419
-### 3.4.2 R2
420
-```
421
-router id 203.0.113.2;
422
-
423
-log syslog all;
424
-
425
-mpls domain mpls_dom;
426
-
427
-mpls table bgp_mpls_table;
428
-
429
-vpn4 table bgp_vpn4;
430
-
431
-ipv4 table vrf_blue4;
432
-
433
-protocol device {
434
-}
435
-
436
-protocol direct {
437
- disabled; # Disable by default
438
- ipv4; # Connect to default IPv4 table
439
- ipv6; # ... and to default IPv6 table
440
-}
441
-
442
-protocol kernel krt_mpls {
443
- mpls {
444
- table bgp_mpls_table;
445
- export all;
446
- };
447
-}
448
-
449
-protocol kernel vrf_blue_4 {
450
- vrf "blue";
451
- ipv4 {
452
- table vrf_blue4;
453
- export all;
454
- import all;
455
- };
456
- kernel table 500;
457
-}
458
-
459
-protocol kernel {
460
- ipv4 { # Connect protocol to IPv4 table by channel
461
- export all; # Export to protocol. default is export none
462
- };
463
-}
464
-
465
-protocol kernel {
466
- ipv6 { export all; };
467
-}
468
-
469
-protocol static {
470
- ipv4; # Again, IPv4 channel with default options
471
- route 203.0.113.2/32 reject;
472
-}
473
-
474
-protocol static {
475
- ipv4 { table vrf_blue4; };
476
- route 192.168.2.0/24 reject;
477
-}
478
-
479
-protocol bgp r3 {
480
- local 203.0.113.2 as 64513;
481
- neighbor 203.0.113.3 as 64514;
482
- confederation 100;
483
- confederation member;
484
- ipv4 mpls {
485
- import all;
486
- export all;
487
- };
488
- vpn4 mpls {
489
- table bgp_vpn4;
490
- import all;
491
- export all;
492
- };
493
- mpls {
494
- label policy aggregate;
495
- };
496
-}
497
-
498
-protocol l3vpn vpn_blue4 {
499
- vrf "blue";
500
- ipv4 { table vrf_blue4; };
501
- vpn4 { table bgp_vpn4; };
502
- mpls { label policy vrf; };
503
-
504
- rd 203.0.113.2:500;
505
- import target [(rt,100,500)];
506
- export target [(rt,100,500)];
507
-}
508
-
509
-```
510
-### 3.4.3 R3
511
-```
512
-log syslog all;
513
-
514
-router id 203.0.113.3;
515
-
516
-mpls domain mpls_dom;
517
-
518
-mpls table bgp_mpls_table;
519
-
520
-vpn4 table bgp_vpn4;
521
-
522
-protocol device {
523
-}
524
-
525
-protocol direct {
526
- disabled; # Disable by default
527
- ipv4; # Connect to default IPv4 table
528
- ipv6; # ... and to default IPv6 table
529
-}
530
-
531
-protocol kernel {
532
- ipv4 { # Connect protocol to IPv4 table by channel
533
- export all; # Export to protocol. default is export none
534
- };
535
-}
536
-
537
-protocol kernel {
538
- ipv6 { export all; };
539
-}
540
-
541
-protocol kernel krt_mpls {
542
- mpls {
543
- table bgp_mpls_table;
544
- export all;
545
- };
546
-};
547
-
548
-protocol static {
549
- ipv4; # Again, IPv4 channel with default options
550
-
551
-}
552
-
553
-protocol bgp r1 {
554
- local 203.0.113.3 as 64514;
555
- neighbor 203.0.113.1 as 64512;
556
- confederation 100;
557
- confederation member;
558
- ipv4 mpls {
559
- next hop self;
560
- import all;
561
- export all;
562
- };
563
- vpn4 mpls {
564
- next hop self;
565
- table bgp_vpn4;
566
- import all;
567
- export all;
568
- };
569
- mpls {
570
- label policy aggregate;
571
- };
572
-}
573
-
574
-protocol bgp r2 {
575
- local 203.0.113.3 as 64514;
576
- neighbor 203.0.113.2 as 64513;
577
- confederation 100;
578
- confederation member;
579
- ipv4 mpls {
580
- next hop self;
581
- import all;
582
- export all;
583
- };
584
- vpn4 mpls {
585
- next hop self;
586
- table bgp_vpn4;
587
- import all;
588
- export all;
589
- };
590
- mpls {
591
- label policy aggregate;
592
- };
593
-}
594
-
595
-```
596
-
597
-# 4 Verification
598
-## 4.1 Check VPNv4 Table
599
-R1:
600
-```
601
-bird> show route table bgp_vpn4
602
-Table bgp_vpn4:
603
-203.0.113.2:500 192.168.2.0/24 mpls 1001 unicast [r3 23:20:55.236] * (100) [AS64513i]
604
- via 203.0.113.3 on ens19 mpls 1002
605
-203.0.113.1:500 192.168.1.0/24 mpls 1002 unicast [vpn_blue4 22:58:48.918] * (120/0)
606
- dev blue
607
-bird>
608
-```
609
-R2:
610
-```
611
-bird> show route table bgp_vpn4
612
-Table bgp_vpn4:
613
-203.0.113.2:500 192.168.2.0/24 mpls 1001 unicast [vpn_blue4 23:20:55.219] * (120/0)
614
- dev blue
615
-203.0.113.1:500 192.168.1.0/24 mpls 1002 unicast [r3 22:58:56.352] * (100) [AS64512i]
616
- via 203.0.113.3 on ens19 mpls 1003
617
-bird>
618
-```
619
-## 4.2 Check Default IPv4 Table
620
-R1:
621
-```
622
-bird> show route table master4
623
-Table master4:
624
-203.0.113.2/32 mpls 1000 unicast [r3 22:58:56.355] * (100) [AS64513i]
625
- via 203.0.113.3 on ens19 mpls 1000
626
-203.0.113.1/32 unreachable [static1 22:33:27.446] * (200)
627
-bird>
628
-```
629
-R2:
630
-```
631
-bird> show route table master4
632
-Table master4:
633
-203.0.113.2/32 unreachable [static1 22:32:38.874] * (200)
634
-203.0.113.1/32 mpls 1000 unicast [r3 22:58:56.352] * (100) [AS64512i]
635
- via 203.0.113.3 on ens19 mpls 1001
636
-bird>
637
-```
638
-## 4.3 Check VRF IPv4 Table
639
-R1:
640
-```
641
-bird> show route table vrf_blue4
642
-Table vrf_blue4:
643
-192.168.1.0/24 unreachable [static2 22:58:48.918] * (200)
644
-192.168.2.0/24 unicast [vpn_blue4 23:20:55.236] * (80/0)
645
- via 203.0.113.3 on ens19 mpls 1002
646
-bird>
647
-```
648
-R2:
649
-```
650
-bird> show route table vrf_blue4
651
-Table vrf_blue4:
652
-192.168.1.0/24 unicast [vpn_blue4 23:20:55.219] * (80/0)
653
- via 203.0.113.3 on ens19 mpls 1003
654
-192.168.2.0/24 unreachable [static2 22:54:38.777] * (200)
655
-bird>
656
-```
657
-## 4.4 Check connectivity between PC1 and PC2
658
-PC1:
659
-```
660
-root@pc1:~# ping -c 4 192.168.2.2
661
-PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
662
-64 bytes from 192.168.2.2: icmp_seq=1 ttl=61 time=5.53 ms
663
-64 bytes from 192.168.2.2: icmp_seq=2 ttl=61 time=5.03 ms
664
-64 bytes from 192.168.2.2: icmp_seq=3 ttl=61 time=3.73 ms
665
-64 bytes from 192.168.2.2: icmp_seq=4 ttl=61 time=5.97 ms
666
-
667
---- 192.168.2.2 ping statistics ---
668
-4 packets transmitted, 4 received, 0% packet loss, time 3005ms
669
-rtt min/avg/max/mdev = 3.729/5.063/5.965/0.838 ms
670
-root@pc1:~# traceroute 192.168.2.2
671
-traceroute to 192.168.2.2 (192.168.2.2), 30 hops max, 60 byte packets
672
- 1 192.168.1.1 (192.168.1.1) 5.787 ms 6.165 ms *
673
- 2 * * *
674
- 3 * * *
675
- 4 192.168.2.2 (192.168.2.2) 36.865 ms 37.489 ms 44.775 ms
676
-root@pc1:~#
677
-```
678
-PC2:
679
-```
680
-root@pc2:~# ping -c 4 192.168.1.2
681
-PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
682
-64 bytes from 192.168.1.2: icmp_seq=1 ttl=61 time=21.7 ms
683
-64 bytes from 192.168.1.2: icmp_seq=2 ttl=61 time=4.35 ms
684
-64 bytes from 192.168.1.2: icmp_seq=3 ttl=61 time=13.6 ms
685
-64 bytes from 192.168.1.2: icmp_seq=4 ttl=61 time=4.67 ms
686
-
687
---- 192.168.1.2 ping statistics ---
688
-4 packets transmitted, 4 received, 0% packet loss, time 3007ms
689
-rtt min/avg/max/mdev = 4.352/11.098/21.731/7.181 ms
690
-root@pc2:~# traceroute 192.168.1.2
691
-traceroute to 192.168.1.2 (192.168.1.2), 30 hops max, 60 byte packets
692
- 1 192.168.2.1 (192.168.2.1) 17.272 ms 17.125 ms 17.175 ms
693
- 2 * * *
694
- 3 * * *
695
- 4 192.168.1.2 (192.168.1.2) 27.517 ms 27.945 ms 32.354 ms
696
-root@pc2:~#
697
-```
698
-
699
-# 5 Reference
700
-<span id="c1">1. BIRD Team. (2023, October 7). _News Archive_. bird.network.cz. [https://bird.network.cz/?o_news/](https://bird.network.cz/?o_news/)</span>
701
-
702
-<span id="c2">2. BIRD Team. (2023, October 7). BIRD 2.0 User’s Guide. _MPLS_, 9-10. [https://bird.network.cz/download/bird-doc-2.14.tar.gz](https://bird.network.cz/download/bird-doc-2.14.tar.gz)</span>
703
-
704
-<span id="c3">3. James Swineson. (2020, February 22). _Use Linux as an MPLS Router_. blog.swineson.me. [https://blog.swineson.me/en/use-linux-as-an-mpls-router/](https://blog.swineson.me/en/use-linux-as-an-mpls-router/)</span>
... ...
\ No newline at end of file
howto/mpls-bird2.md
... ...
@@ -0,0 +1,704 @@
1
+Original Article: [https://blog.sherpherd.top/2024/02/11/RunYourMPLSNetworkWithBIRD_en.html](https://blog.sherpherd.top/2024/02/11/RunYourMPLSNetworkWithBIRD_en.html)
2
+
3
+# Intro
4
+Now, most tutorials about running MPLS on Linux are based on FRR. Because in a long time, FRR and its predecessor Quagga are the only choices who provide industry standard MPLS related protocol (LDP, BGP-LU, BGP IPv4/IPv6 MPLS L3VPN, etc.) implementation, by the time, most of other routing software don't even have availiable MPLS support.
5
+
6
+The most popular routing software among DN42 users, BIRD, has added availiable MPLS support in its newest version (2.14), now BIRD has MPLS-aware, labeled route producing routing protocol, too. (No LDP still though) [<sup>[1]</sup>](#c1)
7
+
8
+The newest BIRD 2.0 User Guide has added MPLS function related chapter[<sup>[2]</sup>](#c2), this is an excerpt:
9
+
10
+> In BIRD, the whole process generally works this way: A MPLS-aware routing protocol (say BGP) receives
11
+routing information including remote label. It produces a route with attribute mpls policy (p. 30) specifying
12
+desired MPLS label policy (p. 18). Such route then passes the import filter (which could modify the MPLS
13
+label policy or perhaps assign a static label) and when it is accepted, a local MPLS label is selected (according
14
+to the label policy) and attached to the route, producing labeled route. When a new MPLS label is allocated,
15
+the MPLS-aware protocol automatically produces corresponding MPLS route. When all labeled routes that
16
+use specific local MPLS label are retracted, the corresponding MPLS route is retracted too. <br>
17
+There are three important concepts for MPLS in BIRD: MPLS domains, MPLS tables and MPLS channels.
18
+MPLS domain represents an independent label space, all MPLS-aware protocols are associated with some MPLS domain. It is responsible for label management, handling label allocation requests from MPLS-aware protocols. MPLS table is just a routing table for MPLS routes. Routers usually have one MPLS domain and one MPLS table, with Kernel protocol to export MPLS routes into kernel FIB. <br>
19
+MPLS channels make protocols MPLS-aware, they are responsible for keeping track of active FECs (and corresponding allocated labels), selecting FECs / local labels for labeled routes, and maintaining correspondence between labeled routes and MPLS routes.
20
+
21
+As mentioned above, the current BGP implementation of BIRD is MPLS-awared, can be used to assign and distribute MPLS labeled route.
22
+
23
+In this article, I will make use of official BIRD document to show readers how to construct a simple MPLS VPN network running with BIRD.
24
+
25
+# Prerequisites
26
+* Unless specific configuration, your node must running completely independent kernel (dedicated server, KVM virtualization, etc.), so that you can enable MPLS kernel module.
27
+* If you using Vultr VPS, due to unknown reason, Vultr integrated system image has some trouble with MPLS, please reinstall your system with official ISO after deployment.
28
+
29
+# Table of Contents
30
+- [Intro](#intro)
31
+- [Prerequisites](#prerequisites)
32
+- [Table of Contents](#table-of-contents)
33
+- [1 Lab Topo](#1-lab-topo)
34
+ - [1.1 Node Specs](#11-node-specs)
35
+- [2 Preliminary Work](#2-preliminary-work)
36
+ - [2.1 Enable MPLS Kernel Module](#21-enable-mpls-kernel-module)
37
+ - [2.2 Kernel Parameter Adjustment](#22-kernel-parameter-adjustment)
38
+ - [2.2.1 Enable MPLS Input on MPLS Port](#221-enable-mpls-input-on-mpls-port)
39
+ - [2.3 Create VRF and assign VRF for port](#23-create-vrf-and-assign-vrf-for-port)
40
+ - [2.3.1 Adjust Client-faced Port MTU to Avoid Fragmentation](#231-adjust-client-faced-port-mtu-to-avoid-fragmentation)
41
+ - [2.4 IP Address and Static Route Configuration](#24-ip-address-and-static-route-configuration)
42
+ - [2.5 Installing BIRD](#25-installing-bird)
43
+ - [2.5.1 Install Compiling and Building Dependencies](#251-install-compiling-and-building-dependencies)
44
+ - [2.5.2 Clone BIRD 2.14 Repo](#252-clone-bird-214-repo)
45
+ - [2.5.3 Build Software Package of BIRD 2.14](#253-build-software-package-of-bird-214)
46
+- [3 BIRD Configuration](#3-bird-configuration)
47
+ - [3.1 Basic Setup](#31-basic-setup)
48
+ - [3.1.1 Router ID](#311-router-id)
49
+ - [3.1.2 Adding MPLS Domain and Tables](#312-adding-mpls-domain-and-tables)
50
+ - [3.1.3 Adding MPLS and VRF Related Protocol and Configuration](#313-adding-mpls-and-vrf-related-protocol-and-configuration)
51
+ - [3.2 BGP Configuration](#32-bgp-configuration)
52
+ - [3.3 Setup Binding between MPLS L3VPN and VRF Instance](#33-setup-binding-between-mpls-l3vpn-and-vrf-instance)
53
+ - [3.4 Complete BIRD Configuration File](#34-complete-bird-configuration-file)
54
+ - [3.4.1 R1](#341-r1)
55
+ - [3.4.2 R2](#342-r2)
56
+ - [3.4.3 R3](#343-r3)
57
+- [4 Verification](#4-verification)
58
+ - [4.1 Check VPNv4 Table](#41-check-vpnv4-table)
59
+ - [4.2 Check Default IPv4 Table](#42-check-default-ipv4-table)
60
+ - [4.3 Check VRF IPv4 Table](#43-check-vrf-ipv4-table)
61
+ - [4.4 Check connectivity between PC1 and PC2](#44-check-connectivity-between-pc1-and-pc2)
62
+- [5 Reference](#5-reference)
63
+
64
+# 1 Lab Topo
65
+```
66
+
67
+ ----------------------------------------------------------
68
+-------- | -------- -------- -------- | --------
69
+| | eth0 ens20 | | ens19 ens19| | ens20 ens19| | ens20 eth0 | |
70
+| PC1 | O==========O | R1 |O==========O| R3 |O==========O| R2 | O==========O | PC2 |
71
+| | | | | | | | | | | |
72
+-------- | -------- -------- -------- | --------
73
+ | |
74
+ | Confederation ASN: 100 |
75
+ | R1 ASN: 64512 |
76
+ | R2 ASN: 64513 |
77
+ | R3 ASN: 64514 |
78
+ | RT: 100:500 |
79
+ | R1 RT: 203.0.113.1:500 |
80
+ | R2 RT: 203.0.113.2:500 |
81
+ | |
82
+ ----------------------------------------------------------
83
+ | Address Assignment |
84
+ ----------------------------------------------------------
85
+ | |
86
+ | eth0@PC1: 192.168.1.2/24 |
87
+ | ens20@R1: 192.168.1.1/24 |
88
+ | (vrf blue) |
89
+ | lo@R1: 203.0.113.1/32 |
90
+ | ens19@R1: 203.0.113.1/32 |
91
+ | lo@R3: 203.0.113.3/32 |
92
+ | ens19@R3: 203.0.113.3/32 |
93
+ | ens20@R3: 203.0.113.3/32 |
94
+ | lo@R2: 203.0.113.2/32 |
95
+ | ens19@R2: 203.0.113.2/32 |
96
+ | ens20@R2: 192.168.2.1/24 |
97
+ | (vrf blue) |
98
+ | eth0@PC2: 192.168.2.2/24 |
99
+ | |
100
+ ----------------------------------------------------------
101
+
102
+```
103
+
104
+## 1.1 Node Specs
105
+PC1, R1, R2 and PC2 all running Debian 12. R1 and R2 both installed newest version BIRD by the time I finished this, the BIRD 2.14.
106
+
107
+**Notice: Remember to add third port for R1, R2 and R3 to make them able to access Internet for downloading BIRD software package or compiling dependencies**
108
+
109
+# 2 Preliminary Work
110
+## 2.1 Enable MPLS Kernel Module
111
+Run these command on R1 and R2 with root permission:
112
+```
113
+modprobe mpls_router
114
+modprobe mpls_iptunnel
115
+modprobe mpls_gso
116
+```
117
+## 2.2 Kernel Parameter Adjustment
118
+Run these command on R1, R2 and R3 with root permission to adjust parameters related to IP routing and MPLS, make them able to work[<sup>[3]</sup>](#c3):
119
+```
120
+cat >/etc/sysctl.d/90-mpls-router.conf <<EOF
121
+net.ipv4.ip_forward=1
122
+net.ipv6.conf.all.forwarding=1
123
+net.ipv4.conf.all.rp_filter=0
124
+net.mpls.platform_labels=1048575
125
+net.ipv4.tcp_l3mdev_accept=1
126
+net.ipv4.udp_l3mdev_accept=1
127
+net.mpls.conf.lo.input=1
128
+EOF
129
+sysctl -p /etc/sysctl.d/90-mpls-router.conf
130
+```
131
+### 2.2.1 Enable MPLS Input on MPLS Port
132
+Every port transits MPLS traffic need to enable MPLS input, run these command on R1 and R2 with root permission to enable MPLS input for their port ens19:
133
+```
134
+sysctl -w net.mpls.conf.ens19.input=1
135
+```
136
+So do on R3:
137
+```
138
+sysctl -w net.mpls.conf.ens19.input=1
139
+sysctl -w net.mpls.conf.ens20.input=1
140
+```
141
+**Notice: Every MPLS traffic transiting port need this configuration**
142
+## 2.3 Create VRF and assign VRF for port
143
+Run these command on R1 and R2 with root permission to create a VRF interface named "blue":
144
+```
145
+ip link add blue type vrf table 500
146
+ip link set blue up
147
+```
148
+Run these command on R1 and R2 with root permission to assign ens20 to VRF blue then enable it:
149
+```
150
+ip link set ens20 master blue up
151
+```
152
+### 2.3.1 Adjust Client-faced Port MTU to Avoid Fragmentation
153
+In practice, increasing MTU of core network link is always harder than decreasing client-faced port MTU, and using MPLS incur additional packet header overhead (4 bytes per label), this made large packet may get fragmented when entering MPLS network. To avoid this, we need to approviately decrease the MTU of client-faced port.
154
+
155
+Run these command on PC1 and PC2 with root permission to adjust MTU of eth0 then enable it:
156
+```
157
+ip link set eth0 mtu 1492 up
158
+```
159
+Run these command on R1 and R2 with root permission to adjust MTU of ens20:
160
+```
161
+ip link set ens20 mtu 1492
162
+```
163
+## 2.4 IP Address and Static Route Configuration
164
+Run command with root permission on nodes below to done this.
165
+R1:
166
+```
167
+ip addr add 203.0.113.1/32 dev lo
168
+ip addr add 203.0.113.1/32 dev ens19 peer 203.0.113.3/32
169
+ip addr add 192.168.1.1/24 dev ens20
170
+```
171
+R2:
172
+```
173
+ip addr add 203.0.113.2/32 dev lo
174
+ip addr add 203.0.113.2/32 dev ens19 peer 203.0.113.3/32
175
+ip addr add 192.168.2.1/24 dev ens20
176
+```
177
+R3:
178
+```
179
+ip addr add 203.0.113.3/32 dev lo
180
+ip addr add 203.0.113.3/32 dev ens19 peer 203.0.113.1/32
181
+ip addr add 203.0.113.3/32 dev ens20 peer 203.0.113.2/32
182
+```
183
+PC1:
184
+```
185
+ip addr add 192.168.1.2/24 dev eth0
186
+ip route add 192.168.2.0/24 via 192.168.1.1
187
+```
188
+PC1:
189
+```
190
+ip addr add 192.168.2.2/24 dev eth0
191
+ip route add 192.168.1.0/24 via 192.168.2.1
192
+```
193
+## 2.5 Installing BIRD
194
+The compile installed BIRD is incomplete, it lacks system service file, docs, etc.
195
+
196
+If you want complete BIRD, you have to build software package then install from it.
197
+
198
+If you don't want build yourself, you can download them here (deb package):
199
+
200
+[https://drive.google.com/drive/folders/1DUaFJgZGsEXI-RlreNxCG9mnERiAkIVB?usp=drive_link](https://drive.google.com/drive/folders/1DUaFJgZGsEXI-RlreNxCG9mnERiAkIVB?usp=drive_link)
201
+
202
+If hints dependency miss, follow the hint to install missed dependency.
203
+
204
+If you want to build it yourself, please read the rest of this chapter.
205
+
206
+Prepare a compile node running Debian 12, no need of high spec, mine got 4 cores and 4 gigs of RAM, then do as follow.
207
+
208
+### 2.5.1 Install Compiling and Building Dependencies
209
+```
210
+apt install -y git linuxdoc-tools autoconf build-essential libssh-dev libreadline-dev libncurses-dev flex bison checkinstall debhelper docbook-xsl libssh-gcrypt-dev quilt xsltproc linuxdoc-tools-latex texlive-latex-extra
211
+```
212
+```
213
+pipx install apkg
214
+```
215
+### 2.5.2 Clone BIRD 2.14 Repo
216
+```
217
+git clone --branch v2.14 https://gitlab.nic.cz/labs/bird.git
218
+```
219
+### 2.5.3 Build Software Package of BIRD 2.14
220
+Enter "bird" then run command below:
221
+```
222
+apkg build
223
+```
224
+Once finished, apkg gives hint like this:
225
+```
226
+built 3 packages in: pkg/pkgs/debian-12/bird2_2.14.1707409394.0e1fbaa5-cznic.1
227
+```
228
+The built software package is located in the location the hint mentioned, make use of it.
229
+
230
+# 3 BIRD Configuration
231
+Currently BIRD don't have implementation of distributing MPLS labeled route through IGP topo, so we use BGP-LU to do that.
232
+## 3.1 Basic Setup
233
+### 3.1.1 Router ID
234
+Having a static Router ID is always not a bad thing.
235
+
236
+R1:
237
+```
238
+router id 203.0.113.1;
239
+```
240
+So do on R2 and R3.
241
+
242
+### 3.1.2 Adding MPLS Domain and Tables
243
+Use R1 as example, so do on other nodes:
244
+```
245
+mpls domain mpls_dom;
246
+
247
+mpls table bgp_mpls_table;
248
+
249
+vpn4 table bgp_vpn4;
250
+
251
+ipv4 table vrf_blue4; # This one is no need on R3
252
+```
253
+
254
+### 3.1.3 Adding MPLS and VRF Related Protocol and Configuration
255
+Use R1 as example:
256
+```
257
+protocol kernel krt_mpls {
258
+ mpls {
259
+ table bgp_mpls_table;
260
+ export all;
261
+ };
262
+}
263
+
264
+protocol kernel vrf_blue_4 { # No need for R3, since it doesn't run any VRF instance
265
+ vrf "blue";
266
+ ipv4 {
267
+ table vrf_blue4;
268
+ export all;
269
+ import all;
270
+ };
271
+ kernel table 500;
272
+}
273
+
274
+protocol static {
275
+ ipv4;
276
+ route 203.0.113.1/32 reject; # Inject direct route through static, for advertising it in BGP
277
+}
278
+
279
+protocol static { # Same, no need for R3
280
+ ipv4 { table vrf_blue4; };
281
+ route 192.168.1.0/24 reject;
282
+}
283
+```
284
+
285
+## 3.2 BGP Configuration
286
+Use R1 as example:
287
+```
288
+protocol bgp r3 {
289
+ local 203.0.113.1 as 64512;
290
+ neighbor 203.0.113.3 as 64514;
291
+ confederation 100;
292
+ confederation member;
293
+ ipv4 mpls { # Enable IPv4 Labeled Unicast channel, to enable MPLS reachability between MPLS nodes
294
+ import all;
295
+ export all;
296
+ };
297
+ vpn4 mpls { # Enable VPNv4 channel, carring IPv4 VPN route
298
+ table bgp_vpn4;
299
+ import all;
300
+ export all;
301
+ };
302
+ mpls {
303
+ label policy aggregate;
304
+ };
305
+}
306
+```
307
+
308
+## 3.3 Setup Binding between MPLS L3VPN and VRF Instance
309
+No need for R3, it doesn't run any VRF instance.
310
+
311
+Use R1 as example:
312
+```
313
+protocol l3vpn vpn_blue4 {
314
+ vrf "blue";
315
+ ipv4 { table vrf_blue4; }; # # Binding VRF Table
316
+ vpn4 { table bgp_vpn4; }; # Binding VPNv4 Table
317
+ mpls { label policy vrf; };
318
+
319
+ rd 203.0.113.1:500;
320
+ import target [(rt,100,500)]; # Define RT the desired route import from binded VPNv4 to VRF have
321
+ export target [(rt,100,500)]; # Define RT the route export from VRF to binded VPNv4 will be attached
322
+}
323
+```
324
+
325
+## 3.4 Complete BIRD Configuration File
326
+### 3.4.1 R1
327
+```
328
+log syslog all;
329
+
330
+router id 203.0.113.1;
331
+
332
+mpls domain mpls_dom;
333
+
334
+mpls table bgp_mpls_table;
335
+
336
+vpn4 table bgp_vpn4;
337
+
338
+ipv4 table vrf_blue4;
339
+
340
+protocol device {
341
+
342
+}
343
+
344
+protocol direct {
345
+ disabled; # Disable by default
346
+ ipv4; # Connect to default IPv4 table
347
+ ipv6; # ... and to default IPv6 table
348
+}
349
+
350
+protocol kernel {
351
+ ipv4 { # Connect protocol to IPv4 table by channel
352
+ export all; # Export to protocol. default is export none
353
+ import all;
354
+ };
355
+}
356
+
357
+protocol kernel {
358
+ ipv6 { export all; };
359
+}
360
+
361
+protocol kernel krt_mpls {
362
+ mpls {
363
+ table bgp_mpls_table;
364
+ export all;
365
+ };
366
+}
367
+
368
+protocol kernel vrf_blue_4 {
369
+ vrf "blue";
370
+ ipv4 {
371
+ table vrf_blue4;
372
+ export all;
373
+ import all;
374
+ };
375
+ kernel table 500;
376
+}
377
+
378
+protocol static {
379
+ ipv4; # Again, IPv4 channel with default options
380
+ route 203.0.113.1/32 reject;
381
+}
382
+
383
+protocol static {
384
+ ipv4 { table vrf_blue4; };
385
+ route 192.168.1.0/24 reject;
386
+}
387
+
388
+protocol bgp r3 {
389
+ local 203.0.113.1 as 64512;
390
+ neighbor 203.0.113.3 as 64514;
391
+ confederation 100;
392
+ confederation member;
393
+ ipv4 mpls {
394
+ import all;
395
+ export all;
396
+ };
397
+ vpn4 mpls {
398
+ table bgp_vpn4;
399
+ import all;
400
+ export all;
401
+ };
402
+ mpls {
403
+ label policy aggregate;
404
+ };
405
+}
406
+
407
+protocol l3vpn vpn_blue4 {
408
+ vrf "blue";
409
+ ipv4 { table vrf_blue4; };
410
+ vpn4 { table bgp_vpn4; };
411
+ mpls { label policy vrf; };
412
+
413
+ rd 203.0.113.1:500;
414
+ import target [(rt,100,500)];
415
+ export target [(rt,100,500)];
416
+}
417
+
418
+```
419
+### 3.4.2 R2
420
+```
421
+router id 203.0.113.2;
422
+
423
+log syslog all;
424
+
425
+mpls domain mpls_dom;
426
+
427
+mpls table bgp_mpls_table;
428
+
429
+vpn4 table bgp_vpn4;
430
+
431
+ipv4 table vrf_blue4;
432
+
433
+protocol device {
434
+}
435
+
436
+protocol direct {
437
+ disabled; # Disable by default
438
+ ipv4; # Connect to default IPv4 table
439
+ ipv6; # ... and to default IPv6 table
440
+}
441
+
442
+protocol kernel krt_mpls {
443
+ mpls {
444
+ table bgp_mpls_table;
445
+ export all;
446
+ };
447
+}
448
+
449
+protocol kernel vrf_blue_4 {
450
+ vrf "blue";
451
+ ipv4 {
452
+ table vrf_blue4;
453
+ export all;
454
+ import all;
455
+ };
456
+ kernel table 500;
457
+}
458
+
459
+protocol kernel {
460
+ ipv4 { # Connect protocol to IPv4 table by channel
461
+ export all; # Export to protocol. default is export none
462
+ };
463
+}
464
+
465
+protocol kernel {
466
+ ipv6 { export all; };
467
+}
468
+
469
+protocol static {
470
+ ipv4; # Again, IPv4 channel with default options
471
+ route 203.0.113.2/32 reject;
472
+}
473
+
474
+protocol static {
475
+ ipv4 { table vrf_blue4; };
476
+ route 192.168.2.0/24 reject;
477
+}
478
+
479
+protocol bgp r3 {
480
+ local 203.0.113.2 as 64513;
481
+ neighbor 203.0.113.3 as 64514;
482
+ confederation 100;
483
+ confederation member;
484
+ ipv4 mpls {
485
+ import all;
486
+ export all;
487
+ };
488
+ vpn4 mpls {
489
+ table bgp_vpn4;
490
+ import all;
491
+ export all;
492
+ };
493
+ mpls {
494
+ label policy aggregate;
495
+ };
496
+}
497
+
498
+protocol l3vpn vpn_blue4 {
499
+ vrf "blue";
500
+ ipv4 { table vrf_blue4; };
501
+ vpn4 { table bgp_vpn4; };
502
+ mpls { label policy vrf; };
503
+
504
+ rd 203.0.113.2:500;
505
+ import target [(rt,100,500)];
506
+ export target [(rt,100,500)];
507
+}
508
+
509
+```
510
+### 3.4.3 R3
511
+```
512
+log syslog all;
513
+
514
+router id 203.0.113.3;
515
+
516
+mpls domain mpls_dom;
517
+
518
+mpls table bgp_mpls_table;
519
+
520
+vpn4 table bgp_vpn4;
521
+
522
+protocol device {
523
+}
524
+
525
+protocol direct {
526
+ disabled; # Disable by default
527
+ ipv4; # Connect to default IPv4 table
528
+ ipv6; # ... and to default IPv6 table
529
+}
530
+
531
+protocol kernel {
532
+ ipv4 { # Connect protocol to IPv4 table by channel
533
+ export all; # Export to protocol. default is export none
534
+ };
535
+}
536
+
537
+protocol kernel {
538
+ ipv6 { export all; };
539
+}
540
+
541
+protocol kernel krt_mpls {
542
+ mpls {
543
+ table bgp_mpls_table;
544
+ export all;
545
+ };
546
+};
547
+
548
+protocol static {
549
+ ipv4; # Again, IPv4 channel with default options
550
+
551
+}
552
+
553
+protocol bgp r1 {
554
+ local 203.0.113.3 as 64514;
555
+ neighbor 203.0.113.1 as 64512;
556
+ confederation 100;
557
+ confederation member;
558
+ ipv4 mpls {
559
+ next hop self;
560
+ import all;
561
+ export all;
562
+ };
563
+ vpn4 mpls {
564
+ next hop self;
565
+ table bgp_vpn4;
566
+ import all;
567
+ export all;
568
+ };
569
+ mpls {
570
+ label policy aggregate;
571
+ };
572
+}
573
+
574
+protocol bgp r2 {
575
+ local 203.0.113.3 as 64514;
576
+ neighbor 203.0.113.2 as 64513;
577
+ confederation 100;
578
+ confederation member;
579
+ ipv4 mpls {
580
+ next hop self;
581
+ import all;
582
+ export all;
583
+ };
584
+ vpn4 mpls {
585
+ next hop self;
586
+ table bgp_vpn4;
587
+ import all;
588
+ export all;
589
+ };
590
+ mpls {
591
+ label policy aggregate;
592
+ };
593
+}
594
+
595
+```
596
+
597
+# 4 Verification
598
+## 4.1 Check VPNv4 Table
599
+R1:
600
+```
601
+bird> show route table bgp_vpn4
602
+Table bgp_vpn4:
603
+203.0.113.2:500 192.168.2.0/24 mpls 1001 unicast [r3 23:20:55.236] * (100) [AS64513i]
604
+ via 203.0.113.3 on ens19 mpls 1002
605
+203.0.113.1:500 192.168.1.0/24 mpls 1002 unicast [vpn_blue4 22:58:48.918] * (120/0)
606
+ dev blue
607
+bird>
608
+```
609
+R2:
610
+```
611
+bird> show route table bgp_vpn4
612
+Table bgp_vpn4:
613
+203.0.113.2:500 192.168.2.0/24 mpls 1001 unicast [vpn_blue4 23:20:55.219] * (120/0)
614
+ dev blue
615
+203.0.113.1:500 192.168.1.0/24 mpls 1002 unicast [r3 22:58:56.352] * (100) [AS64512i]
616
+ via 203.0.113.3 on ens19 mpls 1003
617
+bird>
618
+```
619
+## 4.2 Check Default IPv4 Table
620
+R1:
621
+```
622
+bird> show route table master4
623
+Table master4:
624
+203.0.113.2/32 mpls 1000 unicast [r3 22:58:56.355] * (100) [AS64513i]
625
+ via 203.0.113.3 on ens19 mpls 1000
626
+203.0.113.1/32 unreachable [static1 22:33:27.446] * (200)
627
+bird>
628
+```
629
+R2:
630
+```
631
+bird> show route table master4
632
+Table master4:
633
+203.0.113.2/32 unreachable [static1 22:32:38.874] * (200)
634
+203.0.113.1/32 mpls 1000 unicast [r3 22:58:56.352] * (100) [AS64512i]
635
+ via 203.0.113.3 on ens19 mpls 1001
636
+bird>
637
+```
638
+## 4.3 Check VRF IPv4 Table
639
+R1:
640
+```
641
+bird> show route table vrf_blue4
642
+Table vrf_blue4:
643
+192.168.1.0/24 unreachable [static2 22:58:48.918] * (200)
644
+192.168.2.0/24 unicast [vpn_blue4 23:20:55.236] * (80/0)
645
+ via 203.0.113.3 on ens19 mpls 1002
646
+bird>
647
+```
648
+R2:
649
+```
650
+bird> show route table vrf_blue4
651
+Table vrf_blue4:
652
+192.168.1.0/24 unicast [vpn_blue4 23:20:55.219] * (80/0)
653
+ via 203.0.113.3 on ens19 mpls 1003
654
+192.168.2.0/24 unreachable [static2 22:54:38.777] * (200)
655
+bird>
656
+```
657
+## 4.4 Check connectivity between PC1 and PC2
658
+PC1:
659
+```
660
+root@pc1:~# ping -c 4 192.168.2.2
661
+PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
662
+64 bytes from 192.168.2.2: icmp_seq=1 ttl=61 time=5.53 ms
663
+64 bytes from 192.168.2.2: icmp_seq=2 ttl=61 time=5.03 ms
664
+64 bytes from 192.168.2.2: icmp_seq=3 ttl=61 time=3.73 ms
665
+64 bytes from 192.168.2.2: icmp_seq=4 ttl=61 time=5.97 ms
666
+
667
+--- 192.168.2.2 ping statistics ---
668
+4 packets transmitted, 4 received, 0% packet loss, time 3005ms
669
+rtt min/avg/max/mdev = 3.729/5.063/5.965/0.838 ms
670
+root@pc1:~# traceroute 192.168.2.2
671
+traceroute to 192.168.2.2 (192.168.2.2), 30 hops max, 60 byte packets
672
+ 1 192.168.1.1 (192.168.1.1) 5.787 ms 6.165 ms *
673
+ 2 * * *
674
+ 3 * * *
675
+ 4 192.168.2.2 (192.168.2.2) 36.865 ms 37.489 ms 44.775 ms
676
+root@pc1:~#
677
+```
678
+PC2:
679
+```
680
+root@pc2:~# ping -c 4 192.168.1.2
681
+PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
682
+64 bytes from 192.168.1.2: icmp_seq=1 ttl=61 time=21.7 ms
683
+64 bytes from 192.168.1.2: icmp_seq=2 ttl=61 time=4.35 ms
684
+64 bytes from 192.168.1.2: icmp_seq=3 ttl=61 time=13.6 ms
685
+64 bytes from 192.168.1.2: icmp_seq=4 ttl=61 time=4.67 ms
686
+
687
+--- 192.168.1.2 ping statistics ---
688
+4 packets transmitted, 4 received, 0% packet loss, time 3007ms
689
+rtt min/avg/max/mdev = 4.352/11.098/21.731/7.181 ms
690
+root@pc2:~# traceroute 192.168.1.2
691
+traceroute to 192.168.1.2 (192.168.1.2), 30 hops max, 60 byte packets
692
+ 1 192.168.2.1 (192.168.2.1) 17.272 ms 17.125 ms 17.175 ms
693
+ 2 * * *
694
+ 3 * * *
695
+ 4 192.168.1.2 (192.168.1.2) 27.517 ms 27.945 ms 32.354 ms
696
+root@pc2:~#
697
+```
698
+
699
+# 5 Reference
700
+<span id="c1">1. BIRD Team. (2023, October 7). _News Archive_. bird.network.cz. [https://bird.network.cz/?o_news/](https://bird.network.cz/?o_news/)</span>
701
+
702
+<span id="c2">2. BIRD Team. (2023, October 7). BIRD 2.0 User’s Guide. _MPLS_, 9-10. [https://bird.network.cz/download/bird-doc-2.14.tar.gz](https://bird.network.cz/download/bird-doc-2.14.tar.gz)</span>
703
+
704
+<span id="c3">3. James Swineson. (2020, February 22). _Use Linux as an MPLS Router_. blog.swineson.me. [https://blog.swineson.me/en/use-linux-as-an-mpls-router/](https://blog.swineson.me/en/use-linux-as-an-mpls-router/)</span>
... ...
\ No newline at end of file
howto/mpls.md
... ...
@@ -1,5 +1,3 @@
1
-Tutorial: [Run your MPLS network with BIRD](/howto/Run your MPLS network with BIRD)
2
-
3 1
mpls label switching is faster because it's a divide and conquer search in an ordered list, compared to routing, which is a longest prefix match, which is a search in a netmask deep tree
4 2
5 3
and doing just label switching, especially with multiple labels, have consequences like
... ...
@@ -26,6 +24,8 @@ to do inter-as-mpls-vpn on top of it, you can enable rr-to-rr, asbr-to-asbr or r
26 24
27 25
more info at <http://mpls.dn42/> or at <http://mp.ls/>
28 26
27
+[How to run MPLS with bird2](/howto/mpls-bird2)
28
+
29 29
participating networks:
30 30
31 31
nop-mnt