Inhaltsverzeichnis

Raspberry Pi

Der Raspberry Pi ist ein kreditkartengroßer Einplatinencomputer, der von der Raspberry Pi Foundation entwickelt wurde.

meine bevorzugte Bezugsquelle: https://pi3g.com/de / https://buyzero.de

siehe auch: https://de.elv.com/technik-fuer-elektronik-projekte/bausaetze/minicomputer-sbc-u.a.-raspberry-pi/

FreeBSD auf dem Raspberry Pi installieren

Seit 2014 kann man FreeBSD auf dem Raspberry Pi installieren.

Stand 2024-03-09: der Raspberry Pi 5 wird leider noch von keinem Image unterstützt.

Raspberry Pi 5

Boot-Reihenfolge ändern

Boot-Reihenfolge ändern (Pi5)

Raspberry Pi 4

Installation von Ubuntu 20.04

Installation von Raspberry-OS (Debian 11)

Konfiguration

https://docs.pi-hole.net/guides/dns/unbound/

Installation der Pi-Hole-Software

Zusätzlich kann man das /tmp-Verzeichnis auch als RAM-Disk auslegen, das verbessert die allgemeine Systemgeschwindigkeit und verlängert die Lebensdauer der SD-Karte, belegt aber etwas RAM. Man sollte das also nur dann tun, wenn man genügent RAM hat! In diesem Beispiel werden 10% vom RAM als RAM-Disk für das /tmp-Verzeichnis verwendet.

root@ubuntu:~# echo "tmpfs /tmp tmpfs rw,relatime,mode=1777,uid=0,gid=0,noexec,nosuid,nodev,seclabel,size=10% 0 0" >> /etc/fstab
root@ubuntu:~# rm -fr /tmp/* /tmp/.*/
root@ubuntu:~# mount /tmp
root@ubuntu:~# df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           782M     0  782M   0% /tmp

root@ubuntu:~# ls -lha /tmp

Man kann aber auch ein Betriebssystem installieren, welches nicht im Imager direkt aufgelistet ist: https://wiki.debian.org/RaspberryPi

> apt install bind9-dnsutils

Pi-Hole installieren

Update Pi-Hole

https://docs.pi-hole.net/main/update/

root@raspberrypi4:~# pihole --help
Usage: pihole [options]
Example: 'pihole -w -h'
Add '-h' after specific commands for more information on usage

...

root@raspberrypi4:~# pihole -v
  Pi-hole version is v5.2.4 (Latest: v5.3.1)
  AdminLTE version is v5.4 (Latest: v5.5)
  FTL version is v5.7 (Latest: v5.8.1)

root@raspberrypi4:~# pihole -up --check-only
  [i] Checking for updates...
  [i] Pi-hole Core:     update available
  [i] Web Interface:    update available
  [i] FTL:              update available

root@raspberrypi4:~# pihole -up
  [i] Checking for updates...
  [i] Pi-hole Core:     update available
  [i] Web Interface:    update available
  [i] FTL:              update available

  [i] Pi-hole core files out of date, updating local repo.
  [✓] Check for existing repository in /etc/.pihole
  [i] Update repo in /etc/.pihole...HEAD is now at 4736e03 Merge pull request #4122 from pi-hole/release/v5.3.1
  [✓] Update repo in /etc/.pihole

  [i] If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'

  [i] Pi-hole Web Admin files out of date, updating local repo.
  [✓] Check for existing repository in /var/www/html/admin
  [i] Update repo in /var/www/html/admin...HEAD is now at 7e602e0 Merge pull request #1779 from pi-hole/release/v5.5
  [✓] Update repo in /var/www/html/admin

  [i] If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'

  [i] FTL out of date, it will be updated by the installer.

  [✓] Root user check

        .;;,.
        .ccccc:,.
         :cccclll:.      ..,,
          :ccccclll.   ;ooodc
           'ccll:;ll .oooodc
             .;cll.;;looo:.
                 .. ','.
                .',,,,,,'.
              .',,,,,,,,,,.
            .',,,,,,,,,,,,....
          ....''',,,,,,,'.......
        .........  ....  .........
        ..........      ..........
        ..........      ..........
        .........  ....  .........
          ........,,,,,,,'......
            ....',,,,,,,,,,,,.
               .',,,,,,,,,'.
                .',,,,,,'.
                  ..'''.

  [✓] Update local cache of available packages
  ...
  ...
  ...
  [✓] Pi-hole blocking is enabled

  [i] The install log is located at: /etc/pihole/install.log
Update Complete! 

  Current Pi-hole version is v5.3.1.
  Current AdminLTE version is v5.5.
  Current FTL version is v5.8.1.

Passwort für Pi-Hole neu setzen:

root@raspberrypi4:~# pihole -a -p
Enter New Password (Blank for no password): 
Confirm Password: 
  [✓] New password set

Pi-Hole Konfigurationsdateien

* Router, und weitere statische Hosts eintragen

/etc/pihole/custom.list
fd00::de15:c8ff:feb6:1e26 fritz.box
192.168.1.254 fritz.box
fd00::da3a:ddff:fed9:1ec1 pi.hole
192.168.1.5 pi.hole
fd00::3e49:37ff:fe07:21ce heins.info
192.168.1.1 heins.info
fd00::dea6:32ff:feea:c128 pi4.heins.info
192.168.1.4 pi4.heins.info
fd00::da3a:ddff:fed9:1ec1 pi5.heins.info
192.168.1.5 pi5.heins.info
/etc/pihole/pihole-FTL.conf
#; Pi-hole FTL config file
#; Comments should start with #; to avoid issues with PHP and bash reading this file
PRIVACYLEVEL=0
RATE_LIMIT=1000/60

* WEBPASSWORD ist hier entfernt worden, also nicht einfach kopieren & überschreiben * korrekten Port bei DNS-Server beachten * in der Pi-Hole-Admin-GUI darauf achten, dass nur Custom mit localhost IPs aktiviert ist

/etc/pihole/setupVars.conf
PIHOLE_INTERFACE=end0
QUERY_LOGGING=true
INSTALL_WEB_SERVER=true
INSTALL_WEB_INTERFACE=true
LIGHTTPD_ENABLED=true
CACHE_SIZE=10000
DNS_FQDN_REQUIRED=false
DNS_BOGUS_PRIV=false
DNSMASQ_LISTENING=local
WEBPASSWORD=
BLOCKING_ENABLED=true
WEBUIBOXEDLAYOUT=traditional
WEBTHEME=default-auto
DNSSEC=false
REV_SERVER=false
DHCP_ACTIVE=false
TEMPERATUREUNIT=C
PIHOLE_DNS_1=127.0.0.1#5335
PIHOLE_DNS_2=::1#5335

Netzwerkkonfiguration

resolv.conf

/etc/resolv.conf
nameserver ::1
nameserver 127.0.0.1
options edns0 trust-ad
search fritz.box

systemd-networkd

siehe systemd-networkd

mit folgenden Änderungen:

/etc/systemd/network/default.network
[Network]
IPv6PrivacyExtensions=false
DNS=::1
DNS=127.0.0.1
 
[DHCPv4]
UseDNS=false
 
[DHCPv6]
UseDNS=false
 
[IPv6AcceptRA]
Token=eui64
UseDNS=false

unbound

apt install unbound

rm /etc/unbound/unbound.conf.d/resolvconf_resolvers.conf
curl -o /etc/unbound/root.hints https://www.internic.net/domain/named.cache

* Port 5335, da Pi-Hole ja Port 53 belegt und der Haupt-DNS-Server sein soll

siehe dns_mit_unbound

mit folgenden Änderungen:

server:
	port: 5335
	interface-automatic-ports: "5335"

Restart Services

systemctl restart systemd-networkd && systemctl status systemd-networkd
systemctl restart unbound && systemctl status unbound
systemctl restart pihole-FTL && systemctl status pihole-FTL

Kommunikations-Server installieren

Mumble (TS3 - Alternative)

siehe: MumbleSich selbst zum Admin machen

root@raspberrypi4:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

root@raspberrypi4:~# apt install mumble-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  avahi-daemon libavahi-client3 libavahi-common-data libavahi-common3 libavahi-compat-libdnssd1 libavahi-core7 libdaemon0
  libdouble-conversion3 libnss-mdns libpcre2-16-0 libprotobuf17 libqt5core5a libqt5dbus5 libqt5network5 libqt5sql5
  libqt5sql5-sqlite libqt5xml5 libzeroc-ice3.7 qttranslations5-l10n
Suggested packages:
  avahi-autoipd avahi-autoipd | zeroconf libthai0
The following NEW packages will be installed:
  avahi-daemon libavahi-client3 libavahi-common-data libavahi-common3 libavahi-compat-libdnssd1 libavahi-core7 libdaemon0
  libdouble-conversion3 libnss-mdns libpcre2-16-0 libprotobuf17 libqt5core5a libqt5dbus5 libqt5network5 libqt5sql5
  libqt5sql5-sqlite libqt5xml5 libzeroc-ice3.7 mumble-server qttranslations5-l10n
0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded.
Need to get 8473 kB of archives.
After this operation, 43.3 MB of additional disk space will be used.
Do you want to continue? [Y/n]

root@raspberrypi4:~# vi /etc/mumble-server.ini
root@raspberrypi4:~# fgrep 'Password' /var/log/mumble-server/mumble-server.log
root@raspberrypi4:~# /etc/init.d/mumble-server status

Der Windows-Client für Mumble/Murmur steht hier zum Download bereit (es enthält auch einen Murmur-Server für Windows).

Element/Matrix/Synapse (Discord - Alternative)

root@raspberrypi4:~# apt install matrix-synapse
root@raspberrypi4:~# openssl ecparam -out /etc/matrix-synapse/homeserver.tls.key -name secp256k1 -genkey
root@raspberrypi4:~# openssl req -new -x509 -key /etc/matrix-synapse/homeserver.tls.key -keyform PEM -out /etc/matrix-synapse/homeserver.tls.crt -outform PEM -days 7000 -subj "/emailAddress=email@adresse.de/C=DE/ST=Hessen/L=Frankfurt/O=Firma/OU=Abteilung/CN=Hostname"
root@raspberrypi4:~# openssl dhparam -out /etc/matrix-synapse/homeserver.tls.dh 4096
root@raspberrypi4:~# vi /etc/matrix-synapse/homeserver.yaml

root@raspberrypi4:~# /etc/init.d/matrix-synapse status

benutzte Ports, diese sollte man im Router entsprechend eintragen (z.B. Port-Weiterleitung):

443/tcp for HTTPS
8448/tcp for Matrix federation
3478/tcp, 5349/tcp, 3478/udp, 5349/udp, 49152-49172/udp for TURN/STUN

spezielle Einstellungen

root@ubuntu:~# mount /dev/mmcblk0p1 /mnt/

root@ubuntu:~# vi /mnt/config.txt
root@ubuntu:~# umount /mnt/

eine einfache Teilsicherung für eine schnelle Wiederherstellung (simple Backup-Alternative mit Board-Mitteln)

# ssh -A root@raspi
Enter passphrase for key '/root/.ssh/id_ed25519':

root@ubuntu:~# tar czf - /root/ /home/ /etc/ /opt/ | ssh backup@server.de "cat > raspi_sicherung_$(date +'%F_%H-%M-%S').tgz"

Wenn dann die SD-Karte im Raspi durch einen Stromausfall oder ein Versehen kaputt geht, kann man das System mit den folgenden Schritten wiederherstellen:

  1. auf die SD-Karte mit dem Raspberry Pi Imager wieder ein neues Betriebssystem aufspielen
  2. des Raspi mit der SD-Karte wieder starten
  3. im DHCP-Server (meistens macht das die Fritz!Box) nachschauen, welche IP der Raspberry Pi 4 bekommen hat (in diesem Beispiel verwenden wir die IP 192.168.0.131)
  4. einloggen (das initiale Passwort lautet ''ubuntu''): ssh ubuntu@192.168.0.131
    • jetzt ist man gezwungen ein anständiges Passwort zu setzen
    • danach wird man automatisch wieder ausgeloggt
  5. erneut einloggen (ab jetzt mit dem neuen Passwort): ssh ubuntu@192.168.0.131
  6. beim ersten mal wieder ausloggen, damit die Datei .bash_history mit den richtigen Rechten angelegt wird: exit
  7. erneut einloggen: ssh ubuntu@192.168.0.131
  8. zum Super-User werden: sudo su - ; exit
  9. das System aktualisieren: time (locale-gen; apt update; dpkg --configure -a; apt autoremove; apt full-upgrade; apt autoremove) && echo OK; dpkg --configure -a; dpkg -l | sed "s/^ii[ ]*//;s/ .*//" | egrep ^linux-; uname -a
  10. damit die Aktualisierungen aktiviert werden können, muss rebootet werden: reboot
  11. die Sicherung wieder auf den Raspi zurückspielen
    • ssh backup@server.de 'cat raspi_sicherung_2021-03-13_16-36-47.tgz' | tar xzf - -C /
  12. Reboot

WireGuard-VPN einrichten

root@ubuntu:~# apt install wireguard
root@ubuntu:~# ip link add dev wg0 type wireguard
root@ubuntu:~# ip address add dev wg0 192.168.2.4/24
root@ubuntu:~# vi /etc/wireguard/wg0.conf

FIXME Dieser Artikel ist noch im Aufbau und zeigt noch kein funktionierendes Vorgehen! FIXME

wg genkey | tee /etc/wireguard/wg.key | wg pubkey > /etc/wireguard/wg.pub ; chmod 0640 /etc/wireguard/wg.key
wg genkey | tee /etc/wireguard/honor10_wg.key | wg pubkey > /etc/wireguard/honor10_wg.pub ; chmod 0640 /etc/wireguard/honor10_wg.key

Das eben erzeugte Schlüsselpaar in der Konfigurationsdatei "/etc/wireguard/wg0.conf" hinterlegen.

Damit die IPs zwischen den Netzen geroutet werden:

sysctl net.ipv4.ip_forward=1
sysctl net.ipv6.conf.all.forwarding=1
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.forwarding=1" >> /etc/sysctl.conf
wg setconf wg0 /etc/wireguard/wg0.conf
systemctl enable wg-quick@wg0
service wg-quick@wg0 start
service wg-quick@wg0 status

Raspberry Pi 3

Raspberry Pi als Desktop und Netbook nutzen

Raspberry Pi 3 Modell B

Seit Montag, dem 29. Februar 2016 ist das Raspberry Pi 3 Modell B käuflich zu erwerben, auch ein Ubuntu Mate 15.10-Image liegt im Internet schon bereit.

… Für den Raspberry Pi 3 haben sich mit der heutigen offiziellen Vorstellung die Gerüchte der letzten Tage bestätigt. Neben einer CPU mit 1.2 GHz und der Unterstützung des 64-Bit-Befehlssatzes sind WLAN und Bluetooth LE jetzt auf der Platine integriert. Ansonsten bleibt die technische Basis unverändert. Auch der Preis bleibt bei 35 US-Dollar. Erste Shops wie Pollin, Reichelt und Watterott bieten den Raspberry Pi 3 Model B hierzulande bereits für um die 40 Euro an.

Raspberry Pi mit Kamera

Den Raspberry Pi mit Kamera ausstatten, für 6,10€ (2021) extra:

> apt install motion
> vi /etc/default/motion
...
start_motion_ daemon="yes"
...

> motion
...
Started stream webcam server in port 8081

Zugriff bekommt man jetzt über localhost:8081

Alternativen

Die aus meiner Sicht, interessantesten Einplatinencomputer, die eine Alternative zum Raspberry Pi darstellen, ist die Odroid-Reihe. Sie haben meistens nicht nur eine schnellere CPU, sondern meist auch noch 2x S-ATA on board.

Benschmark-Vergleich zwischen Pi4, Odroid XU4, Odroid N2 und Odroid N2+

Stand: Februar 2023

DCF77

Gekoppelt mit einem DCF77-Funkmodul, eignet sich der RasPi perfekt als hochpräziser Zeitgeber fürs heimische LAN. Das Einrichten des Gespanns hat sich jedoch in den letzten Jahren drastisch verändert.