aboutsummaryrefslogtreecommitdiffstats
path: root/roles/space_server/files/bird.conf
blob: 0c447ae6ee6a4472aee2831729adc7fa2b46ccb4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#
# BIRD 2 configuration for AS205235 Labitat
#

log syslog all;
#debug protocols all;
debug protocols { events, states };

watchdog warning 5 s;
watchdog timeout 30 s;

timeformat base     iso long;
timeformat log      iso long;
timeformat protocol iso long;
timeformat route    iso long;

router id 185.38.175.0;

# functions and filters

define local_asn   = 205235;
define fiberby_asn = 42541;
define asbjorn_asn = 207727;
define graffen_asn = 209616;
define hafnium_asn = 211153;

define local_prefixes_v4 = [
	185.38.175.0/24,
	194.165.56.0/24,
	194.165.58.0/24
];

define local_prefixes_v6 = [
	2a01:4262:1ab::/48,
	2a10:2a80:ac::/48,
	2a10:2a80:1ab::/48,
	2001:678:15c::/48,
	2a0e:8f02:f034::/48
];

define asbjorn_prefixes_v4 = [
	194.165.56.0/24,
	194.165.58.0/24
];

define asbjorn_prefixes_v6 = [
	2a10:2a80:ac::/48,
	2a10:2a80:1ab::/48
];

define graffen_prefixes_v4 = [
	44.145.128.0/24
];

define graffen_prefixes_v6 = [
	2001:678:15c::/48
];

define hafnium_prefixes_v6 = [
	2a0e:8f02:f034::/48
];

# functions and filters

function is_default_route() {
	case net.type {
		NET_IP4: if net = 0.0.0.0/0 then return true;
		NET_IP6: if net = ::/0 then return true;
	}
	return false;
}

function is_customer_route() {
	case net.type {
		NET_IP4: if net ~ local_prefixes_v4 then return true;
		NET_IP6: if net ~ local_prefixes_v6 then return true;
	}
	return false;
}

filter kernel_export {
	if source !~ [ RTS_BGP, RTS_STATIC ] then reject;
	if is_default_route() then accept;
	if is_customer_route() then accept;
	reject;
}

function honor_graceful_shutdown()
{
	# RFC 8326 Graceful BGP Session Shutdown
	if (65535, 0) ~ bgp_community then {
		bgp_local_pref = 0;
	}
}

filter transit_import {
	honor_graceful_shutdown();
	accept;
}

filter transit_export {
	if is_customer_route() then accept;
	reject;
}

# generate local routes
protocol static static4 {
	ipv4;
	route 185.38.175.0/24 unreachable;
}

protocol static static6 {
	ipv6;
	route 2a01:4262:1ab::/48 unreachable;
}

# customer import
function customer_import(int peer_asn; prefix set peer_prefixes) {
	if net !~ peer_prefixes then reject;
	if bgp_path.first != peer_asn then reject;
	accept;
}

# customer export functions
function customer_export_default_only() {
	if !is_default_route() then reject;
	accept;
}

function customer_export_dfz() {
	if source !~ [ RTS_BGP, RTS_STATIC ] then reject;
	if is_default_route() then reject;
	accept;
}

function customer_export_and_default() {
	if is_default_route() then {
		customer_export_default_only();
	} else {
		customer_export_dfz();
	}
}


# define basic protocols
protocol device {}

protocol direct {
	ipv4;
	ipv6;
}

protocol kernel kernel4 {
	ipv4 {
		import none;
		export filter kernel_export;
	};
	learn;
	persist;
	graceful restart;
	merge paths;
}

protocol kernel kernel6 {
	ipv6 {
		import none;
		export filter kernel_export;
	};
	learn;
	persist;
	graceful restart;
	merge paths;
}


# templates
template bgp bgp_customer {
	default bgp_local_pref 150;
}

template bgp bgp_transit_v4 {
	default bgp_local_pref 100;
	ipv4 {
		import limit off;
		receive limit off;
		import keep filtered on;
		import filter transit_import;
		export filter transit_export;
	};
}

template bgp bgp_transit_v6 {
	default bgp_local_pref 100;
	ipv6 {
		import limit off;
		receive limit off;
		import keep filtered on;
		import filter transit_import;
		export filter transit_export;
	};
}

# Transit
protocol bgp fiberby_tgc_v4 from bgp_transit_v4 {
	local 193.106.167.41 as local_asn;
	neighbor 193.106.167.40 as fiberby_asn;
}

protocol bgp fiberby_inx_v4 from bgp_transit_v4 {
	local 193.106.167.43 as local_asn;
	neighbor 193.106.167.42 as fiberby_asn;
}

protocol bgp fiberby_tgc_v6 from bgp_transit_v6 {
	local 2a03:5440:1:2935:1ab:1::2 as local_asn;
	neighbor 2a03:5440:1:2935:1ab:1::1 as fiberby_asn;
}

protocol bgp fiberby_inx_v6 from bgp_transit_v6 {
	local 2a03:5440:1:2935:1ab:2::2 as local_asn;
	neighbor 2a03:5440:1:2935:1ab:2::1 as fiberby_asn;
}

# BGP customer: asbjorn
protocol bgp asbjorn_ipv4 from bgp_customer {
	local 185.38.175.65 as local_asn;
	neighbor 185.38.175.75 as asbjorn_asn;
	ipv4 {
		import limit 10 action block;
		receive limit 20 action disable;
		import keep filtered on;
		import filter { customer_import(asbjorn_asn, asbjorn_prefixes_v4); };
		export filter { customer_export_default_only(); };
	};
}

protocol bgp asbjorn_ipv6 from bgp_customer {
	local 2a01:4262:1ab:20::1 as local_asn;
	neighbor 2a01:4262:1ab:20::75 as asbjorn_asn;
	ipv6 {
		import limit 10 action block;
		receive limit 20 action disable;
		import keep filtered on;
		import filter { customer_import(asbjorn_asn, asbjorn_prefixes_v6); };
		export filter { customer_export_default_only(); };
	};
}

# BGP customer: graffen
protocol bgp graffen_ipv4 from bgp_customer {
	local 185.38.175.65 as local_asn;
	neighbor 185.38.175.78 as graffen_asn;
	ipv4 {
		import limit 10 action block;
		receive limit 20 action disable;
		import keep filtered on;
		import filter { customer_import(graffen_asn, graffen_prefixes_v4); };
		export filter { customer_export_and_default(); };
	};
}

protocol bgp graffen_ipv6 from bgp_customer {
	local 2a01:4262:1ab:20::1 as local_asn;
	neighbor 2a01:4262:1ab:20::78 as graffen_asn;
	ipv6 {
		import limit 10 action block;
		receive limit 20 action disable;
		import keep filtered on;
		import filter { customer_import(graffen_asn, graffen_prefixes_v6); };
		export filter { customer_export_and_default(); };
	};
}

# BGP customer: hafnium
protocol bgp hafnium_ipv6 from bgp_customer {
	local 2a01:4262:1ab:20::1 as local_asn;
	neighbor 2a01:4262:1ab:20::81 as hafnium_asn;
	ipv6 {
		import limit 10 action block;
		receive limit 20 action disable;
		import keep filtered on;
		import filter { customer_import(hafnium_asn, hafnium_prefixes_v6); };
		export filter { customer_export_and_default(); };
	};
}