-
Notifications
You must be signed in to change notification settings - Fork 3
/
bird_route_server.conf
115 lines (95 loc) · 2.79 KB
/
bird_route_server.conf
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
# BIRD 2 configuration for ASxxxxx LABIX
# The config is based on the AF-IX template from https://www.af-ix.net/resources/2015/05/template-bird-route-server-configuration
log "/var/log/bird.log" all;
log syslog all;
# Globally unique ID. Typically public IPv4 address
router id 123.124.125.126;
define local_asn = 12345;
# Client ASNs
define hafnium_asn = 211153
define labitat_asn = 205235;
define asbjorn_asn = 207727;
# Route share servers
define bgptool_asn = 212232;
protocol device { }
# The following function excludes weird networks such as
# RFC1918, class D, class E, and too long or too short prefixes
function avoid_martians()
prefix set martians;
{
martians_v4 = [ 169.254.0.0/16+, 172.16.0.0/12+, 192.168.0.0/16+, 10.0.0.0/8+,
224.0.0.0/4+, 240.0.0.0/4+, 0.0.0.0/32-, 0.0.0.0/0{25,32}, 0.0.0.0/0{0,7} ];
## Gotten from https://bgpfilterguide.nlnog.net/guides/bogon_prefixes/#bird-1
martians_v6 = [ ::/8+, 0100::/64+, 2001:2::/48+, 2001:10::/28+, 2001:db8::/32+,
2002::/16+, 3ffe::/16+, fc00::/7+, fe80::/10+, fec0::/10+, ff00::/8+ ];
case net.type {
NET_IP4: if net ~ martians_v4 then return false;
NET_IP6: if net ~ martians_v6 then return false;
}
return true;
}
### Routeable prefix size
function reject_small_prefixes()
{
case net.type {
NET_IP4: if (net.len) > 24 then {
print "Reject: Too small prefix: ", net, " ", bgp_path;
return false;
}
NET_IP6: if (net.len > 48) then {
print "Reject: Too small prefix: ", net, " ", bgp_path;
return false;
}
}
return true;
}
### Protocol Template
template bgp PEERS {
local as local_asn;
import all;
export all;
route limit 10000;
rs client;
}
### Generic Input Filter
filter bgp_in {
if avoid_martians() && reject_small_prefixes() then accept;
else reject;
}
### BGP output filter (based on communities)
function bgp_out(int peeras)
{
if ! (source = RTS_BGP ) then return false;
if peeras > 65535 then return true; ### communities do not support AS32
if (0,peeras) ~ bgp_community then return false;
if (local_asn,peeras) ~ bgp_community then return true;
if (0, local_asn) ~ bgp_community then return false;
return true;
}
# Clients
protocol bgp hafnium_peer from PEERS {
description "hafnium_peer - peer 1";
neighbor 123.124.125.200 as hafnium_asn;
import filter bgp_in;
export where bgp_out(hafnium_asn);
}
protocol bgp asbjorn_peer from PEERS {
description "asbjorn_peer - peer 2";
neighbor 123.124.125.201 as asbjorn_asn;
import filter bgp_in;
export where bgp_out(asbjorn_asn);
}
protocol bgp R_65432 from PEERS {
description "R_65432 - peer 3";
neighbor 123.124.125.202 as 65432;
import filter bgp_in;
export where bgp_out(65432);
}
protocol bgp R_54321 from PEERS {
description "R_54321 - peer 4";
neighbor 123.124.125.203 as 54321;
import filter bgp_in;
export where bgp_out(54321);
}
# Route Share
## Todo: Add BGP.tools