Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
Raspberry Pi aufsetzen
Hier soll es darum gehen einen Raspberry Pi aufzusetzen. Ich nutze hier einen Mac, für Windows oder Linux hilft sicherlich Google weiter.
MicroSD Karte vorbereiten
- Raspbian Jessie Lite von https://www.raspberrypi.org/downloads/raspbian/ beziehen
- MicroSD Karte in SD Adapter einlegen und in den Mac stecken
Je nachdem was auf der MicroSD Karte drauf ist, wird die vom macOS automatisch gemounted. In diesem Fall ist es „disk2“, dies kann bei euch aber etwas anderes ein.
Achtung! Wer hier jetzt versehentlich seine eigene SSD/HDD des Mac auswählt, baut echt Bockmist! Bitte vorsichtig!
BennyE$ diskutil list /dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *500.3 GB disk0 1: EFI EFI 209.7 MB disk0s1 2: Apple_CoreStorage 499.4 GB disk0s2 3: Apple_Boot Recovery HD 650.0 MB disk0s3 /dev/disk1 #: TYPE NAME SIZE IDENTIFIER 0: Apple_HFS Macintosh HD *499.1 GB disk1 Logical Volume on disk0s2 Unlocked Encrypted /dev/disk2 #: TYPE NAME SIZE IDENTIFIER 0: FDisk_partition_scheme *15.5 GB disk2 1: Windows_FAT_32 boot 66.1 MB disk2s1 2: Linux 15.5 GB disk2s2
Damit wir mit der Karte arbeiten können, müssen wir sie erstmal unmounten.
BennyE$ diskutil unmountdisk /dev/disk2 Unmount of all volumes on disk2 was successful
Nun sind wir bereit die MicroSD Karte mit dem Image (das ZIP müsst ihr natürlich entpacken) zu beschreiben. Hier ist es wichtig auf dem Mac (BSD-like) /dev/rdisk2 zu verwenden, da die Übertragung sonst ewig dauert. (Dies hängt damit zusammen dass rdisk ein „character device“ ist und disk ein „block device“.)
BennyE$ sudo dd if=2016-05-10-raspbian-jessie-lite.img of=/dev/rdisk2 bs=1024k 1322+0 records in 1322+0 records out 1386217472 bytes transferred in 126.697464 secs (10941162 bytes/sec)
Wer Lust hat kann den Vorgang parallel mit iostat überwachen
BennyE$ iostat disk2 10 disk2 cpu load average KB/t tps MB/s us sy id 1m 5m 15m 676.90 0 0.00 7 4 89 1.95 1.99 2.03 1024.00 10 10.20 3 3 94 2.19 2.04 2.05 1024.00 14 13.79 4 3 93 2.08 2.02 2.04 1024.00 14 13.70 4 3 93 2.23 2.05 2.05 1024.00 14 13.90 5 3 92 1.96 2.00 2.03 1024.00 13 12.90 8 4 88 2.05 2.01 2.04 1024.00 14 13.80 4 3 93 1.96 2.00 2.03 1024.00 14 13.79 4 3 93 1.97 2.00 2.03 1024.00 14 13.70 2 3 95 1.82 1.96 2.02 1024.00 14 13.90 2 3 95 1.76 1.95 2.01 769.03 12 9.31 6 3 91 1.87 1.97 2.01 8.00 0 0.00 2 3 95 2.12 2.02 2.03 0.00 0 0.00 2 2 95 2.10 2.01 2.03 0.00 0 0.00 5 3 93 2.15 2.03 2.03
- MicroSD Karte aus SD Adapter entfernen und in den Raspberry Pi (3) stecken
Einrichtung des Raspberry Pi
Nach dem Boot ist der Raspberry Pi automatisch im Netzwerk (LAN) erreichbar (wenn man DHCP nutzt, wovon ich mal ausgehe).
Die IP-Adresse entnimmt man entweder seinem DHCP-Server oder dem Boot-Screen des Pi.
Benutzer/Passwort für die erste Anmeldung:
- Benutzer: pi
- Passwort: raspberry
Wer direkt mit der Tastatur am Pi angeschlossen ist, sollte beachten dass standardmäßig ein QWERTY-Tastaturlayout hinterlegt ist. Man sollte also „raspberrz“ eintippen. Bei SSH gilt euer eigenes Tastaturlayout.
BennyE$ ssh pi@192.168.5.156 The authenticity of host '192.168.5.156 (192.168.5.156)' can't be established. RSA key fingerprint is c8:c2:66:d9:74:ca:0a:ed:4a:0c:80:b3:c5:e9:27:d5. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.5.156' (RSA) to the list of known hosts. pi@192.168.5.156's password: raspberry The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. pi@raspberrypi:~ $
Im nächsten Schritt wollen wir dem Raspberry Pi das korrekte Tastaturlayout verpassen, die Zeitzone auf Berlin einstellen, den Hostname setzen und optional (wenn vorhanden) die Wi-Fi/Wireless Schnittstelle auf Deutschland einrichten.
pi@raspberrypi:~ $ sudo raspi-config
Für deutsches Tastaturlayout wählt nacheinander:
„Internationalisation Options“ →
„Keyboard Layout“→
z.B. „Generic 105-key (Intl) PC“ →
„Other“ →
„German“ →
„German“ →
„The default for the keyboard layout“ →
„No compose key“
Für deutsche Zeitzone wählt nacheinander:
„Internationalisation Options“ →
„Change Timezone“ →
„Europe“ →
„Berlin“
Den Hostname des Raspberry Pi festlegen:
„Advanced Options“ →
„Hostname“ →
„OK“ →
„pi1“ (wahlweise was ihr wollt)
Für deutsche regulatorische Domäne Wi-Fi/Wireless:
„Internationalisation Options“ →
„Change Wi-fi Country“ →
„DE Germany“
Nach diesen Änderungen ist ein Neustart notwendig, wählt „Finish“ und ihr werdet nach dem Reboot gefragt den ihr mit „Yes“ bestätigt.
Raspberry Pi aktualisieren
Nach dem Neustart aus dem vorherigen Schritt, steht erst einmal eine Aktualisierung des Betriebssystems an (Korrekturen und Behebung von poteniellen Sicherheitsproblemen). Dieses Thema solltet ihr ernst nehmen!
pi@raspberrypi:~ $ sudo apt-get update && sudo apt-get dist-upgrade
Der Raspberry aktualisiert daraufhin erst einmal die Informationsbasis welche Pakete aktuell sind und bietet euch danach zahlreiche Pakete zur Aktualisierung an:
Do you want to continue? [Y/n]
Dies mit „Enter“ bestätigen und warten …
Neues Passwort für Benutzer "pi" festlegen
Um ungebetene Gäste vom System fernzuhalten, sollte nun das Passwort geändert werden:
pi@raspberrypi:~ $ sudo raspi-config
Um das Passwort zu ändern, wählt:
„Change User Password“ →
„OK“ →
Enter new UNIX password:
Retype new UNIX password:
Pakete nachinstallieren
- VIM
- tcpdump
- iperf3
- tshark
- smcroute
pi@raspberrypi:~ $ sudo apt-get install -y vim tcpdump iperf3
Optional (smcroute)
Multicast am OmniSwitch 6450 (6.7.1.86.R03) + Raspberry Pi
Der Linux Kernel des Raspberry Pi macht von Haus aus Multicast, daher muss man hier nicht groß rumsuchen:
pi@pi1:~ $ ifconfig eth0 eth0 Link encap:Ethernet HWaddr b8:27:eb:82:26:a8 inet addr:192.168.5.155 Bcast:192.168.5.255 Mask:255.255.255.0 inet6 addr: fe80::e72a:7f1b:ac2c:ca62/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:123 errors:0 dropped:0 overruns:0 frame:0 TX packets:126 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:12051 (11.7 KiB) TX bytes:16815 (16.4 KiB) pi@pi1:~ $ ip maddr show dev eth0 2: eth0 link 33:33:00:00:00:01 link 33:33:ff:2c:ca:62 link 01:00:5e:00:00:01 link 33:33:00:00:00:fb link 01:00:5e:00:00:fb inet 224.0.0.251 inet 224.0.0.1 inet6 ff02::fb inet6 ff02::1:ff2c:ca62 inet6 ff02::1 inet6 ff01::1 pi@pi1:~ $ ping 239.0.10.1 PING 239.0.10.1 (239.0.10.1) 56(84) bytes of data. ^C --- 239.0.10.1 ping statistics --- 6 packets transmitted, 0 received, 100% packet loss, time 5004ms
Am Pi2 kann man diese Pakete auch sehen (aber es wird nicht darauf geantwortet)
pi@pi2:~ $ sudo tcpdump -lvvvni eth0 host 239.0.10.1 tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 20:43:11.536867 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 828, seq 1, length 64 20:43:12.544589 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 828, seq 2, length 64 20:43:13.544467 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 828, seq 3, length 64 20:43:14.544464 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 828, seq 4, length 64 20:43:15.544456 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 828, seq 5, length 64
Soweit so gut, nur wollen wir die Pakete erst erhalten nachdem wir diese Gruppe per IGMP gejoined haben.
Dafür müssen wir erstmal dem OmniSwitch etwas mehr Intelligenz einhauchen, damit der nicht alles einfach vervielfältigt.
-> show ip multicast Status = disabled, Querying = disabled, Proxying = disabled, Spoofing = disabled, Zapping = disabled, Querier Forwarding = disabled, Flood Unknown = disabled, Dynamic control drop-all status = disabled, Version = 2, Robustness = 2, Query Interval (seconds) = 125, Query Response Interval (tenths of seconds) = 100, Last Member Query Interval (tenths of seconds) = 10, Unsolicited Report Interval (seconds) = 1, Router Timeout (seconds) = 90, Source Timeout (seconds) = 30, Max-group = 0, Max-group action = none -> ip multicast status enable -> show ip multicast Status = enabled, Querying = disabled, Proxying = disabled, Spoofing = disabled, Zapping = disabled, Querier Forwarding = disabled, Flood Unknown = disabled, Dynamic control drop-all status = disabled, Version = 2, Robustness = 2, Query Interval (seconds) = 125, Query Response Interval (tenths of seconds) = 100, Last Member Query Interval (tenths of seconds) = 10, Unsolicited Report Interval (seconds) = 1, Router Timeout (seconds) = 90, Source Timeout (seconds) = 30, Max-group = 0, Max-group action = none
Wiederholt man nun den ping auf dem Pi1, empfängt man auf Pi2 nichts mehr - dafür sieht der Switch den Pi1 als Source
pi@pi1:~ $ ping 239.0.10.1 PING 239.0.10.1 (239.0.10.1) 56(84) bytes of data. ^C --- 239.0.10.1 ping statistics --- 5 packets transmitted, 0 received, 100% packet loss, time 4004ms
-> show ip multicast source Total 1 Sources Group Address Host Address Tunnel Address VLAN Port ---------------+---------------+---------------+-----+----- 239.0.10.1 192.168.5.155 0.0.0.0 1 1/7
pi@pi2:~ $ sudo tcpdump -lvvvni eth0 host 239.0.10.1 tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes ^C 0 packets captured 0 packets received by filter 0 packets dropped by kernel
Zum Zeitpunkt zu dem dieser Artikel geschrieben wurde, beherrschen die iproute2 Werkzeuge zwar die Anzeige von Multicast-Einstellungen, man kann aber keine neuen Gruppen manuell registrieren.
Pi2 SSH Session 1
pi@pi2:~ $ sudo smcroute -d pi@pi2:~ $ sudo smcroute -j eth0 239.0.10.1
Pi2 SSH Session 2
pi@pi2:~ $ sudo tcpdump -lvvvnni eth0 igmp or host 239.0.10.1 tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 21:25:04.000098 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto IGMP (2), length 40, options (RA)) 192.168.5.156 > 224.0.0.22: igmp v3 report, 1 group record(s) [gaddr 239.0.10.1 to_ex { }] 21:25:04.750039 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto IGMP (2), length 40, options (RA)) 192.168.5.156 > 224.0.0.22: igmp v3 report, 1 group record(s) [gaddr 239.0.10.1 to_ex { }]
Pi1, mal lospingen
pi@pi1:~ $ ping 239.0.10.1 PING 239.0.10.1 (239.0.10.1) 56(84) bytes of data. ^C --- 239.0.10.1 ping statistics --- 10 packets transmitted, 0 received, 100% packet loss, time 9003ms
Der OmniSwitch 6450 sieht die Pakete und vermittelt sie auch weiter
-> show ip multicast source Total 1 Sources Group Address Host Address Tunnel Address VLAN Port ---------------+---------------+---------------+-----+----- 239.0.10.1 192.168.5.155 0.0.0.0 1 1/7 -> show ip multicast group Total 1 Groups Group Address Source Address VLAN Port Mode Static Count Life RVLAN ---------------+---------------+-----+-----+--------+-------+------+-----+------ 239.0.10.1 0.0.0.0 1 1/3 exclude no 2 133 -
Pi2 SSH Session 2
pi@pi2:~ $ sudo tcpdump -lvvvnni eth0 igmp or host 239.0.10.1 tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 21:25:25.919115 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 873, seq 2, length 64 21:25:26.919035 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 873, seq 3, length 64 21:25:27.919029 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 873, seq 4, length 64 21:27:06.528880 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 874, seq 2, length 64 21:27:07.528765 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 874, seq 3, length 64 21:27:08.528766 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 874, seq 4, length 64 21:27:09.528757 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 874, seq 5, length 64 21:27:10.528758 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 874, seq 6, length 64 21:27:11.528757 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 874, seq 7, length 64 21:27:12.528759 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 874, seq 8, length 64 21:27:13.528761 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 874, seq 9, length 64 21:27:14.528757 IP (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.5.155 > 239.0.10.1: ICMP echo request, id 874, seq 10, length 64