forked from areyer/ffs-make-gateway
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_bird.sh
92 lines (89 loc) · 2.9 KB
/
setup_bird.sh
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
setup_bird() {
cat <<-EOF >/etc/bird/bird_routerid.conf
router id router id 10.191.255.$GWID;
EOF
cat <<-EOF >/etc/bird/bird_kernel_stuttgart.conf
table tk_stuttgart;
protocol kernel k_stuttgart {
learn; # Learn all alien routes from the kernel
persist; # Don't remove routes on bird shutdown
scan time 20; # Scan kernel routing table every 20 seconds
import all; # Default is import all
kernel table 70; # Kernel table to synchronize with (default: main)
table tk_stuttgart;
export filter {
if net = 0.0.0.0/0 then { # no default route
reject;
}
krt_metric = 100;
accept;
};
device routes;
}
EOF
cat <<-EOF >/etc/bird/bird_device.conf
protocol device {
scan time 10; # Scan interfaces every 10 seconds
table tk_stuttgart
}
EOF
cat <<-EOF >/etc/bird/bird_ospf_stuttgart.conf
protocol ospf ffsBackbone {
table tk_stuttgart;
preference 100;
import filter {
# Wir lennen alles was eine Netzmaske /8 oder schlechter hat:
if net ~ [ 0.0.0.0/0{0,7} ] then reject;
accept;
};
export filter {
# Wir lennen alles was eine Netzmaske /8 oder schlechter hat:
if net ~ [ 0.0.0.0/0{0,7} ] then reject;
accept;
ospf_metric1 = 100;
};
rfc1583compat no; # Metrik gem. OSPFv2, RFC 2328
stub router no; # Box macht ggf. auch Transit-Traffic
tick 1; # Topologie-Berechnungen nur alle 1s
ecmp no; # Kein Equal-Cost-Multipath, um Problemen mit unterschiedlichen
# Uplinks aus dem Weg zu gehen
area 0.0.0.0 { # Backbone-Area
external {
0.0.0.0/0;
};
interface "ffsl3" {
cost 100;
hello 10;
poll 20;
retransmit 5;
priority 10;
wait 40;
type bcast;
authentication cryptographic;
password "ffsVPN00";
};
};
};
EOF
if grep -q "router id 10.191.255.$GWID;" /etc/bird/bird.conf; then
sed -i 's/^router id .*/router id 10.191.255.'$(($GWID*10+$GWSUBID))';/' /etc/bird/bird.conf
fi
if grep -q "router id 10.191.255.$GWID;" /etc/bird/bird6.conf; then
sed -i 's/^router id .*/router id 10.191.255.'$(($GWID*10+$GWSUBID))';/' /etc/bird/bird6.conf
fi
if [ ! -z $IP6 ]; then
cat <<-EOF > /etc/bird/bird6_ffs.conf
# autogenerated by ffs-make-gw
protocol static static_ffs {
table tk_stuttgart;
EOF
for seg in $SEGMENTLIST ; do
seghex=$(printf %02x ${seg#0})
segdec=$(printf %02d ${seg#0})
echo " route $IP6$seghex::/64 via \"br$segdec\";" >> /etc/bird/bird6_ffs.conf
done
echo } >> /etc/bird/bird6_ffs.conf
fi
systemctl enable bird
systemctl enable bird6
}