=== English version below === (version1, 26.2.19)
Diese Artikel beschreibt, wie man auf einem Raspberry Pi die Bremer Gatemon-Software installiert. Mit so einem Gerät hilft man, die Bremer Freifunk-VPN-Server ständig auf Probleme zu überprüfen. Die Ergebnisse aller Gatemons sind unter status.ffhb.de verfügbar.
Fragen zu diesem Artikel könnt ihr im Chat oder auf der Mailing-Liste stellen, wie unter https://ffhb.de/kontakt.html beschrieben. Ich freu mich über Verbesserungen und Korrekturen!
Es soll bewusst auf einem Raspberry Pi laufen, statt auf einem Router. Da so die sicht "als Client" aufs Netz sichergestellt werden soll.
Grundlage für diese Anleitung ist ein Raspberry Pi Model 1B oder besser. Das Gerät wird am Schluss per LAN-Kabel an einen Freifunk-Router angeschlossen und kann dann (ohne Tastatur, Maus oder Monitor) still seinen Dienst verrichten.
Zur Einrichtung braucht man:
Unter https://www.raspberrypi.org/downloads/raspbian/ lädt man sich eines der angebotenen Images runter. Ich gehe in dieser Anleitung davon aus, dass das "Lite"-Image verwendet wird. Wenn man später gerne eine grafische Oberfläche auf dem Raspberry Pi haben möchte, kann man auch eines der anderen Images nehmen. Dann braucht man während der Installation zusätzlich eine USB-Maus.
Das Image schreibt man auf die SD-Karte, wie in der Anleitung beschrieben.
Dann schliesst man an den Raspberry Pi die Tastatur, Monitor und Strom an und wartet, bis der Bootvorgang abgeschlossen ist und der Login-Prompt erscheint. Dort meldet man sich als Benutzer "pi" mit Passwort "raspberry" an (Achtung: standardmäßig ist ein US-Tastatur-Layout eingestellt, so dass bei einer deutschen Tastatur "y" und "z" vertauscht sind).
Erstmal ändert man das Tastatur-Layout: sudo raspi-config
ausführen, dann unter "4. Localisation Options" die Sprache, Zeitzone und das Tastatur-Layout anpassen.
Als nächstes ändert man das Standard-Passwort. Dazu erzeugt man ein neues zufälliges Passwort nach einer dieser Methoden:
pwgen 12 1
ausführenhead /dev/urandom | tr -dc A-Za-z0-9 | head -c12
ausführen
Das neue Passwort schreibt man sich auf einen Zettel auf oder besser: legt es im Passwort-Manager ab.
Dann auf dem Raspberry Pi "passwd" ausführen und das alte Passwort (raspberry) und das neue eingeben.Dann aktiviert man den SSH-Server: sudo raspi-config
ausführen, unter "5. Interfacing" -> "P2 SSH" mit "Yes" bestätigen.
Schließlich legt man mittels nano /etc/network/interfaces.d/eth0
eine neue Datei an, mit folgendem Inhalt:
auto eth0
iface eth0 inet auto
iface eth0 inet6 auto
Idealerweise wird der Raspberry Pi per Kabel mit einem Freifunk-Router verbunden. Man kann ihn aber wohl auch per WLAN verbinden (hab ich aber nicht ausprobiert und ist nicht Thema dieser Anleitung).
Dazu benötigt man einen Freifunk-Router, der noch einen freien LAN-Port hat und bei dem Mesh-on-LAN ausgeschaltet ist.
Der Raspberry Pi wird jetzt an diesen LAN-Port angeschlossen und neugestartet (mittels sudo reboot
). Nach dem Neustart meldet man sich wieder an und schaut dann mit ip a | grep 2a06
, welche nutzbare IPv6-Adresse das Gerät bekommen hat. Beispielausgabe:
inet6 2a06:8782:ffbb:1337:ba27:ebff:fea1:1d97/64 scope global mngtmpaddr dynamic
Der Teil zwischen "inet6" und dem Schrägstrich ist die öffentliche IPv6-Adresse. Unter dieser Adresse meldet man sich jetzt per SSH an (Benutzer "pi").
Die Gatemon-Software benötigt ein sogenanntes API-Token, um Daten zu https://status.ffhb.de/ hochzuladen. Dieses Token bekommt man z.B. im IRC-Chat, oder per Mail-Anfrage an liste@bremen.freifunk.net oder bei einem Freifunk-Treffen: einfach fragen "ich bin der XYZ und hätte gerne ein API-Token für status.ffhb.de". Das Token ist einfach eine lange Zeichenfolge (wie ein langes Passwort). Man sollte ein Token immer nur auf einem einzigen Gatemon verwenden.
Außerdem braucht der Raspberry Pi für die Gatemon-Software eine statische IPv4-Adresse (weil der DHCP-Port für die Tests benötigt wird und man somit keinen DHCP-Client laufen lassen kann). Dazu sucht man sich unter https://wiki.ffhb.de/Dienste/Home#ipv4-adressen eine unbenutzte Adresse und trägt diese auf der Wiki-Seite ein (zusammen mit einem IRC-Nick oder anderen Kontaktdaten).
Die gewählte IP (z.B. "10.196.0.250") benutzt man, indem man in /etc/network/interfaces.d/eth0
folgenden Inhalt einträgt (statt des bisherigen Inhalts):
auto eth0
iface eth0 inet static
address 10.196.0.250
netmask 255.255.0.0
gateway 10.196.0.1
dns-nameservers 10.196.0.1 10.196.0.2 10.196.0.3 10.196.0.5 10.196.0.6
iface eth0 inet6 auto
Bei "address" trägt man halt seine eigene gewählte IP-Adresse ein.
Damit der DHCP-Port tatsächlich nicht mehr belegt ist, deaktiviert man den DHCP-Dienst:
sudo systemctl disable dhcpcd
Nach einem Reboot sollte ip a | grep "inet "
die neue Adresse zeigen.
Als nächstes installiert man die nötige Zusatzsoftware, mittels (als root):
apt-get install curl dnsutils gcc git jq libc6-dev make monitoring-plugins-basic monitoring-plugins-standard mtr-tiny
(nicht wundern: dieser Befehl installiert ca. 80 neue Pakete).
Dann installiert man die Gatemon-Software, wie unter https://github.com/FreifunkBremen/gatemon#installation beschrieben (alles als root):
cd /opt
git clone https://github.com/FreifunkBremen/gatemon
cd gatemon
make check_dhcp
make -C libpacketmark
cp gatemon.cfg /etc/
cp gatemon.cron /etc/cron.d/gatemon
Weiterhin bearbeitet man die /etc/gatemon.cfg
und ändert die Angaben für folgende Parameter:
Jetzt wartet man bis zu 15 Minuten; danach sollte auf https://status.ffhb.de/ der eigene Gatemon neu auftauchen. Die Gatemon-Tests werden nun automatisch alle 10 Minuten durchgeführt.
Wenn das alles soweit funktioniert, kann man Tastatur und Monitor abstöpseln und den Raspberry Pi in die Ecke neben den Freifunk-Router stellen. Fertig!
Falls der eigene Gatemon nicht nach spätestens 15 Minuten auf status.ffhb.de auftaucht, kann man mal die Check-Software von Hand starten:
sudo /opt/gatemon/gatemon.sh
Aus den Ausgaben lässt sich evtl. rausfinden, wo das Problem liegt.
Weitere Hilfe findet man dann im IRC, auf der Mailingliste oder beim Treffen.
sudo netstat -tapnu | grep ":68 "
anzeigen, wer grad Port 68 benutztsudo systemctl disable dhcpcd
für die Zukunft deaktivieren, und dann mit sudo systemctl stop dhcpcd
den aktuellen dhcpcd-Prozess beenden/etc/cron.d/gatemon
heißen, ohne .cron
am Ende)Ein Update wird wie folgt durchgeführt. SSH Zugang als root zum Gatemon herstellen.
cd /opt/gatemon
git pull --rebase https://github.com/FreifunkBremen/gatemon
make check_dhcp
make -C libpacketmark
Konfigdatei anpassen: /etc/gatemon.cfg
MESHMON_NAME
in GATEMON_NAME
MESHMON_PROVIDER
in GATEMON_PROVIDER
jq
installieren (z.B. apt-get install jq
)
This article describes the necessary steps to install a gatemon on a Raspberry Pi. The Gatemon-Software is a piece of software, created by some of the "Freifunk Bremen" People. The gatemons deliver data about the VPN-Servers continously and thereby help finding problems. The results of all gatemons (in Bremen) are available here: status.ffhb.de .
Questions on this Article and the gatemons are welcome either in the Chat or on the Mailinglist, Contact-Info can be found here: https://ffhb.de/kontakt.html. we are looking forward to constructive criticism and feedback.
The hardware described here is a raspberry PI, which will in the end be connected by ethernet and power-cord only, no keyboard or mouse is needed after the setup. For the setup-process you will need:
Get an image of raspian here: https://www.raspberrypi.org/downloads/raspbian/ This Documentation assumes the Lite-Version of Raspian. For other images than "Lite" it may be necessary to use an USB-Mouse.
Write the image to a SD-Card, as mentioned in the raspberry- Guide.
Connect your Keyboard and Screen to the PI, connect the power-cord and wait for the boot process to finish. You should see a login-prompt. login with user "pi" and password "raspberry". Take care of possibly switched "y" and "z", depending on your keyboard.
First: switch the keyboard layout to your favourite settings with the following command:
sudo raspi-config
You can also change timezone and language there.
Next: change the default password. Therefore a new one can be created in one of the following ways:
pwgen 12 1
on another computer.head /dev/urandom | tr -dc A-Za-z0-9 | head -c12
on your raspi.Both commands will print a new password, which you should write down on paper or a password-manager.
To finally change the password, use passwd
on your raspi and type in the old password (raspberry), followed by the new one.
Then, the ssh-server needs to be activated.
type sudo raspi-config
in your commandline, under section "5.Interfacing" you can find the option "P2 SSH". Confirm the entry with "Yes".
Finally create a textfile with the follwing command:
nano /etc/network/interfaces.d/eth0
and put the follwing 3 lines in:
auto eth0
iface eth0 inet auto
iface eth0 inet6 auto
Idealy you connect the raspi to one of your freifunk-routers, you could also use the wifi, but none of us tried this so far. (Many router-models have USB-Ports, you can use this to power the raspi)
To be connected to the Freifunk-Net, the Mesh-on-LAN option must be disabled. (The raspi needs the client-net)
After connecting the raspi to the router and rebooting via sudo reboot
, you can login again and check the ip-adresses, the raspi was given.
Example:
ip a | grep 2a06
Example output:
inet6 2a06:8782:ffbb:1337:ba27:ebff:fea1:1d97/64 scope global mngtmpaddr dynamic
The part between "inet6" and the slash is the public IPv6-Adress.
Use it to connect to the pi via ssh (user "pi")
The Gatemon-Software needs an API-Token to send data to https://status.ffhb.de/. You can get a Token in our IRC-Chat or via Mail to: liste@bremen.freifunk.net. Simply say "hi, i am XYZ and would like to have a Token for status.ffhb.de" The Token is a long string, just like a password. Please use on Token for each Gatemon.
Furthermore your raspi needs a static IPv4-Adress (since the DHCP-Port is needed for the tests and cannot be used for the normal adress-management). To set a static IPv4-Adress, go to https://wiki.ffhb.de/Dienste/Home#ipv4-adressen, find an unused adress, write this adress with your nickname and some contact data on this page.
The adress (lets assume 10.196.0.250 here) can be used by writing the following lines (and only these lines) in the file /etc/network/interfaces.d/eth0
auto eth0
iface eth0 inet static
address 10.196.0.250
netmask 255.255.0.0
gateway 10.196.0.1
dns-nameservers 10.196.0.1 10.196.0.2 10.196.0.3 10.196.0.5 10.196.0.6
iface eth0 inet6 auto
Write your own address in the "address" line.
To ensure that the DHCP port is actually unused, the DHCP service must be disabled:
sudo systemctl disable dhcpcd
After reboot, the command ip a | grep "inet "
should print your IP.
Next, you need the software, install it via (as root):
apt-get install curl dnsutils gcc git jq libc6-dev make monitoring-plugins-basic monitoring-plugins-standard mtr-tiny
(dont panic, this command installs around 80 packages)
Then install the Gatemon-Software as described on the github-page (as root):
git clone https://github.com/FreifunkBremen/gatemon
cd gatemon
make check_dhcp
cp gatemon.cfg /etc/
cp gatemon.cron /etc/cron.d/gatemon
Second last step:
edit the following lines in the file /etc/gatemon.cfg
:
Now wait 15 Minutes. Then, the gatemon should appear on https://status.ffhb.de/. The Gatemon-Tests will run every 10 Minutes. If that works, you can disconnect screen and keyboard and place the raspi next to your freifunk-Router. DONE!
If the Gatemon doesnt appear on status.ffhb.de after 15 minutes, you can start the Check-Software with this command:
sudo /opt/gatemon/gatemon.sh
The output may tell you more about the problem. If the output looks fine, the cronjob may be the problem.
Further assistance can be requested in the IRC-Channel or on the Mailinglist.
sudo netstat -tapnu | grep ":68 "
to see which process is using port 68sudo systemctl disable dhcpcd
die disable it for the future, then stop the current dhcpcd process with sudo systemctl stop dhcpcd
/etc/cron.d/gatemon
, without any .cron
suffix)