Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
en:howtos:pivpn [2022/02/17 17:38] – Externe Bearbeitung 127.0.0.1 | en:howtos:pivpn [2022/02/18 08:09] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== PiVPN Installation und Konfiguration | + | ====== PiVPN installation and configuration |
- | Die Frage, wozu man ein [[https:// | + | The question why you need a [[https:// |
- | * Sicheres Nutzen des Internets auch in öffentlichen | + | * Secure use of the Internet |
- | * Zugriff auf die heimische Netzwerkfestplatte | + | * Access to the home network hard drive |
- | VPNs werden von den unterschiedlichsten Providern angeboten, sind aber in der Regel kostenpflichtig oder im Datenvolumen beschränkt. Hinzu kommt die Überlegung das man dem Anbieter vertrauen muss, denn aller Netzwerkverkehr läuft über dessen Server und kann dort mitgelesen werden.\\ | + | VPNs are offered by a wide variety of providers, but are usually subject to a fee or limited |
- | Für eine eigene | + | For your own VPN solution you can use |
- | * der eigenen | + | * your own (WLAN) |
- | * ein Computer im heimischen Netz in Frage | + | * a computer in the home network |
- | Einige Routerhersteller bieten in im Gerät die Möglichkeit zum Aufbau eines VPN an. Ich selbst habe eine Fritz!Box | + | Some router manufacturers offer the option of setting up a VPN in the device. I myself have a Fritz!Box |
- | Einen Computer zu Hause zu betreiben hört sich aufwendig an, ist es aber nicht. Der RaspBerry Pi, ein billiger | + | Running a computer at home sounds complicated, but it isn't. The RaspBerry Pi, a cheap (both to buy and run) home server. The range of software is overwhelming, as usual with Linux, |
- | Für eine eigene | + | For your own VPN solution, |
- | Wie kommt nun PiVPN ins Spiel? Einen OpenVPN | + | So how does PiVPN come into play? Installing, configuring and operating an OpenVPN |
- | Lesenswerte Artikel zu diesem Thema (u.a. hilfreiche Quellen meiner ersten Versuche mit PiVPN): | + | Articles worth reading on this topic (including helpful sources from my first attempts with PiVPN): |
- | * [[https:// | + | * [[https:// |
- | * [[https:// | + | * [[https:// |
- | * [[https:// | + | * [[https:// |
- | * Hilfreich ist auch [[https:// | + | * Also helpful is [[https:// |
- | * [[https:// | + | * [[https:// |
- | + | ===== Preparation | |
- | ===== Vorbereitung | + | Before the installation, one should gather some information that will be needed during the installation. The most important ones are listed here, in most cases suitable suggestions are made. |
- | Vor der Installation sollte man einige Informationen zusammenstellen, die während der Installation benötigt werden. Die wichtigsten sind hier gelistet, in den meisten Fällen werden geeignete Vorschläge gemacht. | + | * Name of the network interface, usually |
- | * Name des Netzwerk Interfaces, i.d.R. | + | * Port number on which OpenVPN |
- | * Port Nummer, auf der OpenVPN | + | * The protocol to be used can be UDP or TCP, each with advantages and disadvantages. I personally prefer |
- | * Das Protokoll das benutzt werden soll, zur Auswahl stehen | + | * Setting up a dynamic address is also necessary. There are various free providers of such services, which is the best depends on the support in the home router. |
- | * Die Einrichtung einer dynamischen Adresse ist ebenfalls von Nöten. Es gibt diverse kostenlose Anbieter solcher Dienste, welcher der Beste ist hängt von der Ünterstützung im heimischen Router ab. | + | |
===== Installation ===== | ===== Installation ===== | ||
curl -L https:// | curl -L https:// | ||
| | ||
- | Das war es schon, es werden im Verlauf der Installations eingie Fragen gestellt, deren Antworten für den "normalen" VPN Nutzer sinnvoll vorbelegt sind. Es empfiehlt sich, einen Blick in die [[https:// | + | That's it, a few questions are asked during the installation, the answers to which are pre-assigned for the "normal" VPN user. It is advisable to take a look at the [[https:// |
- | \\ | + | \\ |
- | Nach erfolgter Installation ist [[http:// | + | After the installation, |
- | \\ | + | \\ |
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
Zeile 43: | Zeile 42: | ||
- | ===== Konfiguration | + | ===== Configuration |
- | Wir haben nun ein funktionierendes | + | We now have a working |
- | Manchmal wollen wir aber mehr, z.B. Zugriff auf andere Geräte | + | But sometimes we want more, e.g. access to other devices |
- | Dazu muss die Konfigurationsdatei des OpenVPN | + | To do this, the configuration file of the OpenVPN |
| | ||
push "route 192.168.178.0 255.255.255.0 10.8.0.1" | push "route 192.168.178.0 255.255.255.0 10.8.0.1" | ||
route 192.168.178.0 255.255.255.0 10.8.0.1 | route 192.168.178.0 255.255.255.0 10.8.0.1 | ||
- | Damit kommen wir nun über den VPN an die Geräte | + | We can now access the devices |
- | push "dhcp-option DNS 192.168.178.1" | + | push "dhcp option DNS 192.168.178.1" |
- | push "dhcp-option DOMAIN fritz.box | + | push "dhcp option DOMAIN fritz.box |
- | ergänzt werden. | + | be added. |
- | ===== Clients anlegen und verwalten | + | ===== Create and manage clients |
- | Der Server läuft, kommen wir nun zu den Clients. Auf jedem Client muss die OpenVPN | + | The server is running, now we come to the clients. The OpenVPN |
- | Wie kommen wir nun an eine Konfigurationsdatei? Bisher haben wir nur über Openvpn | + | How do we get a configuration file now? So far we've only talked about Openvpn, |
pivpn --help | pivpn --help | ||
::: Control all PiVPN specific functions! | ::: Control all PiVPN specific functions! | ||
Zeile 64: | Zeile 63: | ||
::: Usage: pivpn < | ::: Usage: pivpn < | ||
::: | ::: | ||
- | ::: Commands: | + | ::: commands: |
- | ::: -a, add [nopass] | + | ::: -a, add [nopass] Create a client ovpn profile, |
- | ::: -c, clients | + | ::: -c, clients List any connected clients to the server |
- | ::: -d, debug Start a debugging session if having trouble | + | ::: -d, debug Start a debugging session if having trouble |
- | ::: -l, list | + | ::: -l, list List all valid and revoked certificates |
- | ::: -r, revoke | + | ::: -r, revoke Revoke a client ovpn profile |
- | ::: -h, help | + | ::: -h, help Show this help dialog |
- | ::: -u, uninstall | + | ::: -u, uninstall Uninstall PiVPN from your system! |
| | ||
- | und erhalten eine Liste der verfügbaren Optionen. Eine Client Konfigurationsdatei wird z.B. mit | + | and get a list of available options. A client configuration file is e.g |
pivpn -a | pivpn -a | ||
- | Enter a Name for the Client: | + | Enter a Name for the Client: |
Enter the password for the client: | Enter the password for the client: | ||
Enter the password again to verify: | Enter the password again to verify: | ||
- | spawn ./easyrsa build-client-full | + | spawn ./easyrsa build-client-full |
Note: using Easy-RSA configuration from: ./vars | Note: using Easy-RSA configuration from: ./vars | ||
rand: Use -help for summary. | rand: Use -help for summary. | ||
Generating a 4096 bit RSA private key | Generating a 4096 bit RSA private key | ||
..........................++ | ..........................++ | ||
- | ......................................................++ | + | .................................................. ....++ |
writing new private key to '/ | writing new private key to '/ | ||
Enter PEM pass phrase: | Enter PEM pass phrase: | ||
Zeile 90: | Zeile 89: | ||
Using configuration from / | Using configuration from / | ||
Check that the request matches the signature | Check that the request matches the signature | ||
- | | + | |
The Subject' | The Subject' | ||
- | commonName | + | commonName :ASN.1 12:'myiphone' |
Certificate is to be certified until Sep 12 12:54:03 2027 GMT (3650 days) | Certificate is to be certified until Sep 12 12:54:03 2027 GMT (3650 days) | ||
Write out database with 1 new entries | Write out database with 1 new entries | ||
- | | + | |
- | Client' | + | Client' |
- | Client' | + | Client' |
- | CA public | + | CA public |
tls-auth Private Key found: ta.key | tls-auth Private Key found: ta.key | ||
- | | + | ================================================== |
- | Done! meiniphone.ovpn successfully created! | + | Done! myiphone.ovpn successfully created! |
- | | + | |
/ | / | ||
for easy transfer. | for easy transfer. | ||
- | | + | ================================================== |
- | + | We have now created our first client and must transfer the resulting configuration file to the client. We can see where to find it in the last paragraph of the output. | |
- | Damit haben wir jetzt unseren ersten Client angelegt und müssen die so entstandende Konfigurationsdatei auf den Client übertragen. Wo sie zu finden ist, sehen wir im letzten Absatz des Output. | + | |
- | ====== | + | ====== |
- | Über die gängige Nutzung hinaus, Nutzung der Heimnetzes von außerhalb, habe ich folgendes Setup implementiert. Der OpenVPN | + | In addition to the usual use, use of the home network from outside, I have implemented the following setup. The OpenVPN |
- | Das Ziel soll sein folgende Verbindung zu ermöglichen:\\ | + | The aim should be to enable the following connection:\\ |
- | | + | |
- | zu realisieren. Beachte, das zwischen Heimnetz und Raspberry Pi der Pfeil nur in eine Richtung zeigt. | + | to realize. Note that between home network and Raspberry Pi, the arrow only points |
- | ===== Vorbereitung | + | ===== Preparation |
- | Mein Server im Internet | + | My server on the Internet |
net.ipv4.ip_forward=1 | net.ipv4.ip_forward=1 | ||
- | Um dies ohne reboot | + | To enable this without a reboot, the command |
sudo sysctl -w net.ipv4.ip_forward=1 | sudo sysctl -w net.ipv4.ip_forward=1 | ||
- | abgesetzt werden. Der Eintrag | + | be dropped off; be discontinued; |
/ | / | ||
/ | / | ||
/ | / | ||
- | sorgen dafür, das die Firewall den Traffic akzeptiert. Diese Einstellungen überleben keinen Reboot, also muss unter / | + | ensure that the firewall accepts the traffic. These settings do not survive a reboot, so a script must be stored under / |
sudo apt-get install iptables-persistent netfilter-persistent | sudo apt-get install iptables-persistent netfilter-persistent | ||
- | Die Frage, ob die aktuellen Regeln übernommen werden sollen, kann man getrost mit " | + | The question of whether the current rules should be adopted can confidently be answered with " |
- | sudo iptables-save >dateiname | + | sudo iptables-save >filename |
- | sudo iptables-restore <dateiname | + | sudo iptables-restore <filename |
- | dienen dazu die aktuellen Regeln zu sicher oder wiederherzustellen. Um geänderte Regeln für den Reboot zu speichern muss die Datei / | + | serve to save or restore the current rules. In order to save changed rules for the reboot, the file / |
sudo iptables-save >/ | sudo iptables-save >/ | ||
- | geändert werden. Wie das Ganze mit IPv6 funktioniert überlasse ich den man-pages. =) | + | be changed. How the whole thing works with IPv6 I leave to the man pages. =) |
- | ===== Konfiguration | + | ===== Configuration |
- | Jetzt ist der Moment gekommen, die Verbindung zu ermöglichen. Der OpenVPN | + | Now is the moment to enable the connection. The OpenVPN |
ifconfig-push 10.8.0.250 255.255.255.0 | ifconfig-push 10.8.0.250 255.255.255.0 | ||
iroute 192.168.178.0 255.255.255.0 | iroute 192.168.178.0 255.255.255.0 | ||
- | Sobald sich der Raspberry Pi am VPN anmeldet werden die entsprechenden Route an alle Clients, die sich DANACH am VPN anmelden, mitgeteilt. Auch der OpenVPN | + | As soon as the Raspberry Pi registers with the VPN, the corresponding route is communicated to all clients who AFTER register with the VPN. The OpenVPN |
- | Stellt sich die Frage, wie man sicherstellt, | + | The question arises how to ensure that the Raspberry Pi always receives the above address |
- | / | + | / |
client_name, | client_name, | ||
- | " | + | " |
- | Wenn ich nichts vergessen habe und alles richtig installiert und konfiguriert wurde funktioniert jetzt alles. Ein weiteres | + | If I didn't forget anything and everything was installed and configured correctly, everything works now. Integrating another |
- | + | ||
- | + |