From cbb890e29783e13466ead2696345a4a628417bf6 Mon Sep 17 00:00:00 2001 From: Oliver Lorenz Date: Tue, 1 Sep 2026 23:13:11 +0200 Subject: [PATCH] BIRD-Config nach Ansible auslagern (ffc-mash ffc_vpn_gateway) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die BIRD-/BIRD6-Konfiguration wird nicht mehr zur Laufzeit von lib/bird.sh / lib/bird6.sh aus conf/bird*.conf per sed gerendert, sondern vom Ansible-Playbook ffc-mash (Rolle ffc_vpn_gateway) nach /etc/bird/ deployt; bird/bird6 laufen jetzt als von Ansible verwaltete systemd-Dienste. - lib/bird.sh / lib/bird6.sh: nur noch Policy-Routing (Tabelle 100) + NAT; bird_start/bird_stop delegieren an systemctl. Config-Rendering, BGP-Peer- und Routen-Funktionen sowie das Country-Route-Rendering entfernt. - lib/radvd.sh: die ::/0-Default-Route in BIRD6 kommt jetzt aus der Rolle (ffc_vpn_gateway_bird_ipv6_uplink). - conf/: bird.conf, bird6.conf, bird-peers.conf, bird-routes.conf und conf/routes/ entfernt; COUNTRY/WANGW aus general.conf raus; .gitignore aufgeräumt. - docs/: Architektur, Backbone, Betrieb, Komponenten, Sicherheitsmodell, IP-Adressplan und README auf die neue Aufteilung angepasst. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_011ZtqGKZgfboGn2VEZzAhsY --- README.md | 35 ++++++++------- conf/.gitignore | 1 - conf/bird-peers.conf | 3 -- conf/bird-routes.conf | 1 - conf/bird.conf | 37 ---------------- conf/bird6.conf | 36 ---------------- conf/general.conf | 8 ++-- conf/routes/DE.conf | 8 ---- conf/routes/README.md | 45 -------------------- conf/routes/_global.conf | 10 ----- docs/architektur.md | 33 +++++++-------- docs/backbone-netzwerk.md | 45 +++++++++++--------- docs/betrieb.md | 10 +++-- docs/ip-adressplan.md | 11 ++--- docs/komponenten.md | 23 +++++----- docs/sicherheitsmodell.md | 12 +++--- lib/bird.sh | 89 +++++---------------------------------- lib/bird6.sh | 75 ++++----------------------------- lib/radvd.sh | 5 ++- 19 files changed, 116 insertions(+), 371 deletions(-) delete mode 100644 conf/bird-peers.conf delete mode 100644 conf/bird-routes.conf delete mode 100644 conf/bird.conf delete mode 100644 conf/bird6.conf delete mode 100644 conf/routes/DE.conf delete mode 100644 conf/routes/README.md delete mode 100644 conf/routes/_global.conf diff --git a/README.md b/README.md index 28b8e0f..03ddb0d 100644 --- a/README.md +++ b/README.md @@ -56,16 +56,15 @@ Ist ein Routing Deamon zur Verbindung mit anderen Netzen. # aptitude install bird ``` -Wenn sys-V-init verwendet wird: -``` -# update-rc.d bird disable -# update-rc.d bird6 disable -``` +Die BIRD-/BIRD6-Konfiguration (`/etc/bird/bird.conf`, `/etc/bird/bird6.conf`, +`/etc/bird/bird-routes.country.conf`) und die `bird`/`bird6`-Dienste werden vom +Ansible-Playbook [ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) verwaltet +(Rolle `ffc_vpn_gateway`), nicht von diesen Skripten. `lib/bird.sh` / `lib/bird6.sh` +richten nur noch das Policy-Routing (Tabelle 100) und NAT ein. -Wenn systemd verwendet wird: ``` -# systemctl disable bird -# systemctl disable bird6 +# systemctl enable bird +# systemctl enable bird6 ``` @@ -136,19 +135,18 @@ Wenn systemd verwendet wird: ``` cd /opt/freifunk/server-scripts/conf -cp bird.conf bird.local.conf -cp bird-routes.conf bird-routes.local.conf cp dnsmasq.conf dnsmasq.local.conf cp general.conf general.local.conf -touch bird-routes.local.conf ``` -#### bird.local.conf -In der `bird.local.conf` muss `__BIRD_ROUTER_ID__` angepasst werden. Es ist mit mit 169.254.x.y zu ersetzen, wobei x das 3. Oktet und y das 4. Oktet der öffentlichen IPv4 des Servers sind. Wenn der Server die öffentliche IPv4 5.199.142.119 hat, wäre das 169.254.142.119. - -`__BIRD_ROUTER_ASN__` muss durch das 3. und 4. Oktet der öffentlichen IPv4 ersetzt werden, wobei der Punkt wegzulassen ist. Zum Beispiel wird aus 5.199.142.119 dann 142119. +#### BIRD / BGP -Auf Servern, die für das Chemnitzer Umland bestimmt sind ist das `route` unter `protocol static` anzupassen. Es muss auf `10.149.16.0/20` geändert werden. +Die BIRD-Konfiguration wird nicht mehr hier gepflegt, sondern vom Ansible-Playbook +[ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) (Rolle `ffc_vpn_gateway`) +nach `/etc/bird/` gerendert – inklusive Router-ID/ASN (aus der öffentlichen IPv4), +BGP-Peers, Mesh-Route (Umland: `ffc_vpn_gateway_bird_mesh_route_v4: 10.149.16.0/20`) +und der statischen Länder-/Ausnahmerouten. `lib/bird.sh` richtet nur noch +Policy-Routing (Tabelle 100) und NAT ein. #### dnsmasq.local.conf @@ -173,8 +171,9 @@ USE_RADVD="0" USE_MESHVIEWER="0" ``` -`COUNTRY` ist auf den 2 stelligen ISO-Code des Landes zu ändern, in dem der Server betrieben wird. Er wählt die passende Datei `conf/routes/.conf` mit den länderspezifischen Ausnahmerouten aus (zusätzlich zu `conf/routes/_global.conf`). Existiert keine solche Datei, werden nur die globalen Routen gerendert. -`WANGW` ist das IPv4 Gateway des Server (`ip route show`). Über dieses Gateway werden die Ausnahmerouten aus `conf/routes/` geroutet (Platzhalter `NEXTHOP`). Ist `WANGW` leer, bleibt `conf/bird-routes.country.conf` leer. +Das Land des Servers (früher `COUNTRY`) und die Länder-/Ausnahmerouten werden jetzt +im ffc-mash-Playbook gepflegt (`ffc_vpn_gateway_country`, +`roles/custom/ffc_vpn_gateway/files/bird-routes/`). `GRE_PEERS`, `LOG_DEBUG`, `LOG_TO` sollte gelöscht werden. diff --git a/conf/.gitignore b/conf/.gitignore index 296b4e9..3f056f9 100644 --- a/conf/.gitignore +++ b/conf/.gitignore @@ -1,2 +1 @@ /*.local.* -/bird-routes.country.conf diff --git a/conf/bird-peers.conf b/conf/bird-peers.conf deleted file mode 100644 index 035e6ed..0000000 --- a/conf/bird-peers.conf +++ /dev/null @@ -1,3 +0,0 @@ -protocol bgp __BIRD_REMOTE_HOST__ from intern { - neighbor __BIRD_REMOTE_IP__ as __BIRD_REMOTE_ASN__; -} diff --git a/conf/bird-routes.conf b/conf/bird-routes.conf deleted file mode 100644 index 1c87589..0000000 --- a/conf/bird-routes.conf +++ /dev/null @@ -1 +0,0 @@ -route __BIRD_ROUTE__ via __BIRD_VIA__; diff --git a/conf/bird.conf b/conf/bird.conf deleted file mode 100644 index a661a48..0000000 --- a/conf/bird.conf +++ /dev/null @@ -1,37 +0,0 @@ -router id __BIRD_ROUTER_ID__; - -table ffc; - -protocol kernel kffc { - learn; - scan time 300; - import all; - export all; - table ffc; - kernel table 100; -} - -protocol static { - import all; - export all; - table ffc; - - route __WANIP__/32 via "__WANIF__"; - route 10.149.0.0/20 via "bat0"; - include "bird-routes.local.conf"; - include "bird-routes.country.conf"; -} - -protocol device { - scan time 300; -} - -template bgp intern{ - table ffc; - import all; - export all; - source address __BIRD_ROUTER_ID__; - local as __BIRD_ROUTER_ASN__; -} - -include "bird-peers.local.conf"; diff --git a/conf/bird6.conf b/conf/bird6.conf deleted file mode 100644 index f31f5bc..0000000 --- a/conf/bird6.conf +++ /dev/null @@ -1,36 +0,0 @@ -router id __BIRD_ROUTER_ID__; -listen bgp v6only; - -table ffc; - -protocol kernel kffc { - learn; - scan time 300; - import all; - export all; - table ffc; - kernel table 100; -} - -protocol static { - import all; - export all; - table ffc; - - route 2001:bc8:3f13:ffc2::/64 via "bat0"; - include "bird6-routes.local.conf"; -} - -protocol device { - scan time 300; -} - -template bgp intern{ - table ffc; - import all; - export all; - source address __BIRD_ROUTER_IP__; - local as __BIRD_ROUTER_ASN__; -} - -include "bird6-peers.local.conf"; diff --git a/conf/general.conf b/conf/general.conf index 53284ff..5e658f7 100644 --- a/conf/general.conf +++ b/conf/general.conf @@ -19,8 +19,6 @@ BATMAN_IFS=("gre-brewster" "gre-spooner" "gre-hawking" "gre-noether") LOG_DEBUG="0" LOG_TO="crew@chemnitz.freifunk.net" -# Static country/exception routes for BIRD (see conf/routes/). -# COUNTRY selects conf/routes/.conf; WANGW is the local WAN gateway -# that these routes are sent via (NEXTHOP placeholder). -COUNTRY="DE" -WANGW="" +# BIRD/BGP daemon config (incl. the static country/exception routes) is managed by +# the ffc-mash Ansible playbook (ffc_vpn_gateway role), not by these scripts. +# USE_BIRD above only toggles the kernel policy routing / NAT in lib/bird.sh. diff --git a/conf/routes/DE.conf b/conf/routes/DE.conf deleted file mode 100644 index 5ac4c3e..0000000 --- a/conf/routes/DE.conf +++ /dev/null @@ -1,8 +0,0 @@ -# Westsaechsische Hochschule Zwickau -route 141.32.0.0/16 via NEXTHOP; -# Technische Universitaet Chemnitz -route 192.108.33.0/24 via NEXTHOP; -# Technische Universitaet Chemnitz -route 134.109.0.0/16 via NEXTHOP; -# Hochschule fuer Technik und Wirtschaft Mittweida (FH) -route 141.55.0.0/16 via NEXTHOP; diff --git a/conf/routes/README.md b/conf/routes/README.md deleted file mode 100644 index d9000ea..0000000 --- a/conf/routes/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# conf/routes/ – statische Ausnahme-/Länderrouten für BIRD (IPv4) - -Diese Dateien ersetzen den früheren Laufzeit-Abruf von -`http://api.chemnitz.freifunk.net/request.php?region=$COUNTRY` (siehe -[Issue #7](https://github.com/FreifunkChemnitz/server-scripts/issues/7)). -Sie werden im Repo gepflegt und beim Setup (`ffc_start` → `bird_init`) zu -`conf/bird-routes.country.conf` gerendert. - -Damit entfällt der einzige Consumer von `request.php`; das ist die Voraussetzung, -um `api.chemnitz.freifunk.net` zu dockerisieren bzw. ins Mash-Playbook zu -überführen und das `routing-backend` (PHP/Smarty + MySQL auf curie) abzukündigen – -[ffc-mash#55](https://github.com/FreifunkChemnitz/ffc-mash/issues/55). Diese generierte Datei ist in -`conf/.gitignore` und wird von `conf/bird.conf` per -`include "bird-routes.country.conf"` in `protocol static` eingebunden. - -## Dateien - -| Datei | Gilt für | Herkunft (alte DB `ffc_network.routing`) | -|--------------------|---------------------------------------|------------------------------------------| -| `_global.conf` | jeden Gateway, unabhängig von `COUNTRY` | `region IS NULL` bzw. `region='XX'` | -| `.conf` | Gateways mit `COUNTRY=""` | `region=''` (z. B. `DE.conf`) | - -## Rendering - -`bird_init` baut `conf/bird-routes.country.conf` als -`_global.conf` + `.conf` (falls vorhanden) und ersetzt anschließend -den Platzhalter `NEXTHOP` durch das lokale WAN-Gateway `$WANGW` -(`sed "s/NEXTHOP/$WANGW/g"`). Ohne gesetztes `$WANGW` bleibt die Datei leer. - -## Format - -BIRD-`protocol static`-Syntax, ein Prefix pro Zeile: - -``` -# Beschreibung -route 203.0.113.0/24 via NEXTHOP; # über lokales WAN-Gateway routen -route 198.51.100.0/24 prohibit; # überall blackholen (gehört in _global.conf) -``` - -## Ändern - -1. Datei bearbeiten, committen, deployen. -2. Auf einem Gateway `ffc_start` (bzw. Neustart) löst das Re-Rendern aus. - BIRD lädt die neue Konfiguration; ein manueller Reload geht per - `birdc configure` oder `killall bird -s SIGHUP`. diff --git a/conf/routes/_global.conf b/conf/routes/_global.conf deleted file mode 100644 index 1d312d4..0000000 --- a/conf/routes/_global.conf +++ /dev/null @@ -1,10 +0,0 @@ -# Wikimedia Foundation Inc -route 91.198.174.0/24 via NEXTHOP; -# Wikimedia Foundation Inc -route 208.80.152.0/22 via NEXTHOP; -# Mozilla Corp -route 63.245.208.0/20 via NEXTHOP; -# Github -route 192.30.252.0/22 via NEXTHOP; -# Github -route 204.232.128.0/17 via NEXTHOP; diff --git a/docs/architektur.md b/docs/architektur.md index 671af5f..4ed6326 100644 --- a/docs/architektur.md +++ b/docs/architektur.md @@ -14,8 +14,7 @@ und per Cron überwacht werden. | `ffc-server.sh` | Zentrales Steuerskript: `start`, `stop`, `watchdog`. Lädt Konfiguration und alle `lib/*.sh`-Module. | | `initd-ffc.sh` | Dünner Wrapper, der `ffc-server.sh` als `/etc/init.d/ffc` einbindet (SysV-Init). | | `lib/*.sh` | Ein Modul pro Dienst/Funktion (siehe unten). Jedes Modul stellt `_init`, `_start`, `_stop` und optional `_cron` bereit. | -| `conf/*.conf` | Eingecheckte Vorlagen/Defaults. Pro Server werden daraus `*.local.conf`-Dateien erzeugt bzw. von Hand angelegt (siehe `conf/.gitignore`: `*.local.*` und `bird-routes.country.conf` sind lokal/generiert und nicht versioniert). | -| `conf/routes/*.conf` | Statisch gepflegte BIRD-Ausnahme-/Länderrouten (`_global.conf` + `.conf`), die `bird_init` zu `conf/bird-routes.country.conf` rendert. | +| `conf/*.conf` | Eingecheckte Vorlagen/Defaults. Pro Server werden daraus `*.local.conf`-Dateien erzeugt bzw. von Hand angelegt (siehe `conf/.gitignore`: `*.local.*` ist lokal/generiert und nicht versioniert). Die BIRD-Konfiguration liegt **nicht** mehr hier, sondern im Ansible-Playbook [ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) (Rolle `ffc_vpn_gateway`, Ziel `/etc/bird/`). | ## Die Module in `lib/` @@ -28,9 +27,9 @@ ihrem Zweck findet sich in [Komponenten](komponenten.md). | `gre.sh` | Aufbau der GRE-Tunnel (`gretap`) zu allen anderen Backbone-Servern aus `GRE_PEERS`; Watchdog-Check per ICMPv6-Ping auf die Tunnel-Interfaces. | | `batman.sh` | Initialisiert `batman-adv`, hängt die GRE-Interfaces (aus `BATMAN_IFS`) und später `fastd`-Interfaces als Slaves ein, konfiguriert `bat0` (Service-Adressen, Bridge-Loop-Avoidance, Bonding, Gateway-Modus) und startet `alfred`/`batadv-vis` für die Meshviewer-Daten. | | `fastd.sh` | Startet das fastd-VPN (einen Prozess pro CPU-Kern, jeweils auf eigenem Port), über das sich Freifunk-Router mit dem Server verbinden. | -| `bird.sh` / `bird6.sh` | Generieren die BIRD-/BIRD6-Konfiguration aus Templates (`conf/bird*.conf`), tragen alle GRE-Peers als BGP-Nachbarn ein, setzen Policy-Routing (`ip rule`/`ip -6 rule`) für das Mesh-Netz und starten die Routing-Daemons. | +| `bird.sh` / `bird6.sh` | Setzen das Policy-Routing (`ip rule`/`ip -6 rule` → Tabelle 100) und NAT für das Mesh-Netz und starten/stoppen die `bird`/`bird6`-Dienste (via systemd). Die BIRD-Konfiguration selbst (Router-ID, BGP-Peers, Routen) wird vom Ansible-Playbook [ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) (Rolle `ffc_vpn_gateway`) nach `/etc/bird/` gerendert. | | `dnsmasq.sh` | DHCP/DNS für Endgeräte im Mesh (`bat0`), optional, nur auf Servern mit `USE_DNSMASQ=1`. | -| `radvd.sh` | IPv6 Router Advertisements für `bat0`, nur auf IPv6-Gateway-Servern (`USE_RADVD=1`), setzt zusätzlich eine Default-Route in BIRD6. | +| `radvd.sh` | IPv6 Router Advertisements für `bat0`, nur auf IPv6-Gateway-Servern (`USE_RADVD=1`). Die zugehörige IPv6-Default-Route in BIRD6 kommt aus der Ansible-Rolle (`ffc_vpn_gateway_bird_ipv6_uplink`). | | `meshviewer.sh` | Startet `alfred`/`batadv-vis` unabhängig von `batman.sh`, falls der Server primär als Meshviewer-Datenquelle dient. | ## Ablauf: Start, Stop, Watchdog @@ -74,27 +73,27 @@ Wichtige Details zum Ablauf: - **Watchdog:** `ffc-server.sh watchdog` wird minütlich per Cron aufgerufen (siehe README). Jede Minute werden laufende Prozesse (dnsmasq, radvd, alfred) geprüft und bei Bedarf neu gestartet; alle 5 Minuten wird zusätzlich die Erreichbarkeit der GRE-Tunnel per Ping - geprüft und die länderspezifische Routen-Datei von der Freifunk-Chemnitz-API neu geladen. - Fehler werden über `log_error`/`log_fatal_error` sowohl nach syslog als auch (im + geprüft. Fehler werden über `log_error`/`log_fatal_error` sowohl nach syslog als auch (im Watchdog-Kontext) per Mail an `LOG_TO` gemeldet. -- **Konfigurations-Templating:** `bird.sh`, `bird6.sh` und `dnsmasq.sh` erzeugen aus den - eingecheckten `conf/*.conf`-Vorlagen (Platzhalter wie `__BIRD_ROUTER_ID__`, - `__DNSMASQ_SERVICE_IP__`) bei jedem Start neue `*.local.conf`-Dateien anhand der Werte aus - `general.local.conf` — die eingecheckten Vorlagen sind also keine fertigen Configs, - sondern Templates. +- **Konfigurations-Templating:** `dnsmasq.sh` erzeugt aus der eingecheckten + `conf/dnsmasq.conf`-Vorlage (Platzhalter wie `__DNSMASQ_SERVICE_IP__`) bei jedem Start + eine `*.local.conf`-Datei anhand der Werte aus `general.local.conf`. Die + BIRD-/BIRD6-Konfiguration wird dagegen vom Ansible-Playbook + [ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) gerendert (Rolle + `ffc_vpn_gateway` → `/etc/bird/`), nicht mehr zur Laufzeit hier. ## Kopplung zwischen den Modulen Die Module sind nicht unabhängig, sondern bauen aufeinander auf: -- `bird.sh`/`bird6.sh` iterieren über dieselbe `GRE_PEERS`-Liste wie `gre.sh`, um pro - GRE-Tunnel eine BGP-Session zum jeweiligen Nachbarserver zu konfigurieren. +- Die Ansible-Rolle `ffc_vpn_gateway` leitet die BGP-Peers aus derselben Server-Menge + (Inventory-Gruppe `routers`) ab wie die GRE-Vollvermaschung, sodass pro GRE-Tunnel eine + BGP-Session zum jeweiligen Nachbarserver besteht. `bird.sh`/`bird6.sh` selbst richten nur + das Policy-Routing (Tabelle 100) ein. - `batman.sh` bindet die von `gre.sh` erzeugten Interfaces (`BATMAN_IFS`) sowie die von `fastd.sh` erzeugten Client-Tunnel in dieselbe batman-adv-Instanz (`bat0`) ein. -- `radvd.sh` erfordert `USE_BIRD=1` und trägt seine Default-Route direkt in BIRD6 ein - (`bird6_add_route`). -- `dnsmasq.sh` und die BGP-Konfiguration nutzen dieselben `SERVICE_ADDRESSES` (die - Dnsmasq-Gateway-Adresse wird zugleich als Route über BIRD announced). +- `radvd.sh` erfordert `USE_BIRD=1`; die zugehörige IPv6-Default-Route in BIRD6 wird über + die Ansible-Rolle gesetzt (`ffc_vpn_gateway_bird_ipv6_uplink`). Das Zusammenspiel dieser Module ergibt das eigentliche Backbone-Netz — siehe [Backbone-Netzwerk](backbone-netzwerk.md) für die konzeptionelle Erklärung. diff --git a/docs/backbone-netzwerk.md b/docs/backbone-netzwerk.md index 9aa4e16..b0d76c6 100644 --- a/docs/backbone-netzwerk.md +++ b/docs/backbone-netzwerk.md @@ -136,32 +136,37 @@ Ausfallsicherheit über mehrere, unterschiedlich angebundene Server hinweg zu or Dafür betreibt jeder Server **BIRD** (IPv4) und **BIRD6** (IPv6) — je einen eigenen BGP-Router: -- `lib/bird.sh`/`lib/bird6.sh` tragen für **jeden** GRE-Peer eine eigene interne - BGP-Session ein (`template bgp intern`), die genau über die Link-Local-Adressen des - jeweiligen GRE-Tunnels läuft. Damit hat jeder Server eine direkte BGP-Session zu jedem - anderen Server — eine [BGP-Vollvermaschung](#grundlagen-was-ist-eine-vollvermaschung) - passend zur GRE-Vollvermaschung. +- Die BIRD-Konfiguration wird vom Ansible-Playbook + [ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) erzeugt (Rolle `ffc_vpn_gateway` + → `/etc/bird/`). Für **jeden** Server aus der Inventory-Gruppe `routers` wird eine eigene + interne BGP-Session eingetragen (`template bgp intern`), die genau über die + Link-Local-Adressen des jeweiligen GRE-Tunnels läuft. Damit hat jeder Server eine direkte + BGP-Session zu jedem anderen Server — eine + [BGP-Vollvermaschung](#grundlagen-was-ist-eine-vollvermaschung) passend zur + GRE-Vollvermaschung. - Jeder Server bekommt eine Router-ID/AS-Nummer, die aus seiner öffentlichen IP abgeleitet wird (`169.254.<3.Oktett>.<4.Oktett>` bzw. AS `<3.Oktett><4.Oktett>`) — ein einfaches, kollisionsfreies Schema ganz ohne zentrale IP-/AS-Vergabe. - Über BGP announcen die Server sich gegenseitig Routen: die eigene öffentliche IP - (`__WANIP__/32`), das Mesh-Netz (`10.149.0.0/20`), die konfigurierten Service-Adressen - sowie — nur auf Servern mit `USE_RADVD=1` — eine IPv6-Default-Route über den eigenen - Internet-Uplink (`radvd_add_route "::/0" "$WANGW6" "$WANIF"`). + (`/32`), das Mesh-Netz (`10.149.0.0/20`, Umland `10.149.16.0/20`), die + konfigurierten Service-Adressen sowie — auf IPv6-Uplink-Servern + (`ffc_vpn_gateway_bird_ipv6_uplink`) — eine IPv6-Default-Route über den eigenen + Internet-Uplink. - Damit ein Server für Mesh-Verkehr eine **eigene Routingtabelle** neben der normalen - Internet-Routingtabelle nutzt, richtet `bird_init`/`bird6_init` Policy-Routing ein - (`ip rule` für `10.149.0.0/16` bzw. `ip -6 rule` für `ffc2::/64`/`ffc3::/64`, + Internet-Routingtabelle nutzt, richtet `bird_init`/`bird6_init` (in `lib/`) Policy-Routing + ein (`ip rule` für `10.149.0.0/16` bzw. `ip -6 rule` für `ffc2::/64`/`ffc3::/64`, Ziel-Tabelle `100`) und BIRD selbst schreibt seine gelernten Routen in genau diese Tabelle (`kernel table 100`). So kann Mesh-Verkehr andere Pfade/Gateways nehmen als regulärer Internet-Verkehr des Servers. -- **Ausnahme-/Regionalrouten:** `bird_init` rendert beim Setup aus - `conf/routes/_global.conf` und `conf/routes/.conf` die Datei - `conf/bird-routes.country.conf` (Platzhalter `NEXTHOP` → `$WANGW`), die per `include` in - `protocol static` einfließt — so lassen sich einzelne Zielnetze gezielt über das lokale - WAN-Gateway statt übers Mesh routen (z. B. Uni-Netze, Wikimedia, GitHub). Die Routen - werden im Repo gepflegt (`conf/routes/`); früher wurden sie alle 5 Minuten per `bird_cron` - von `api.chemnitz.freifunk.net` nachgeladen (Issue #7). -- **NAT/Internet-Zugang:** `iptables -t nat -A POSTROUTING -o $WANIF -j MASQUERADE` sorgt +- **Ausnahme-/Regionalrouten:** Die Ansible-Rolle rendert aus + `files/bird-routes/_global.conf` und `files/bird-routes/.conf` die Datei + `/etc/bird/bird-routes.country.conf` (Platzhalter `NEXTHOP` → lokales WAN-Gateway), die + per `include` in `protocol static` einfließt — so lassen sich einzelne Zielnetze gezielt + über das lokale WAN-Gateway statt übers Mesh routen (z. B. Uni-Netze, Wikimedia, GitHub). + Die Routen werden im ffc-mash-Playbook gepflegt; früher wurden sie alle 5 Minuten per + `bird_cron` von `api.chemnitz.freifunk.net` nachgeladen (Issue #7). +- **NAT/Internet-Zugang:** `iptables -t nat -A POSTROUTING -o $WANIF -j MASQUERADE` (in + `lib/bird.sh`) sorgt dafür, dass Mesh-Clients über die öffentliche IP des jeweiligen Servers ins Internet können, wenn dieser Server als ihr Gateway gewählt wird. @@ -174,8 +179,8 @@ BGP-Router: Backbone-Server hinweg, mit denen der Router nie direkt verbunden ist. 3. Will der Router ins Internet, wählt er (bzw. das Mesh) einen Gateway-Server; dessen **BIRD/BIRD6**-Instanz hat über BGP von allen anderen Servern gelernt, welche Netze wie - erreichbar sind, trifft Routingentscheidungen (inkl. der statischen Ausnahmerouten aus - `conf/routes/`) und NATet den + erreichbar sind, trifft Routingentscheidungen (inkl. der statischen, per Ansible + gepflegten Ausnahmerouten) und NATet den Verkehr über die eigene öffentliche IP ins Internet. 4. Für Verkehr zwischen zwei Mesh-Teilnehmern an unterschiedlichen Servern reicht bereits die batman-adv-Ebene ([Layer 2](#grundlagen-was-ist-ein-layer-2-netz)) — BGP wird hier nur zur Verteilung der Dienst-/Uplink-Routen diff --git a/docs/betrieb.md b/docs/betrieb.md index 993e38c..d6a19cc 100644 --- a/docs/betrieb.md +++ b/docs/betrieb.md @@ -12,7 +12,9 @@ Die Peer-Liste `GRE_PEERS` ist eine **statische, pro Server gepflegte** Liste in Das ist die häufigste Fehlerquelle beim Hinzufügen eines neuen Servers: 1. Öffentliche IPv4 (`WANIP`) des neuen Servers festlegen und dessen - `general.local.conf`, `bird.local.conf` etc. wie in der README beschrieben einrichten. + `general.local.conf` wie in der README beschrieben einrichten. Die BIRD-Konfiguration + erzeugt das Ansible-Playbook [ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) + aus der Inventory-Gruppe `routers`. 2. Den neuen Server **auf jedem bereits bestehenden Backbone-Server** in dessen `GRE_PEERS` (und ggf. `BATMAN_IFS`, siehe [IP-Adressplan](ip-adressplan.md#regionen-chemnitz-und-umland)) eintragen — nicht nur in der Konfiguration des neuen Servers selbst. @@ -71,8 +73,10 @@ Vorgehen bei einer solchen Meldung: - `dnsmasq_cron`, `radvd_cron` (jede Minute): starten den jeweiligen Dienst still neu, falls er nicht läuft — ohne Logging oder Mail, auch bei Erfolg oder Misserfolg. -BIRD hat keine `*_cron`-Funktion mehr: die Ausnahme-/Regionalrouten werden beim Setup aus -`conf/routes/` gerendert, nicht mehr zur Laufzeit nachgeladen (Issue #7). +BIRD hat keine `*_cron`-Funktion mehr: die Ausnahme-/Regionalrouten werden vom +Ansible-Playbook [ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) beim Deploy +gerendert (`ffc_vpn_gateway`, `files/bird-routes/`), nicht mehr zur Laufzeit nachgeladen +(Issue #7). Eine Watchdog-Mail bedeutet also praktisch immer: ein GRE-Tunnel ist (vermeintlich) ausgefallen. diff --git a/docs/ip-adressplan.md b/docs/ip-adressplan.md index a60839c..7ee98e1 100644 --- a/docs/ip-adressplan.md +++ b/docs/ip-adressplan.md @@ -9,13 +9,14 @@ Dokument fasst nur die Zahlen an einem Ort zusammen. Das Freifunk-Chemnitz-Mesh ist in zwei Regionen mit eigenen Adressbereichen aufgeteilt: die Stadt Chemnitz und das „Chemnitzer Umland“. Ein Server wird durch seine Konfiguration -(`conf/bird.local.conf`, `conf/dnsmasq.local.conf`, `BATMAN_IFS` in `general.local.conf`) -einer der beiden Regionen zugeordnet — es gibt keinen eigenen Feature-Flag dafür, sondern -schlicht andere Werte in denselben Konfigurationsdateien. +(`ffc_vpn_gateway_bird_mesh_route_v4` im ffc-mash-Playbook, `conf/dnsmasq.local.conf`, +`BATMAN_IFS` in `general.local.conf`) einer der beiden Regionen zugeordnet — es gibt keinen +eigenen Feature-Flag dafür, sondern schlicht andere Werte in denselben +Konfigurationsstellen. | | Chemnitz (Standard) | Umland | |---|---|---| -| Statische BIRD-Route (`protocol static` in `bird.conf`) | `10.149.0.0/20` | `10.149.16.0/20` | +| Statische BIRD-Route (`ffc_vpn_gateway_bird_mesh_route_v4`) | `10.149.0.0/20` | `10.149.16.0/20` | | DHCP-Range (`dnsmasq.conf`) | `10.149.1.0`–`10.149.14.255` (`/20`, 30 min Lease) | `10.149.17.0`–`10.149.30.255` (`/20`, 30 min Lease) | | `BATMAN_IFS` | GRE-Interfaces der Chemnitz-Backbone-Server | GRE-Interfaces der für das Umland zuständigen Server | @@ -33,7 +34,7 @@ Routing- oder batman-adv-Ebene. | `10.149.16.0/20` | Statische Route/DHCP-Pool für die Region Umland (siehe oben). | | `SERVICE_ADDRESSES` (frei, pro Server) | Adresse(n) auf `bat0`, z. B. DNS-/DHCP-Gateway-Adresse; wird beim Freifunk-Chemnitz-Team erfragt und in `general.local.conf` sowie `dnsmasq.local.conf` eingetragen. | | `169.254.<3. Oktett>.<4. Oktett>` | Link-Local-Adresse eines Backbone-Servers auf seinen GRE-Tunnel-Interfaces, abgeleitet aus den letzten beiden Oktetten seiner öffentlichen IPv4. Dient nur als BGP-Session-Endpunkt, nicht dem Mesh-Verkehr. | -| `__WANIP__/32` | Die öffentliche IPv4 des jeweiligen Servers selbst, wird als eigene Route ins Mesh announced. | +| `/32` | Die öffentliche IPv4 des jeweiligen Servers selbst, wird als eigene Route ins Mesh announced. | ## IPv6-Adressbereiche diff --git a/docs/komponenten.md b/docs/komponenten.md index 8ac419f..702ba7e 100644 --- a/docs/komponenten.md +++ b/docs/komponenten.md @@ -56,14 +56,17 @@ Backbone-Servern über das öffentliche Internet. Konfiguriert über `lib/gre.sh Zwei getrennte Daemon-Binaries aus derselben BIRD-1.x-Codebasis: `bird` für IPv4, `bird6` für IPv6 (BIRD 2.x hat diese Aufteilung später zu einem einzigen Binary zusammengeführt; -dieses Repository nutzt noch die klassische 1.x-Aufteilung, erkennbar an den getrennten -`lib/bird.sh`/`lib/bird6.sh`-Modulen und `bird.conf`/`bird6.conf`-Dateien). +das Setup nutzt noch die klassische 1.x-Aufteilung mit `/etc/bird/bird.conf` und +`/etc/bird/bird6.conf`). Jeder Server betreibt darüber eine eigene BGP-Instanz und baut zu jedem GRE-Peer eine interne BGP-Session auf. So lernen sich die Server gegenseitig Routen (eigene IP, Mesh-Netz, Service-Adressen, Internet-Default-Route) und ermöglichen serverübergreifendes, ausfallsicheres Routing zusätzlich zur reinen [Layer-2](backbone-netzwerk.md#grundlagen-was-ist-ein-layer-2-netz)-Erreichbarkeit von batman-adv. -Konfiguriert über `lib/bird.sh`/`lib/bird6.sh`, nur aktiv wenn `USE_BIRD=1`. +Die BIRD-Konfiguration und die `bird`/`bird6`-Dienste werden vom Ansible-Playbook +[ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) verwaltet (Rolle +`ffc_vpn_gateway`); `lib/bird.sh`/`lib/bird6.sh` richten nur noch Policy-Routing +(Tabelle 100) und NAT ein, nur aktiv wenn `USE_BIRD=1`. ([Ankündigung der Zusammenführung in BIRD 2](https://bird.network.cz/pipermail/bird-users/2011-August/002341.html)) ### dnsmasq @@ -79,7 +82,9 @@ Nur auf ausgewählten Gateway-Servern aktiv (`USE_DNSMASQ=1`), gesteuert über Router-Advertisement-Daemon für IPv6. Kündigt auf `bat0` die IPv6-Präfixe (`2001:bc8:3f13:ffc2::/64`, `ffc3::/64`) sowie DNS-Server per SLAAC an, sodass sich Mesh-Clients selbst eine IPv6-Adresse konfigurieren können. Nur auf IPv6-Gateway-Servern -aktiv (`USE_RADVD=1`, erfordert `USE_BIRD=1`), gesteuert über `lib/radvd.sh`. +aktiv (`USE_RADVD=1`, erfordert `USE_BIRD=1`), gesteuert über `lib/radvd.sh`. Die +zugehörige IPv6-Default-Route in BIRD6 wird über die Ansible-Rolle gesetzt +(`ffc_vpn_gateway_bird_ipv6_uplink`). ## Eigene Skripte (dieses Repository) @@ -91,20 +96,16 @@ aktiv (`USE_RADVD=1`, erfordert `USE_BIRD=1`), gesteuert über `lib/radvd.sh`. | `lib/gre.sh` | Baut die GRE-Tunnel zu allen in `GRE_PEERS` gelisteten Servern auf/ab und prüft im Watchdog per ICMPv6-Ping, ob sie noch erreichbar sind. | | `lib/batman.sh` | Initialisiert batman-adv, hängt GRE- und fastd-Interfaces ein, konfiguriert `bat0` (Service-Adressen, Bridge-Loop-Avoidance, Bonding) und startet `alfred`/`batadv-vis`. | | `lib/fastd.sh` | Startet/stoppt die fastd-Prozesse für den Client-Zugang. | -| `lib/bird.sh` / `lib/bird6.sh` | Generieren die BIRD-/BIRD6-Konfiguration aus den Templates in `conf/`, tragen BGP-Peers und Routen ein, richten Policy-Routing (Tabelle 100) und NAT ein. `bird_init` rendert zusätzlich die statischen Ausnahmerouten aus `conf/routes/` nach `conf/bird-routes.country.conf`. | +| `lib/bird.sh` / `lib/bird6.sh` | Richten das Policy-Routing (Tabelle 100) und NAT für das Mesh-Netz ein und starten/stoppen die `bird`/`bird6`-Dienste (systemd). Die BIRD-Konfiguration selbst (Router-ID, BGP-Peers, Routen, Länderrouten) kommt aus dem Ansible-Playbook [ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) (Rolle `ffc_vpn_gateway`, `/etc/bird/`). | | `lib/dnsmasq.sh` | Generiert die dnsmasq-Konfiguration und startet/überwacht den Dienst. | -| `lib/radvd.sh` | Startet/überwacht radvd und trägt die IPv6-Default-Route in BIRD6 ein. | +| `lib/radvd.sh` | Startet/überwacht radvd. | | `lib/meshviewer.sh` | Startet `alfred`/`batadv-vis` eigenständig, falls der Server unabhängig von `lib/batman.sh` primär als Meshviewer-Datenquelle dienen soll. | ## Konfigurationsdateien (`conf/`) | Datei | Zweck | |---|---| -| `general.conf` (+ `general.local.conf`) | Zentrale Server-Konfiguration: Netzwerk-Interface/IP, Feature-Flags (`USE_*`), GRE-Peer-Liste, `COUNTRY`/`WANGW` für die Ausnahmerouten. Die `.local.conf`-Variante enthält die serverspezifischen, nicht versionierten Werte. | -| `routes/*.conf` | Statisch gepflegte BIRD-Ausnahme-/Länderrouten: `_global.conf` (überall) + `.conf` (pro Land), Platzhalter `NEXTHOP`. Siehe `conf/routes/README.md`. | -| `bird.conf`, `bird6.conf` | Templates für die BIRD-/BIRD6-Hauptkonfiguration inkl. Policy-Routing-Tabelle `ffc`. | -| `bird-peers.conf` | Template für eine einzelne BGP-Peer-Definition, wird pro GRE-Peer in `bird-peers.local.conf`/`bird6-peers.local.conf` dupliziert. | -| `bird-routes.conf` | Template für eine einzelne statische Route, wird pro Service-Adresse dupliziert. | +| `general.conf` (+ `general.local.conf`) | Zentrale Server-Konfiguration: Netzwerk-Interface/IP, Feature-Flags (`USE_*`), GRE-Peer-Liste. Die `.local.conf`-Variante enthält die serverspezifischen, nicht versionierten Werte. | | `fastd.conf` | fastd-Konfiguration inkl. der Hooks, die neue Client-Interfaces automatisch in batman-adv einhängen. | | `dnsmasq.conf` | Template für DHCP-Range, DNS-Domäne und Gateway-Optionen im Mesh. | | `radvd.conf` | Router-Advertisement-Konfiguration für die beiden IPv6-Mesh-Präfixe. | diff --git a/docs/sicherheitsmodell.md b/docs/sicherheitsmodell.md index 2cdc8e5..8d94df7 100644 --- a/docs/sicherheitsmodell.md +++ b/docs/sicherheitsmodell.md @@ -30,8 +30,8 @@ aufbaut. Die GRE/`gretap`-Tunnel aus `lib/gre.sh` bieten **keine** eingebaute Verschlüsselung oder Authentifizierung — GRE kapselt Frames lediglich, ohne sie kryptografisch zu schützen. -Ebenso enthält `conf/bird-peers.conf` keine BGP-Session-Authentifizierung (z. B. ein -MD5-Passwort). Wer Zugriff auf den Netzwerkpfad zwischen zwei Backbone-Servern im +Ebenso enthält die (per Ansible erzeugte) BIRD-BGP-Konfiguration keine +Session-Authentifizierung (z. B. ein MD5-Passwort). Wer Zugriff auf den Netzwerkpfad zwischen zwei Backbone-Servern im Internet bekommt, kann den GRE- und BGP-Verkehr zwischen ihnen technisch mitlesen oder manipulieren. @@ -44,8 +44,10 @@ Konfiguration, keine im Repository dokumentierte Policy-Aussage. ## BIRD-Ausnahmerouten: statisch statt Laufzeit-Fetch -Die Ausnahme-/Länderrouten für BIRD (`conf/routes/`, gerendert nach -`conf/bird-routes.country.conf`) werden im Repo gepflegt und beim Setup gerendert. +Die Ausnahme-/Länderrouten für BIRD werden im Ansible-Playbook +[ffc-mash](https://github.com/FreifunkChemnitz/ffc-mash) +(`roles/custom/ffc_vpn_gateway/files/bird-routes/`) gepflegt und beim Deploy nach +`/etc/bird/bird-routes.country.conf` gerendert. Früher lud `bird_cron` sie alle 5 Minuten per **unverschlüsseltem `http://`** von `api.chemnitz.freifunk.net` nach und ließ BIRD per `SIGHUP` neu laden — ein On-Path-Angreifer hätte darüber statische Routen in die Routingtabelle der Gateways injizieren können @@ -57,7 +59,7 @@ hätte darüber statische Routen in die Routingtabelle der Gateways injizieren k |---|---|---| | Freifunk-Router ↔ Server (fastd) | Ja (`salsa2012+umac`) | Nein (`on verify "true"`, jeder mit Schlüsselpaar) | | Backbone-Server ↔ Backbone-Server (GRE) | Nein | Nein (statische `GRE_PEERS`-Liste, keine Authentifizierung auf dem Tunnel selbst) | -| Backbone-Server ↔ Backbone-Server (BGP) | Nein | Nein (keine Session-Authentifizierung in `bird-peers.conf`) | +| Backbone-Server ↔ Backbone-Server (BGP) | Nein | Nein (keine Session-Authentifizierung in der BIRD-Konfiguration) | Praktische Konsequenz für den Betrieb: Die Sicherheit des Backbones hängt maßgeblich davon ab, dass ausschließlich vertrauenswürdige, vom Team kontrollierte Server als diff --git a/lib/bird.sh b/lib/bird.sh index 4957987..64e87e5 100644 --- a/lib/bird.sh +++ b/lib/bird.sh @@ -1,37 +1,14 @@ #!/bin/bash -bird_init() { - local ipL1=$(echo $WANIP | awk -F '.' '{print $3}') - local ipL2=$(echo $WANIP | awk -F '.' '{print $4}') - sed -e "s/__BIRD_ROUTER_ID__/169.254.${ipL1}.${ipL2}/g" \ - -e "s/__BIRD_ROUTER_ASN__/${ipL1}${ipL2}/g" \ - -e "s/__WANIP__/${WANIP}/g" \ - -e "s/__WANIF__/${WANIF}/g" \ - conf/bird.conf > conf/bird.local.conf - - echo -n "" > conf/bird-peers.local.conf - for p in "${GRE_PEERS[@]}"; do - local remoteHost=$(echo $p | awk -F ':' '{print $1}') - local remoteIP=$(echo $p | awk -F ':' '{print $2}') - if [ "$remoteHost" ] && [ "$remoteIP" ]; then - # Do not add ourselves as a peer - if [ "$remoteIP" != "$WANIP" ]; then - bird_add_peer "${remoteHost}" "$remoteIP" - fi - else - log_error "Syntax error in peer definition: ${p}" - fi - done - - echo -n "" > conf/bird-routes.local.conf - for s in "${SERVICE_ADDRESSES[@]}"; do - if [ "$(bird_check_route "$s")" ]; then - bird_add_route "$s" - fi - done - - bird_render_country_routes +# BIRD (IPv4 / BGP) +# +# The BIRD daemon configuration (/etc/bird/bird.conf, bird-routes.country.conf, +# BGP peers) and the bird/bird6 systemd services are managed by Ansible - see the +# ffc_vpn_gateway role in the ffc-mash playbook (templates/bird/*.j2). This module +# only sets up the kernel-side policy routing (table 100) and NAT that BIRD's +# learned routes depend on, and defers start/stop to systemd. +bird_init() { ip rule add from 10.149.0.0/16 lookup 100 ip rule add to 10.149.0.0/16 lookup 100 ip route add default via 127.0.0.1 table 100 metric 1024 @@ -39,56 +16,10 @@ bird_init() { iptables -t nat -A POSTROUTING -o $WANIF -j MASQUERADE } -# Check for route -# $1 IPv4 route -bird_check_route() { - [[ "$1" =~ ^[0-9.]*/[0-9]+ ]] && echo "1" -} - bird_start() { - mkdir /run/bird - bird -c conf/bird.local.conf + systemctl restart bird >> /dev/null 2>&1 } bird_stop() { - killall bird >> /dev/null 2>&1 -} - -# Render the static country/exception routes into bird-routes.country.conf. -# Combines conf/routes/_global.conf with the per-country file (if present) -# and substitutes the NEXTHOP placeholder with the local WAN gateway. -# No network access - the routes are maintained in the repo (see conf/routes/). -bird_render_country_routes() { - local out="conf/bird-routes.country.conf" - : > "$out" - if [ -n "$WANGW" ]; then - [ -f "conf/routes/_global.conf" ] && cat "conf/routes/_global.conf" >> "$out" - [ -n "$COUNTRY" ] && [ -f "conf/routes/${COUNTRY}.conf" ] && cat "conf/routes/${COUNTRY}.conf" >> "$out" - sed -e "s/NEXTHOP/$WANGW/g" -i "$out" - fi -} - -# Add BGP peer -# $1 Hostname -# $2 Peer IPv4 address -bird_add_peer() { - local ipR1=$(echo $2 | awk -F '.' '{print $3}') - local ipR2=$(echo $2 | awk -F '.' '{print $4}') - sed -e "s/__BIRD_REMOTE_HOST__/$1/g" \ - -e "s/__BIRD_REMOTE_IP__/169.254.${ipR1}.${ipR2}/g" \ - -e "s/__BIRD_REMOTE_ASN__/${ipR1}${ipR2}/g" \ - conf/bird-peers.conf >> conf/bird-peers.local.conf -} - -# Add BGP route -# $1 IPv4 Route -# $2 Next hop (optional) -# $3 Next hop interface (optional) -bird_add_route() { - local via="\"bat0\"" - [ "$2" ] && local via="$2" - [ "$3" ] && local via="\"$3\"" - sed -e "s|__BIRD_ROUTE__|$1|g" \ - -e "s/__BIRD_VIA__/$via/g" \ - conf/bird-routes.conf >> conf/bird-routes.local.conf + systemctl stop bird >> /dev/null 2>&1 } diff --git a/lib/bird6.sh b/lib/bird6.sh index 67d2fa0..fd82dc8 100644 --- a/lib/bird6.sh +++ b/lib/bird6.sh @@ -1,80 +1,23 @@ #!/bin/bash -bird6_init() { - local ipL1=$(echo $WANIP | awk -F '.' '{print $3}') - local ipL2=$(echo $WANIP | awk -F '.' '{print $4}') - local ip6L1=$(printf '%x' $ipL1) - local ip6L2=$(printf '%x' $ipL2) - sed -e "s/__BIRD_ROUTER_ID__/169.254.${ipL1}.${ipL2}/g" \ - -e "s/__BIRD_ROUTER_IP__/fe80::ffc:${ip6L1}:${ip6L2}/g" \ - -e "s/__BIRD_ROUTER_ASN__/${ipL1}${ipL2}/g" \ - conf/bird6.conf > conf/bird6.local.conf - - echo -n "" > conf/bird6-peers.local.conf - for p in "${GRE_PEERS[@]}"; do - local remoteHost=$(echo $p | awk -F ':' '{print $1}') - local remoteIP=$(echo $p | awk -F ':' '{print $2}') - if [ "$remoteHost" ] && [ "$remoteIP" ]; then - # Do not add ourselves as a peer - if [ "$remoteIP" != "$WANIP" ]; then - bird6_add_peer "${remoteHost}" "$remoteIP" - fi - else - log_error "Syntax error in peer definition: ${p}" - fi - done - - echo -n "" > conf/bird6-routes.local.conf - for s in "${SERVICE_ADDRESSES[@]}"; do - if [ "$(bird6_check_route "$s")" ]; then - bird6_add_route "$s" - fi - done +# BIRD6 (IPv6 / BGP) +# +# Like lib/bird.sh: the bird6 daemon configuration and the bird6 systemd service +# are managed by Ansible (ffc_vpn_gateway role, templates/bird/bird6.conf.j2). +# This module only sets up the IPv6 policy routing (table 100) and defers +# start/stop to systemd. +bird6_init() { ip -6 rule add from 2001:bc8:3f13:ffc2::/64 lookup 100 ip -6 rule add to 2001:bc8:3f13:ffc2::/64 lookup 100 ip -6 rule add from 2001:bc8:3f13:ffc3::/64 lookup 100 ip -6 rule add to 2001:bc8:3f13:ffc3::/64 lookup 100 } -# Check for route -# $1 IPv6 route -bird6_check_route() { - [[ "$1" =~ ^[a-f0-9:]*/[0-9]+ ]] && echo "1" -} - bird6_start() { - bird6 -c conf/bird6.local.conf + systemctl restart bird6 >> /dev/null 2>&1 } bird6_stop() { - killall bird6 >> /dev/null 2>&1 -} - -# Add BGP peer -# $1 Hostname -# $2 Peer IPv6 address -bird6_add_peer() { - local ipR1=$(echo $2 | awk -F '.' '{print $3}') - local ipR2=$(echo $2 | awk -F '.' '{print $4}') - local ip6R1=$(printf '%x' $ipR1) - local ip6R2=$(printf '%x' $ipR2) - sed -e "s/__BIRD_REMOTE_HOST__/$1/g" \ - -e "s/__BIRD_REMOTE_IP__/fe80::ffc:${ip6R1}:${ip6R2} % 'gre-$1'/g" \ - -e "s/__BIRD_REMOTE_ASN__/${ipR1}${ipR2}/g" \ - conf/bird-peers.conf >> conf/bird6-peers.local.conf -} - -# Add BGP route -# $1 IPv6 Route -# $2 Next hop (optional) -# $3 Next hop interface (mandatory, if $2 is selected) -bird6_add_route() { - local via="\"bat0\"" - if [ "$2" ] && [ "$3" ]; then - local via="$2 % $3" - fi - sed -e "s|__BIRD_ROUTE__|$1|g" \ - -e "s/__BIRD_VIA__/$via/g" \ - conf/bird-routes.conf >> conf/bird6-routes.local.conf + systemctl stop bird6 >> /dev/null 2>&1 } diff --git a/lib/radvd.sh b/lib/radvd.sh index 384555f..8bd5d04 100644 --- a/lib/radvd.sh +++ b/lib/radvd.sh @@ -7,7 +7,10 @@ radvd_init() { if [ "$USE_BIRD" != "1" ]; then log_fatal_error "You must enable BIRD to use RADVD - please check configuration!" fi - bird6_add_route "::/0" "$WANGW6" "$WANIF" + # The IPv6 default route (::/0) that BIRD6 announces for this uplink is now + # part of the Ansible-managed bird6 config: set + # ffc_vpn_gateway_bird_ipv6_uplink: true for this host in the ffc-mash + # playbook (ffc_vpn_gateway role). } radvd_start() {