accesspoint
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige ÜberarbeitungVorherige ÜberarbeitungNächste Überarbeitung | Vorherige Überarbeitung | ||
| accesspoint [2020/10/11 17:20] – noone | accesspoint [2022/03/11 23:45] (aktuell) – noone | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ==== Raspberry Pi als WLAN Access Point nutzen | + | ====Raspberry Pi als Access-Point einrichten==== |
| - | Um möglichst überall im Haus mit WLAN versorgt | + | ===Software installieren=== |
| + | Es empfiehlt sich gleich am Anfang die notwendige Software | ||
| + | sudo apt install dnsmasq hostapd iptables | ||
| - | === Voraussetzungen === | + | * **dnsmasq** ist ein DNS-Server für die Namensauflösung |
| - | Natürlich benötigen Sie zuerst einen Raspberry Pi mit Netzteil, SD-Karte (mit installiertem Raspbian) | + | * **hostapd** erzeugt das WLAN, an dem sich die WLAN-Clients anmelden |
| + | * **iptables** sorgt dafür, dass die WLAN-Clients per NAT eine IP-Verbindung ins nächste Netzwerk bekommen (Routing/ | ||
| - | === Installation & Einrichtung | + | ===WLAN-Interface konfigurieren=== |
| - | Nachdem der Raspberrry Pi nun seinen Platz gefunden hat und angeschlossen ist, verbinden Sie sich mittels SSH und aktualisieren Sie zuerst alle Pakete und den Kernel, damit die Unterstützung für möglichst jeden WLAN-Stick sichergestellt ist: | + | |
| - | sudo apt-get update && | + | Seit Raspbian Jessie ist standardmäßig ein DHCP Client Daemon (DHCPCD) aktiviert. Die Netzwerk-Konfiguration wird in der Datei "/ |
| - | | + | sudo nano / |
| - | sudo reboot | + | |
| + | Hier tragen wir folgende Zeilen ein: | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | In dieser IPv4-Konfiguration hat das WLAN-Interface eine statische IPv4-Adresse. Das ist für den Betrieb des DHCP- und DNS-Servers wichtig. | ||
| + | |||
| + | Es wäre auch denkbar, auch der Ethernet-Schnittstelle " | ||
| + | |||
| + | Wir speichern und schließen die Datei mit Strg + O, Return, Strg + X. | ||
| + | |||
| + | Dann starten wir den DHCP Client Daemon neu. | ||
| + | | ||
| + | |||
| + | Dann müssen wir sicherstellen, | ||
| + | ip l | ||
| - | Prüfen Sie nun, ob der WLAN-Stick erkannt wird, indem Sie dazu lsusb auf dem Terminal eingeben. Die Ausgabe der letzten Zeile sollte dann folgendermaßen | + | Beide Netzwerk-Schnittstellen |
| - | Bus 001 Device 005: ID 0bda:8176 Realtec Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter | + | |
| - | Anschließend können Sie die nötigen Pakete hostapd | + | ===DHCP-Server |
| - | sudo apt-get install hostapd | + | Als nächstes richten wir den DHCP-Server und DNS-Cache ein. Der DHCP-Server sorgt dafür, dass die WLAN-Clients nach der Anmeldung alle nötigen Informationen für die IP-Konfiguration bekommen. Der DNS-Dienst übernimmt die Namensauflösung. Um beides kümmert sich "dnsmasq". |
| - | === Access Point einrichten === | + | Dazu müssen |
| - | Zuerst | + | sudo mv /etc/ |
| - | auto lo | + | sudo nano / |
| - | iface lo inet loopback | + | |
| + | Dort tragen wir folgende Zeilen als Minimal-Konfiguration ein: | ||
| + | # DHCP-Server aktiv für WLAN-Interface | ||
| + | interface=wlan0 | ||
| - | # | + | # |
| + | | ||
| - | iface wlan0 inet static | + | # IPv4-Adressbereich und Lease-Time |
| - | address | + | dhcp-range=192.168.1.100, |
| - | | + | |
| - | Wichtig ist, dass wlan0 nur einmalig in dieser Datei genannt | + | # DNS |
| + | | ||
| + | |||
| + | Hier wird der DHCP-Server und das DNS-Forwarding für die Netzwerk-Schnittstelle "wlan0" aktiviert und für die Schnittstelle " | ||
| + | |||
| + | ===DHCP-Server und DNS-Cache prüfen und in Betrieb nehmen (dnsmasq)=== | ||
| + | Vor der Inbetriebnahme empfiehlt es sich, die Konfiguration zu testen. | ||
| + | | ||
| - | Nun muss hostapd eingerichtet werden. Dazu editieren Sie zunächst die 10. Zeile in der Datei / | + | Die Syntaxprüfung sollte mit "OK" |
| - | # Defaults for hostapd initscript | + | |
| - | # | + | |
| - | # See / | + | |
| - | # methods of managing hostapd. | + | |
| - | # | + | |
| - | # Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration | + | |
| - | # file and hostapd will be started during system boot. An example configuration | + | |
| - | # file can be found at / | + | |
| - | # | + | |
| - | | + | |
| - | + | ||
| - | # Additional daemon options to be appended to hostapd command:- | + | |
| - | # | + | |
| - | # | + | |
| - | # | + | |
| - | # | + | |
| - | # Note that -B (daemon mode) and -P (pidfile) options are automatically | + | |
| - | # configured by the init.d script and must not be added to DAEMON_OPTS. | + | |
| - | # | + | |
| - | # | + | |
| - | Und schließlich muss die dort angegebene Deamon-Konfiguration erstellt und mit den gewünschten Einstellungen gefüllt werden. Dazu kopieren Sie einfach diese Konfiguration | + | DNSMASQ neu starten: |
| - | Die wichtigste Anpassung ist die des verwendeten Treibers. Bei den meisten Edimax-Dongles muss nichts nachinstalliert werden, sodass Sie hier den Treiber verwenden können, den die Eingabe von dmesg nach dem Einstecken des Dongles selbst anzeigt. | + | sudo systemctl restart dnsmasq |
| - | # | + | |
| + | DNSMASQ-Status anzeigen: | ||
| + | sudo systemctl status dnsmasq | ||
| + | |||
| + | DNSMASQ beim Systemstart starten: | ||
| + | sudo systemctl enable dnsmasq | ||
| + | |||
| + | ===WLAN-AP-Host einrichten | ||
| + | Dann installieren wir den Host Access Point Daemon, kurz " | ||
| + | |||
| + | Die Konfiguration des WLAN-AP-Hosts: | ||
| + | sudo nano / | ||
| + | |||
| + | Die Datei sollte noch nicht vorhanden und somit leer sein. Wenn die Datei doch vorhanden ist, dann sollte man sie vollständig überschreiben. | ||
| + | In die Datei tragen wir folgende Minimal-Konfiguration ein. Selbstverständlich gibt es noch mehr Parameter, die in diesem Fall keine Rolle spielen. | ||
| + | # | ||
| + | |||
| + | # Schnittstelle und Treiber | ||
| | | ||
| - | # | + | # |
| - | driver=rtl871xdrv | + | |
| - | + | ||
| - | # Deamon-Einstellungen | + | |
| - | | + | |
| - | | + | |
| # WLAN-Konfiguration | # WLAN-Konfiguration | ||
| - | ssid=Raspberry Pi | + | ssid=NETZWERKNAME |
| | | ||
| | | ||
| | | ||
| + | | ||
| + | | ||
| + | | ||
| - | # WLAN-Sicherheit (Passwort unbedingt anpassen!) | + | # WLAN-Verschlüsselung |
| + | | ||
| wpa=2 | wpa=2 | ||
| - | | ||
| | | ||
| - | | ||
| | | ||
| - | + | wpa_passphrase=GEHEIMES_PASSWORT | |
| - | # Ländercode | + | |
| - | | + | |
| - | Zum Abschluss muss ein Client noch eine IP-Adresse erhalten, wenn er sich beim Access Point anmeldet. Dazu editieren Sie die dnsmasq-Konfiguration unter / | + | Drei Einstellungen sind individuell zu tätigen. Das sind der WLAN-Name (" |
| - | # Configuration file for dnsmasq. | + | Der dritte Parameter ist das WLAN-Passwort (" |
| - | # ... | + | |
| - | # If you want dnsmasq to listen for DHCP and DNS requests only on | + | |
| - | # specified interfaces | + | |
| - | # interface | + | |
| - | # Repeat the line for more than one interface. | + | |
| - | | + | |
| - | # ... | + | |
| - | # Uncomment this to enable the integrated DHCP server, you need | + | |
| - | # to supply the range of addresses available for lease and optionally | + | |
| - | # a lease time. If you have more than one network, you will need to | + | |
| - | # repeat this for each network on which you want to supply DHCP | + | |
| - | # service. | + | |
| - | dhcp-range=192.168.2.2,192.168.2.100,255.255.255.0, | + | |
| - | # ... | + | |
| - | Somit vergibt der Raspberry Pi nun IP-Adressen im Bereich von 192.168.2.2 bis 192.168.2.100 für jeweils 12 Stunden. Starten Sie nun die beiden Services neu und verbinden Sie sich mit dem neuen WLAN "Raspberry Pi". Zwar haben Sie noch keine Internet-Verbindung, jedoch können Sie (falls installiert) unter 192.168.2.1 einen Webserver erreichen. | + | Hinweis zum WLAN-Treiber: Es gibt in dieser Konfigurationsdatei den Parameter |
| - | sudo service hostapd restart | + | |
| - | sudo service dnsmasq restart | + | |
| - | === Internet-Verbindung weiterleiten === | + | Anschließend speichern und schließen mit Strg + O, Return, Strg + X. |
| - | Damit nun auch die WLAN-Clients eine Verbindung zum Internet erhalten, müssen Sie ein paar weitere Einstellungen vornehmen: Entfernen Sie zunächst die Raute vor dieser Zeile in der Datei / | + | |
| - | # Uncomment the next line to enable packet forwarding for IPv4 | + | |
| - | # | + | |
| - | Und lesen Sie die Datei anschließend erneut ein: | + | Weil diese Datei das WLAN-Passwort im Klartext enthält, sollte nur der Benutzer " |
| - | | + | |
| - | Nun weisen Sie iptables an, den Internet-Traffic von wlan0 auf eth0 weiterzuleiten, | + | Keine Sorge, mit dem Benutzer " |
| - | # | + | |
| - | | + | |
| - | | + | |
| - | Schließlich machen Sie diese Datei noch ausführbar | + | ===WLAN-AP-Host-Konfiguration prüfen |
| - | sudo chmod +x / | + | Bevor wir uns an das weitere Einrichten des WLAN-Routers machen, nehmen wir zuerst den WLAN-Host in Betrieb. Nur wenn das funktioniert, |
| - | sudo reboot | + | |
| - | === Abschluss === | + | Zur Inbetriebnahme des WLAN-Hosts starten wir " |
| - | Nun können Sie sich mit dem Access Point verbinden und haben eine funktionierende Internetverbindung. | + | sudo hostapd -dd / |
| - | Sollten Sie jedoch weiterhin nicht das Internet erreichen können, prüfen Sie folgende Fehlerquellen: | + | **Hinweis:** Mit "Strg + C" kann man die laufende hostapd-Instanz bei Bedarf beenden. |
| - | * Wurden | + | " |
| - | * Dem Gerät | + | ... |
| + | | ||
| + | ... | ||
| + | wlan0: AP-ENABLED | ||
| + | ... | ||
| - | dhcp-option=3, | + | Das ist eine gute Gelegenheit den WLAN-AP zu testen (ohne Internet-Verbindung). Dazu versucht man mit einem WLAN-Client das WLAN zu finden und sich dort anzumelden. |
| + | Dabei kann man in der Kommandozeile schön beobachten, wie sich der WLAN-Client anmeldet (AP-STA-CONNECTED) und auch wieder abmeldet (AP-STA-DISCONNECTED), | ||
| - | | + | **Hinweis:** Wenn man die Konfiguration per SSH vornimmt, dann sollte man das Prüfen des WLAN-AP mit einem anderen Client vornehmen, weil man sich sonst durch das Wechseln des WLANs die SSH-Verbindung abschießt. |
| - | ====Raspberry Pi as Access Point=== | + | Wenn " |
| + | * Ein beliebter Fehler ist das fehlende " | ||
| + | * Weitere Fehlerquellen kann man ausschließen, | ||
| + | * Eine weitere Fehlerquelle ist die verwendete Distribution. Funktionieren wird es auf alle Fälle mit Raspberry Pi OS. | ||
| - | Equipment List | + | Damit der " |
| - | Below are all the bits and pieces that I used for this Raspberry Pi Wireless Access Point tutorial, there is nothing super special that you will need to be able to complete this. | + | Wenn "hostapd" noch läuft, dann beenden wir es mit " |
| - | Recommended: | + | |
| - | * Raspberry Pi 2 or 3 | + | |
| - | * Micro SD Card or a SD card if you’re using an old version of the Pi. | + | |
| - | * Wifi dongle | + | |
| - | * Ethernet Connection | + | |
| - | Optional: | + | |
| - | * Raspberry Pi Case | + | |
| - | + | ||
| - | ===Setting up the Wireless Access Point=== | + | |
| - | As with most tutorials I do, this one just uses a clean version of Raspbian that has been updated to the latest packages. | + | |
| - | To setup the Raspberry Pi wireless access point we will be making the use of two packages. These two packages are //hostapd// and // | + | |
| - | The other package, //dnsmasq// acts as both a DHCP and DNS server so that we can assign IP addresses and process DNS requests through our Raspberry Pi itself. As a bonus //dnsmasq// is very easy to configure while being somewhat lightweight in comparison to isc-dhcp-server and bind9 packages. | + | |
| - | + | ||
| - | Remember for this specific Raspberry Pi tutorial we will need to be utilizing an ethernet network connection and not the Wi-Fi connection. | + | |
| - | + | ||
| - | **1.** Before we get started installing and setting up our packages, we will first run an update on the Raspberry Pi by running the following two commands. | + | |
| - | sudo apt-get update | + | |
| - | sudo apt-get upgrade | + | |
| - | + | ||
| - | **2.** With that done we can now install our two packages, run the following to commands to install hostapd and dnsmasq. | + | |
| - | sudo apt-get install hostapd | + | |
| - | sudo apt-get install dnsmasq | + | |
| - | + | ||
| - | **3.** With the packages now installed we will want to deny any interfaces from using our wlan0 connection, this will help ensure it is free for our access point. To do this we need to edit our dhcpd configuration file with the following command: | + | |
| - | sudo nano / | + | |
| - | + | ||
| - | **4.** Within this file we need to add the following line to the bottom. However, if you have any interfaces there, then make sure you place it above those as it is needed to override them. | + | |
| - | | + | |
| - | Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter. | + | |
| - | + | ||
| - | **5.** Now we need to setup and configure our static IP address for the wlan0 connection, we will do this within our interfaces file. Begin editing this file by running the following command: | + | |
| - | sudo nano / | + | |
| - | + | ||
| - | **6.** Within this file change the //wlan0// section so it looks like below, this will setup the static ip address and allow hot plugging on the wlan0 connection. | + | |
| - | | + | |
| - | iface wlan0 inet static | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | # | + | |
| - | Now we can save and quit out of the file by pressing Ctrl +X then Y and then Enter. | + | |
| - | + | ||
| - | **7.** Now we need to restart our dhcpd service so it will load in all our configuration changes, we also need to reload our wlan0 interface to make sure it’s loaded in our interface changes. Run the following two commands to reload both: | + | |
| - | sudo service dhcpcd restart | + | |
| - | sudo ifdown wlan0 && sudo ifup wlan0 | + | |
| - | + | ||
| - | **8.** Next, we need to adjust our hostapd configuration, | + | |
| - | sudo nano / | + | |
| - | + | ||
| - | **9.** In this file we need to write out the following lines, these basically set up how we want to interact with the wlan device. The only real lines you should worry about in this file is the ssid= line and the wpa_passphrase= line. | + | |
| - | + | ||
| - | **NOTE:** If you are doing this tutorial with a different Wi-Fi device then the inbuilt Pi 3 one, you may have to also change the driver= line to the best driver for your device, google will be your friend for working out what the best driver to use is. | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | # Use WPA2 | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | # This is the name of the network | + | |
| - | | + | |
| - | # The network passphrase | + | |
| - | | + | |
| - | Remember to change wpa_passphrase to your own password, make sure you set it to something secure so random people can’t just connect into your Wi-Fi access point. | + | |
| - | Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter. | + | |
| - | + | ||
| - | **10.** With that done we should now have our hostapd configuration, | + | |
| - | To begin editing the first of these two files run the following command: | + | |
| sudo nano / | sudo nano / | ||
| - | **11.** In this file, we need to find the following line and replace it: | + | Darin ergänzen wir folgende Parameter: |
| - | Find: | + | RUN_DAEMON=yes |
| - | # | + | |
| - | Replace with: | + | |
| | | ||
| - | Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter. | ||
| - | **12.** Now we need to edit the second configuration file, this file is located within the init.d folder. We can edit the file with the following command: | + | Anschließend speichern und schließen mit Strg + O, Return, Strg + X. |
| - | sudo nano /etc/init.d/hostapd | + | |
| - | **13.** In this file, we need to find the following line and replace it: | + | Den " |
| - | Find: | + | sudo systemctl unmask hostapd |
| - | DAEMON_CONF= | + | sudo systemctl start hostapd |
| - | Replace with: | + | sudo systemctl enable |
| - | DAEMON_CONF=/ | + | |
| - | Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter. | + | |
| - | **14.** With hostapd now set up we need to move onto setting up dnsmasq, before we begin editing its configuration we will move the default one to a new location. We can do this with the following command: | + | Den Status des Daemons kann man mit folgendem Kommando prüfen. |
| - | | + | |
| - | **15.** Now that the original configuration file is moved out of the way we can begin by creating our own new configuration file. We will create and edit the new file with the following command: | + | Hier sollten folgende Zeilen stehen: Loaded: loaded und Active: active |
| - | sudo nano / | + | |
| - | **16.** To this file add the following lines, these lines basically tell the dnsmasq service how to handle all the connections coming through. | + | ===Routing und NAT für die Internet-Verbindung konfigurieren=== |
| - | | + | Bis hierhin hat man im Optimalfall mit dem WLAN-Client eine Verbindung zum WLAN und eine IPv4-Konfiguration erhalten. Was noch nicht funktioniert, ist eine Verbindung ins Internet. |
| - | | + | |
| - | bind-interfaces | + | |
| - | | + | |
| - | domain-needed | + | |
| - | | + | |
| - | | + | |
| - | Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter. | + | |
| - | **17.** Next, we need to configure your Raspberry Pi so that it will forward all traffic from our wlan0 connection over to our ethernet connection. First we must enable it through the sysctl.conf configuration file, so let’s begin editing it with the following command: | + | Zuerst aktivieren wir das Routing. Dazu öffnen wir eine System-Datei. |
| sudo nano / | sudo nano / | ||
| - | **18.** Within this file you need to find the following line, and remove the # from the beginning of it. | + | Hier ergänzen wir die folgende Zeile und schließen die Datei mit Strg + O, Return, Strg + X. |
| - | Find: | + | |
| - | # | + | |
| - | Replace with: | + | |
| | | ||
| - | **19.** Now since we are impatient and don’t want to wait for it to enable on next boot we can run the following command to activate it immediately: | + | Dann aktivieren wir NAT. Wichtig ist hier, dass iptables installiert ist. |
| - | | + | |
| - | **20.** With IPv4 Forwarding now enabled we can configure a NAT between our wlan0 interface and our eth0 interface. Basically, this will forward all traffic from our access point over to our ethernet connection. | + | Dann stellen wir sicher, dass diese Routing-Information gespeichert wird. |
| - | Run the following commands to add our new rules to the iptable: | + | |
| - | sudo iptables | + | |
| - | sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED, | + | |
| - | sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT | + | |
| - | + | ||
| - | **21.** Of course iptables are flushed on every boot of the Raspberry Pi so we will need to save our new rules somewhere so they are loaded back in on every boot. | + | |
| - | To save our new set of rules run the following command: | + | |
| sudo sh -c " | sudo sh -c " | ||
| - | **22.** Now with our new rules safely saved somewhere we need to make this file be loaded back in on every reboot. The most simple way to handle this is to modify the rc.local file. | + | Damit die Routing-Information beim Systemstart geladen wird müssen wir noch ein Systemdatei bearbeiten. |
| - | Run the following command to begin editing the file: | + | |
| sudo nano / | sudo nano / | ||
| - | **23.** Now we are in this file, we need to add the line below. Make sure this line appears above exit 0. This line basically reads the settings out of our iptables.ipv4.nat file and loads them into the iptables. | + | Hier tragen wir vor der Zeilte mit "exit 0" folgende Zeile ein. |
| - | Find: | + | |
| - | exit 0 | + | |
| - | Add above “exit 0”: | + | |
| | | ||
| - | Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter. | ||
| - | **24.** Finally all we need to do is start the two services and enable them in systemctl. Run the following two commands: | + | Anschließend muss man die Datei speichern und schließen: Strg + O, Return, Strg + X. |
| - | sudo service hostapd start | + | |
| - | sudo service dnsmasq start | + | |
| - | **25.** Now you should finally have a fully operational | + | Ein Neustart des Raspberry Pi ist abschließend erforderlich. |
| - | To ensure everything will run smoothly it's best to try rebooting now. This will ensure that everything will successfully re-enable when the Raspberry Pi is started back up. Run the following command to reboot the Raspberry Pi: | + | |
| sudo reboot | sudo reboot | ||
| - | This is yet another great project for the Raspberry Pi that can be extended to make it an extremely useful utility. As I mentioned above you can make this a WiFi access node where you can route all the internet traffic through a VPN. | ||
| - | I hope this Raspberry Pi Wireless access point tutorial has helped you be able to expand your wireless network. If you come across any issues or have some feedback related to this tutorial, then please don’t hesitate to leave a comment below. | + | ===WLAN-, Router- und DHCP/ |
| + | |||
| + | Wenn der Raspberry Pi neu gestartet ist, sollte man kontrollieren, | ||
| + | sudo systemctl status hostapd | ||
| + | ps ax | grep hostapd | ||
| + | sudo systemctl status dnsmasq | ||
| + | ps ax | grep dnsmasq | ||
| - | https:// | + | Wenn die Dienste laufen und die Prozesse für die beiden Dienste angezeigt werden, dann kann man versuchen sich mit einem WLAN-Client am WLAN-Router anzumelden und eine Internet-Verbindung aufzubauen. |
accesspoint.1602429655.txt.gz · Zuletzt geändert: 2020/10/11 17:20 von noone
